testMailClient.to("to@you.com"); testMailClient.setSubject("Test subject"); testMailClient.setMessage( "test line 1\n" + "test line 2" ); Thread client = new Thread(testMailClient); client.start(); try { server.join(60 * 1000); // 60s client.join(30 * 1000); // a further 30s } catch (InterruptedException ie ) { fail("InterruptedException: " + ie); } String result = testMailServer.getResult(); String expectedResult = "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n" + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" + "250\r\n" + "RCPT TO: <to@you.com>\r\n" + "250\r\n" + "DATA\r\n" + "354\r\n" + "Subject: Test subject\r\n" + "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" + "To: to@you.com\r\n" + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + "\r\n" + "test line 1\r\n" + "test line 2\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>"); testMailClient.to("to@you.com"); testMailClient.setMessage( "test line 1\n" + "test line 2" ); Thread client = new Thread(testMailClient); client.start(); try { server.join(60 * 1000); // 60s client.join(30 * 1000); // a further 30s } catch (InterruptedException ie ) { fail( "InterruptedException: " + ie ); } String result = testMailServer.getResult(); String expectedResult = "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n" + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" + "250\r\n" + "RCPT TO: <to@you.com>\r\n" + "250\r\n" + "DATA\r\n" + "354\r\n" + "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" + "To: to@you.com\r\n" + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + "\r\n" + "test line 1\r\n" + "test line 2\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/mail/MailMessageTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/mail/MailMessageTest.java
Method name: void testToOnly() Method name: void testNoSubject()
Number of AST nodes: 10 Number of AST nodes: 10
1
testMailClient.to("to@you.com");
1
testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>");
2
        testMailClient.setSubject("Test subject");
2
        testMailClient.to("to@you.com");
3
        testMailClient.setMessage( "test line 1\n" +
3
        testMailClient.setMessage( "test line 1\n" +
4
            "test line 2" );
4
            "test line 2" );
5
        Thread client = new Thread(testMailClient);
5
        Thread client = new Thread(testMailClient);
6
        client.start();
6
        client.start();
7
        try {
7
        try {
8
            server.join(60 * 1000); // 60s
8
            server.join(60 * 1000); // 60s
9
            client.join(30 * 1000); // a further 30s
9
            client.join(30 * 1000); // a further 30s
10
        } catch (InterruptedException ie ) {
10
        } catch (InterruptedException ie ) {
11
            fail("InterruptedException: " + ie);
11
            fail( "InterruptedException: " + ie );
12
        }
12
        }
13
        String result = testMailServer.getResult();
13
        String result = testMailServer.getResult();
14
        String expectedResult = "220 test SMTP EmailTaskTest\r\n" +
14
        String expectedResult = "220 test SMTP EmailTaskTest\r\n" +
15
        "HELO " + local + "\r\n" +
15
        "HELO " + local + "\r\n" +
16
        "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" +
16
        "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" +
17
        "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" +
17
        "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" +
18
        "250\r\n" +
18
        "250\r\n" +
19
        "RCPT TO: <to@you.com>\r\n" +
19
        "RCPT TO: <to@you.com>\r\n" +
20
        "250\r\n" +
20
        "250\r\n" +
21
        "DATA\r\n" +
21
        "DATA\r\n" +
22
        "354\r\n" +
22
        "354\r\n" +
23
        "Subject: Test subject\r\n" +
24
            "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" +
23
        "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" +
25
            "To: to@you.com\r\n" +
24
            "To: to@you.com\r\n" +
26
        "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" +
25
        "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" +
27
        "\r\n" +
26
        "\r\n" +
28
        "test line 1\r\n" +
27
        "test line 1\r\n" +
29
        "test line 2\r\n" +
28
        "test line 2\r\n" +
30
        "\r\n" +
29
        "\r\n" +
31
        ".\r\n" +
30
        ".\r\n" +
32
        "250\r\n" +
31
        "250\r\n" +
33
        "QUIT\r\n" +
32
        "QUIT\r\n" +
34
        "221\r\n";
33
        "221\r\n";
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons38
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    testMailClient.to("to@you.com");
    6
    testMailClient.to("to@you.com");
    7
    testMailClient.setSubject("Test subject");
    7
    testMailClient.setSubject("Test subject");
    5
    testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>");
    Differences
    Expression1Expression2Difference
    "Test subject""Mail Message "LITERAL_VALUE_MISMATCH
    setSubjectfromMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression testMailClient.setSubject("Test subject") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testMailClient.setSubject("Test subject") is a void method call, and thus it cannot be parameterized
    Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") is a void method call, and thus it cannot be parameterized
    5
    testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>");
    8
    testMailClient.setMessage("test line 1\n" + "test line 2");
    7
    testMailClient.setMessage("test line 1\n" + "test line 2");
    9
    Thread client = new Thread(testMailClient);
    8
    Thread client = new Thread(testMailClient);
    10
    client.start();
    9
    client.start();
    11
    try
    10
    try
    12
    server.join(60 * 1000);
    11
    server.join(60 * 1000);
    13
    client.join(30 * 1000);
    12
    client.join(30 * 1000);
    14
    String result = testMailServer.getResult();
    13
    String result = testMailServer.getResult();
    15
    String expectedResult = "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n" + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" + "250\r\n" + "RCPT TO: <to@you.com>\r\n" + "250\r\n" + "DATA\r\n" + "354\r\n" + "Subject: Test subject\r\n" + "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" + "To: to@you.com\r\n" + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + "\r\n" + "test line 1\r\n" + "test line 2\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
    15
    String expectedResult = "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n" + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" + "250\r\n" + "RCPT TO: <to@you.com>\r\n" + "250\r\n" + "DATA\r\n" + "354\r\n" + "Subject: Test subject\r\n" + "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" + "To: to@you.com\r\n" + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + "\r\n" + "test line 1\r\n" + "test line 2\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
    14
    String expectedResult = "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n" + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" + "250\r\n" + "RCPT TO: <to@you.com>\r\n" + "250\r\n" + "DATA\r\n" + "354\r\n" + "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" + "To: to@you.com\r\n" + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + "\r\n" + "test line 1\r\n" + "test line 2\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
    Differences
    Expression1Expression2Difference
    "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n"+ "250 "+ local+ " Hello "+ local+ " [127.0.0.1], pleased to meet you\r\n"+ "MAIL FROM: \r\n"+ "250\r\n"+ "RCPT TO: \r\n"+ "250\r\n"+ "DATA\r\n"+ "354\r\n"+ "Subject: Test subject\r\n"+ "From: Mail Message \r\n"+ "To: to@you.com\r\n"+ "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n"+ "\r\n"+ "test line 1\r\n"+ "test line 2\r\n"+ "\r\n"+ ".\r\n"+ "250\r\n"+ "QUIT\r\n"+ "221\r\n""220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n"+ "250 "+ local+ " Hello "+ local+ " [127.0.0.1], pleased to meet you\r\n"+ "MAIL FROM: \r\n"+ "250\r\n"+ "RCPT TO: \r\n"+ "250\r\n"+ "DATA\r\n"+ "354\r\n"+ "From: Mail Message \r\n"+ "To: to@you.com\r\n"+ "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n"+ "\r\n"+ "test line 1\r\n"+ "test line 2\r\n"+ "\r\n"+ ".\r\n"+ "250\r\n"+ "QUIT\r\n"+ "221\r\n"INFIX_EXTENDED_OPERAND_NUMBER_MISMATCH
    14
    String expectedResult = "220 test SMTP EmailTaskTest\r\n" + "HELO " + local + "\r\n" + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + "MAIL FROM: <EmailTaskTest@ant.apache.org>\r\n" + "250\r\n" + "RCPT TO: <to@you.com>\r\n" + "250\r\n" + "DATA\r\n" + "354\r\n" + "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" + "To: to@you.com\r\n" + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + "\r\n" + "test line 1\r\n" + "test line 2\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
    Precondition Violations (5)
    Row Violation
    1Expression testMailClient.setSubject("Test subject") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression testMailClient.setSubject("Test subject") is a void method call, and thus it cannot be parameterized
    4Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") is a void method call, and thus it cannot be parameterized
    5Clone fragment #1 returns variables result, expectedResult , while Clone fragment #2 returns variables result, expectedResult