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";
testMailClient.to("to@you.com"); testMailClient.setSubject("Test subject"); testMailClient.setMessage(""); 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" + "\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 testNoSubject() Method name: void testEmptyBody()
Number of AST nodes: 10 Number of AST nodes: 10
1
testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>");
1
testMailClient.to("to@you.com");
2
        testMailClient.to("to@you.com");
2
        testMailClient.setSubject("Test subject");
3
        testMailClient.setMessage( "test line 1\n" +
3
        testMailClient.setMessage(
4
            "test line 2" );
4
"");
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" +
23
        "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" +
24
            "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" +
24
            "To: to@you.com\r\n" +
25
            "To: to@you.com\r\n" +
25
        "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" +
26
        "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" +
26
        "\r\n" +
27
        "\r\n" +
27
        "test line 1\r\n" +
28
        "
28
        "test line 2\r\n" +
29
\r\n" +
29
        "\r\n" +
30
        "\r\n" +
30
        ".\r\n" +
31
        ".\r\n" +
31
        "250\r\n" +
32
        "250\r\n" +
32
        "QUIT\r\n" +
33
        "QUIT\r\n" +
33
        "221\r\n";
34
        "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)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>");
    5
    testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>");
    7
    testMailClient.setSubject("Test subject");
    Differences
    Expression1Expression2Difference
    "Mail Message ""Test subject"LITERAL_VALUE_MISMATCH
    fromsetSubjectMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    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") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") is a void method call, and thus it cannot be parameterized
    Expression testMailClient.setSubject("Test subject") is a void method call, and thus it cannot be parameterized
    7
    testMailClient.setSubject("Test subject");
    6
    testMailClient.to("to@you.com");
    6
    testMailClient.to("to@you.com");
    7
    testMailClient.setMessage("test line 1\n" + "test line 2");
    7
    testMailClient.setMessage("test line 1\n" + "test line 2");
    8
    testMailClient.setMessage("");
    Differences
    Expression1Expression2Difference
    "test line 1\n" + "test line 2"""TYPE_COMPATIBLE_REPLACEMENT
    8
    testMailClient.setMessage("");
    8
    Thread client = new Thread(testMailClient);
    9
    Thread client = new Thread(testMailClient);
    9
    client.start();
    10
    client.start();
    10
    try
    11
    try
    11
    server.join(60 * 1000);
    12
    server.join(60 * 1000);
    12
    client.join(30 * 1000);
    13
    client.join(30 * 1000);
    13
    String result = testMailServer.getResult();
    14
    String result = testMailServer.getResult();
    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";
    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";
    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" + "\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
    Differences
    Expression1Expression2Difference
    "From: Mail Message \r\n""Subject: Test subject\r\n"LITERAL_VALUE_MISMATCH
    "To: to@you.com\r\n""From: Mail Message \r\n"LITERAL_VALUE_MISMATCH
    "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n""To: to@you.com\r\n"LITERAL_VALUE_MISMATCH
    "\r\n""X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n"LITERAL_VALUE_MISMATCH
    "test line 1\r\n""\r\n"LITERAL_VALUE_MISMATCH
    "test line 2\r\n""\r\n"LITERAL_VALUE_MISMATCH
    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" + "\r\n" + "\r\n" + ".\r\n" + "250\r\n" + "QUIT\r\n" + "221\r\n";
    Precondition Violations (5)
    Row Violation
    1Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression testMailClient.setSubject("Test subject") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression testMailClient.from("Mail Message <EmailTaskTest@ant.apache.org>") is a void method call, and thus it cannot be parameterized
    4Expression testMailClient.setSubject("Test subject") 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