testMailClient.bcc("bcc@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" + "RCPT TO: <cc1@you.com>\r\n" + "250\r\n" + "RCPT TO: <cc2@you.com>\r\n" + "250\r\n" + "RCPT TO: <bcc@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" + "Cc: cc1@you.com, cc2@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( "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";
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 testAPIExample() Method name: void testToOnly()
Number of AST nodes: 10 Number of AST nodes: 10
1
testMailClient.bcc("bcc@you.com");
1
testMailClient.to("to@you.com");
2
        testMailClient.setSubject("Test subject");
2
        testMailClient.setSubject("Test subject");
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
        "RCPT TO: <cc1@you.com>\r\n" +
22
        "250\r\n" +
23
        "RCPT TO: <cc2@you.com>\r\n" +
24
        "250\r\n" +
25
        "RCPT TO: <bcc@you.com>\r\n" +
26
        "250\r\n" +
27
        "DATA\r\n" +
21
        "DATA\r\n" +
28
        "354\r\n" +
22
        "354\r\n" +
29
        "Subject: Test subject\r\n" +
23
        "Subject: Test subject\r\n" +
30
        "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" +
24
            "From: Mail Message <EmailTaskTest@ant.apache.org>\r\n" +
31
        "To: to@you.com\r\n" +
25
            "To: to
32
        "Cc: cc1@you.com, cc2@you.com\r\n" +
26
@you.com\r\n" +
33
        "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" +
27
        "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" +
34
        "\r\n" +
28
        "\r\n" +
35
        "test line 1\r\n" +
29
        "test line 1\r\n" +
36
        "test line 2\r\n" +
30
        "test line 2\r\n" +
37
        "\r\n" +
31
        "\r\n" +
38
        ".\r\n" +
32
        ".\r\n" +
39
        "250\r\n" +
33
        "250\r\n" +
40
        "QUIT\r\n" +
34
        "QUIT\r\n" +
41
        "221\r\n";
35
        "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.3
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.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    9
    testMailClient.bcc("bcc@you.com");
    9
    testMailClient.bcc("bcc@you.com");
    6
    testMailClient.to("to@you.com");
    Differences
    Expression1Expression2Difference
    "bcc@you.com""to@you.com"LITERAL_VALUE_MISMATCH
    bcctoMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression testMailClient.bcc("bcc@you.com") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testMailClient.to("to@you.com") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testMailClient.bcc("bcc@you.com") is a void method call, and thus it cannot be parameterized
    Expression testMailClient.to("to@you.com") is a void method call, and thus it cannot be parameterized
    6
    testMailClient.to("to@you.com");
    10
    testMailClient.setSubject("Test subject");
    7
    testMailClient.setSubject("Test subject");
    11
    testMailClient.setMessage("test line 1\n" + "test line 2");
    8
    testMailClient.setMessage("test line 1\n" + "test line 2");
    12
    Thread client = new Thread(testMailClient);
    9
    Thread client = new Thread(testMailClient);
    13
    client.start();
    10
    client.start();
    14
    try
    11
    try
    15
    server.join(60 * 1000);
    12
    server.join(60 * 1000);
    16
    client.join(30 * 1000);
    13
    client.join(30 * 1000);
    17
    String result = testMailServer.getResult();
    14
    String result = testMailServer.getResult();
    18
    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" + "RCPT TO: <cc1@you.com>\r\n" + "250\r\n" + "RCPT TO: <cc2@you.com>\r\n" + "250\r\n" + "RCPT TO: <bcc@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" + "Cc: cc1@you.com, cc2@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";
    18
    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" + "RCPT TO: <cc1@you.com>\r\n" + "250\r\n" + "RCPT TO: <cc2@you.com>\r\n" + "250\r\n" + "RCPT TO: <bcc@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" + "Cc: cc1@you.com, cc2@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";
    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"+ "RCPT TO: \r\n"+ "250\r\n"+ "RCPT TO: \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"+ "Cc: cc1@you.com, cc2@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"+ "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"INFIX_EXTENDED_OPERAND_NUMBER_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" + "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.bcc("bcc@you.com") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression testMailClient.to("to@you.com") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression testMailClient.bcc("bcc@you.com") is a void method call, and thus it cannot be parameterized
    4Expression testMailClient.to("to@you.com") is a void method call, and thus it cannot be parameterized
    5Clone fragment #1 returns variables expectedResult, result , while Clone fragment #2 returns variables result, expectedResult