XmlElement xml = new XmlElement("account"); xml.addAttribute("name", "my account"); xml.addAttribute("uid", "0"); XmlElement child = xml.addSubElement("identity"); child.addAttribute("name", "John Doe"); child.addAttribute("attach_signature", "false"); child = xml.addSubElement("popserver"); child.addAttribute("port", "25"); child.addAttribute("login_method", "USER"); child = xml.addSubElement("specialfolders"); child.addAttribute("inbox", "101"); child.addAttribute("sent", "104"); AccountItem item = new AccountItem(xml); // second account item XmlElement xml2 = new XmlElement("account"); xml2.addAttribute("uid", "0"); xml2.addAttribute("name", "my account"); XmlElement child2 = xml2.addSubElement("identity"); child2.addAttribute("attach_signature", "false"); child2.addAttribute("name", "John Doe"); child2 = xml2.addSubElement("popserver"); child2.addAttribute("login_method", "USER"); child2.addAttribute("port", "25"); child2 = xml2.addSubElement("specialfolders"); child2.addAttribute("sent", "104"); child2.addAttribute("inbox", "101"); AccountItem item2 = new AccountItem(xml2); // third item, a bit different from the first XmlElement xml3 = new XmlElement("account"); xml3.addAttribute("name", "my account"); xml3.addAttribute("uid", "0"); XmlElement child3 = xml3.addSubElement("identity"); child3.addAttribute("name", "Kalle Kamel"); child3.addAttribute("attach_signature", "false"); child3 = xml3.addSubElement("popserver"); child3.addAttribute("port", "25"); child3.addAttribute("login_method", "USER"); child3 = xml3.addSubElement("specialfolders"); child3.addAttribute("inbox", "101"); child3.addAttribute("sent", "104"); AccountItem item3 = new AccountItem(xml3); // test self equality... assertTrue("Self equality failed for item", item.equals(item)); assertTrue("Self equality failed for item2", item2.equals(item2)); // item and item2 should be equal... assertTrue("item and item2 are not equal", item.equals(item2)); assertTrue("item2 and item are not equal", item2.equals(item)); // item and item2 should be two different objects assertNotSame("item and item2 refers to the same object", item, item2); // item should not be equal to a newly created item or null assertFalse("item is equal to a newly created AccountItem", item.equals(new AccountItem(new XmlElement()))); assertFalse("item is equal to null", item.equals(null)); // item and item3 should not be equal assertFalse("item and item3 are equal", item.equals(item3));
XmlElement xml = new XmlElement("account"); xml.addAttribute("name", "my account"); xml.addAttribute("uid", "0"); XmlElement child = xml.addSubElement("identity"); child.addAttribute("name", "John Doe"); child.addAttribute("attach_signature", "false"); child = xml.addSubElement("popserver"); child.addAttribute("port", "25"); child.addAttribute("login_method", "USER"); child = xml.addSubElement("specialfolders"); child.addAttribute("inbox", "101"); child.addAttribute("sent", "104"); AccountItem item = new AccountItem(xml); // second account item XmlElement xml2 = new XmlElement("account"); xml2.addAttribute("uid", "0"); xml2.addAttribute("name", "my account"); XmlElement child2 = xml2.addSubElement("identity"); child2.addAttribute("attach_signature", "false"); child2.addAttribute("name", "John Doe"); child2 = xml2.addSubElement("popserver"); child2.addAttribute("login_method", "USER"); child2.addAttribute("port", "25"); child2 = xml2.addSubElement("specialfolders"); child2.addAttribute("sent", "104"); child2.addAttribute("inbox", "101"); AccountItem item2 = new AccountItem(xml2); // third item, a bit different from the first XmlElement xml3 = new XmlElement("account"); xml3.addAttribute("name", "my account"); xml3.addAttribute("uid", "0"); XmlElement child3 = xml3.addSubElement("identity"); child3.addAttribute("name", "Kalle Kamel"); child3.addAttribute("attach_signature", "false"); child3 = xml3.addSubElement("popserver"); child3.addAttribute("port", "25"); child3.addAttribute("login_method", "USER"); child3 = xml3.addSubElement("specialfolders"); child3.addAttribute("inbox", "101"); child3.addAttribute("sent", "104"); AccountItem item3 = new AccountItem(xml3); // should have the same hashcodes... assertTrue("The hashcodes of item and item2 are not the same", item.hashCode() == item2.hashCode()); // expect a different hashcode from a newly created item... assertFalse("The hashcodes of item and a new object are the same", item.hashCode() == (new AccountItem(new XmlElement())).hashCode()); // expect a different hashcode for item and item3 assertFalse("The hashcodes of item and item3 are the same", item.hashCode() == item3.hashCode());
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/mail/src/test/java/org/columba/mail/config/AccountItemTest.java File path: /columba-1.4-src/mail/src/test/java/org/columba/mail/config/AccountItemTest.java
Method name: void testEqualsObject() Method name: void testHashCode()
Number of AST nodes: 47 Number of AST nodes: 42
1
XmlElement xml = new XmlElement("account");
1
XmlElement xml = new XmlElement("account");
2
        xml.addAttribute("name", "my account");
2
        xml.addAttribute("name", "my account");
3
        xml.addAttribute("uid", "0");
3
        xml.addAttribute("uid", "0");
4
        XmlElement child = xml.addSubElement("identity");
4
        XmlElement child = xml.addSubElement("identity");
5
        child.addAttribute("name", "John Doe");
5
        child.addAttribute("name", "John Doe");
6
        child.addAttribute("attach_signature", "false");
6
        child.addAttribute("attach_signature", "false");
7
        child = xml.addSubElement("popserver");
7
        child = xml.addSubElement("popserver");
8
        child.addAttribute("port", "25");
8
        child.addAttribute("port", "25");
9
        child.addAttribute("login_method", "USER");
9
        child.addAttribute("login_method", "USER");
10
        child = xml.addSubElement("specialfolders");
10
        child = xml.addSubElement("specialfolders");
11
        child.addAttribute("inbox", "101");
11
        child.addAttribute("inbox", "101");
12
        child.addAttribute("sent", "104");
12
        child.addAttribute("sent", "104");
13
        AccountItem item = new AccountItem(xml);
13
        AccountItem item = new AccountItem(xml);
14
        // second account item
14
        // second account item
15
        XmlElement xml2 = new XmlElement("account");
15
        XmlElement xml2 = new XmlElement("account");
16
        xml2.addAttribute("uid", "0");
16
        xml2.addAttribute("uid", "0");
17
        xml2.addAttribute("name", "my account");
17
        xml2.addAttribute("name", "my account");
18
        XmlElement child2 = xml2.addSubElement("identity");
18
        XmlElement child2 = xml2.addSubElement("identity");
19
        child2.addAttribute("attach_signature", "false");
19
        child2.addAttribute("attach_signature", "false");
20
        child2.addAttribute("name", "John Doe");
20
        child2.addAttribute("name", "John Doe");
21
        child2 = xml2.addSubElement("popserver");
21
        child2 = xml2.addSubElement("popserver");
22
        child2.addAttribute("login_method", "USER");
22
        child2.addAttribute("login_method", "USER");
23
        child2.addAttribute("port", "25");
23
        child2.addAttribute("port", "25");
24
        child2 = xml2.addSubElement("specialfolders");
24
        child2 = xml2.addSubElement("specialfolders");
25
        child2.addAttribute("sent", "104");
25
        child2.addAttribute("sent", "104");
26
        child2.addAttribute("inbox", "101");
26
        child2.addAttribute("inbox", "101");
27
        AccountItem item2 = new AccountItem(xml2);
27
        AccountItem item2 = new AccountItem(xml2);
28
        // third item, a bit different from the first
28
        // third item, a bit different from the first
29
        XmlElement xml3 = new XmlElement("account");
29
        XmlElement xml3 = new XmlElement("account");
30
        xml3.addAttribute("name", "my account");
30
        xml3.addAttribute("name", "my account");
31
        xml3.addAttribute("uid", "0");
31
        xml3.addAttribute("uid", "0");
32
        XmlElement child3 = xml3.addSubElement("identity");
32
        XmlElement child3 = xml3.addSubElement("identity");
33
        child3.addAttribute("name", "Kalle Kamel");
33
        child3.addAttribute("name", "Kalle Kamel");
34
        child3.addAttribute("attach_signature", "false");
34
        child3.addAttribute("attach_signature", "false");
35
        child3 = xml3.addSubElement("popserver");
35
        child3 = xml3.addSubElement("popserver");
36
        child3.addAttribute("port", "25");
36
        child3.addAttribute("port", "25");
37
        child3.addAttribute("login_method", "USER");
37
        child3.addAttribute("login_method", "USER");
38
        child3 = xml3.addSubElement("specialfolders");
38
        child3 = xml3.addSubElement("specialfolders");
39
        child3.addAttribute("inbox", "101");
39
        child3.addAttribute("inbox", "101");
40
        child3.addAttribute("sent", "104");
40
        child3.addAttribute("sent", "104");
41
        AccountItem item3 = new AccountItem(xml3);
41
        AccountItem item3 = new AccountItem(xml3);
42
        // test self equality...
42
        // 
43
        assertTrue("Self equality failed for item", item.equals(item));
44
        assertTrue("Self equality failed for item2", item2.equals(item2));
45
        // item and item2 should be equal...
46
        assertTrue("item and item2 are not equal", item.equals(item2));
47
        assertTrue("item2 and item are not equal", item2.equals(item));
48
        // item and item2 should be two different objects
49
        assertNotSame("item and item2 refers to the same object", item, item2);
50
        // item should not be equal to
43
should have the same hashcodes...
44
        assertTrue("The hashcodes of item and item2 are not the same",
45
            item.hashCode() == item2.hashCode());
51
 a newly created item or null
46
        // expect a different hashcode from a newly created item...
52
        assertFalse("item is equal to a newly created AccountItem",
47
        assertFalse("The hashcodes of item and a new object are the same",
53
            item.equals(new AccountItem(new XmlElement())));
48
            item.hashCode() == (new AccountItem(new XmlElement()))
54
        assertFalse("item is equal to null", item.equals(null));
55
        // item and item3 should not be equal
49
.hashCode());
50
        // expect a different hashcode for item and item3
56
        assertFalse("item and item3 are equal", item.equals(item3
51
        assertFalse("The hashcodes of item and item3 are the same",
57
));
52
            item.hashCode() == item3.hashCode());
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.0
Clones locationClones are declared in the same class
Number of node comparisons825
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements42
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    XmlElement xml = new XmlElement("account");
    1
    XmlElement xml = new XmlElement("account");
    2
    xml.addAttribute("name", "my account");
    2
    xml.addAttribute("name", "my account");
    3
    xml.addAttribute("uid", "0");
    3
    xml.addAttribute("uid", "0");
    4
    XmlElement child = xml.addSubElement("identity");
    4
    XmlElement child = xml.addSubElement("identity");
    5
    child.addAttribute("name", "John Doe");
    5
    child.addAttribute("name", "John Doe");
    6
    child.addAttribute("attach_signature", "false");
    6
    child.addAttribute("attach_signature", "false");
    7
    child = xml.addSubElement("popserver");
    7
    child = xml.addSubElement("popserver");
    8
    child.addAttribute("port", "25");
    8
    child.addAttribute("port", "25");
    9
    child.addAttribute("login_method", "USER");
    9
    child.addAttribute("login_method", "USER");
    10
    child = xml.addSubElement("specialfolders");
    10
    child = xml.addSubElement("specialfolders");
    11
    child.addAttribute("inbox", "101");
    11
    child.addAttribute("inbox", "101");
    12
    child.addAttribute("sent", "104");
    12
    child.addAttribute("sent", "104");
    13
    AccountItem item = new AccountItem(xml);
    13
    AccountItem item = new AccountItem(xml);
    14
    XmlElement xml2 = new XmlElement("account");
    14
    XmlElement xml2 = new XmlElement("account");
    15
    xml2.addAttribute("uid", "0");
    15
    xml2.addAttribute("uid", "0");
    16
    xml2.addAttribute("name", "my account");
    16
    xml2.addAttribute("name", "my account");
    17
    XmlElement child2 = xml2.addSubElement("identity");
    17
    XmlElement child2 = xml2.addSubElement("identity");
    18
    child2.addAttribute("attach_signature", "false");
    18
    child2.addAttribute("attach_signature", "false");
    19
    child2.addAttribute("name", "John Doe");
    19
    child2.addAttribute("name", "John Doe");
    20
    child2 = xml2.addSubElement("popserver");
    20
    child2 = xml2.addSubElement("popserver");
    21
    child2.addAttribute("login_method", "USER");
    21
    child2.addAttribute("login_method", "USER");
    22
    child2.addAttribute("port", "25");
    22
    child2.addAttribute("port", "25");
    23
    child2 = xml2.addSubElement("specialfolders");
    23
    child2 = xml2.addSubElement("specialfolders");
    24
    child2.addAttribute("sent", "104");
    24
    child2.addAttribute("sent", "104");
    25
    child2.addAttribute("inbox", "101");
    25
    child2.addAttribute("inbox", "101");
    26
    AccountItem item2 = new AccountItem(xml2);
    26
    AccountItem item2 = new AccountItem(xml2);
    27
    XmlElement xml3 = new XmlElement("account");
    27
    XmlElement xml3 = new XmlElement("account");
    28
    xml3.addAttribute("name", "my account");
    28
    xml3.addAttribute("name", "my account");
    29
    xml3.addAttribute("uid", "0");
    29
    xml3.addAttribute("uid", "0");
    30
    XmlElement child3 = xml3.addSubElement("identity");
    30
    XmlElement child3 = xml3.addSubElement("identity");
    31
    child3.addAttribute("name", "Kalle Kamel");
    31
    child3.addAttribute("name", "Kalle Kamel");
    32
    child3.addAttribute("attach_signature", "false");
    32
    child3.addAttribute("attach_signature", "false");
    33
    child3 = xml3.addSubElement("popserver");
    33
    child3 = xml3.addSubElement("popserver");
    34
    child3.addAttribute("port", "25");
    34
    child3.addAttribute("port", "25");
    35
    child3.addAttribute("login_method", "USER");
    35
    child3.addAttribute("login_method", "USER");
    36
    child3 = xml3.addSubElement("specialfolders");
    36
    child3 = xml3.addSubElement("specialfolders");
    37
    child3.addAttribute("inbox", "101");
    37
    child3.addAttribute("inbox", "101");
    38
    child3.addAttribute("sent", "104");
    38
    child3.addAttribute("sent", "104");
    39
    AccountItem item3 = new AccountItem(xml3);
    39
    AccountItem item3 = new AccountItem(xml3);
    40
    assertTrue("Self equality failed for item", item.equals(item));
    40
    assertTrue("Self equality failed for item", item.equals(item));
    40
    assertTrue("The hashcodes of item and item2 are not the same", item.hashCode() == item2.hashCode());
    Differences
    Expression1Expression2Difference
    "Self equality failed for item""The hashcodes of item and item2 are not the same"LITERAL_VALUE_MISMATCH
    item.equals(item)item.hashCode() == item2.hashCode()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression item.equals(item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.hashCode() == item2.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    40
    assertTrue("The hashcodes of item and item2 are not the same", item.hashCode() == item2.hashCode());
    41
    assertTrue("Self equality failed for item2", item2.equals(item2));
                                                                                                                                              
    42
    assertTrue("item and item2 are not equal", item.equals(item2));
                                                                                                                                        
    43
    assertTrue("item2 and item are not equal", item2.equals(item));
                                                                                                                                        
    44
    assertNotSame("item and item2 refers to the same object", item, item2);
    44
    assertNotSame("item and item2 refers to the same object", item, item2);
    41
    assertFalse("The hashcodes of item and a new object are the same", item.hashCode() == (new AccountItem(new XmlElement())).hashCode());
    Differences
    Expression1Expression2Difference
    assertNotSameassertFalseMETHOD_INVOCATION_NAME_MISMATCH
    assertNotSame("item and item2 refers to the same object",item,item2)assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertNotSame("item and item2 refers to the same object",item,item2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotSame("item and item2 refers to the same object",item,item2) is a void method call, and thus it cannot be parameterized
    Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) is a void method call, and thus it cannot be parameterized
    Expression assertNotSame("item and item2 refers to the same object",item,item2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotSame("item and item2 refers to the same object",item,item2) is a void method call, and thus it cannot be parameterized
    Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) is a void method call, and thus it cannot be parameterized
    41
    assertFalse("The hashcodes of item and a new object are the same", item.hashCode() == (new AccountItem(new XmlElement())).hashCode());
    45
    assertFalse("item is equal to a newly created AccountItem", item.equals(new AccountItem(new XmlElement())));
    45
    assertFalse("item is equal to a newly created AccountItem", item.equals(new AccountItem(new XmlElement())));
    42
    assertFalse("The hashcodes of item and item3 are the same", item.hashCode() == item3.hashCode());
    Differences
    Expression1Expression2Difference
    "item is equal to a newly created AccountItem""The hashcodes of item and item3 are the same"LITERAL_VALUE_MISMATCH
    item.equals(new AccountItem(new XmlElement()))item.hashCode() == item3.hashCode()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression item.equals(new AccountItem(new XmlElement())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.hashCode() == item3.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    42
    assertFalse("The hashcodes of item and item3 are the same", item.hashCode() == item3.hashCode());
    46
    assertFalse("item is equal to null", item.equals(null));
                                                                                                                          
    47
    assertFalse("item and item3 are equal", item.equals(item3));
                                                                                                                                  
    Precondition Violations (13)
    Row Violation
    1Expression item.equals(item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression item.hashCode() == item2.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertNotSame("item and item2 refers to the same object",item,item2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression assertNotSame("item and item2 refers to the same object",item,item2) is a void method call, and thus it cannot be parameterized
    6Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) is a void method call, and thus it cannot be parameterized
    7Expression assertNotSame("item and item2 refers to the same object",item,item2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression assertNotSame("item and item2 refers to the same object",item,item2) is a void method call, and thus it cannot be parameterized
    10Expression assertFalse("The hashcodes of item and a new object are the same",item.hashCode() == (new AccountItem(new XmlElement())).hashCode()) is a void method call, and thus it cannot be parameterized
    11Expression item.equals(new AccountItem(new XmlElement())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression item.hashCode() == item3.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Clone fragment #1 returns variables item2, item, item3 , while Clone fragment #2 returns variables