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());
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));
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 testHashCode() Method name: void testEqualsObject()
Number of AST nodes: 40 Number of AST nodes: 40
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
        // should have the same hashcodes...
42
        // 
43
        assertTrue("The hashcodes of item and item2 are not the same",
44
            item.hashCode() == item2.hashCode(
43
test self equality...
45
));
44
        assertTrue("Self equality failed for item", item.equals(item));
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 comparisons705
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements40
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    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("The hashcodes of item and item2 are not the same", item.hashCode() == item2.hashCode());
    40
    assertTrue("The hashcodes of item and item2 are not the same", item.hashCode() == item2.hashCode());
    40
    assertTrue("Self equality failed for item", item.equals(item));
    Differences
    Expression1Expression2Difference
    "The hashcodes of item and item2 are not the same""Self equality failed for item"LITERAL_VALUE_MISMATCH
    item.hashCode() == item2.hashCode()item.equals(item)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression item.hashCode() == item2.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.equals(item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    40
    assertTrue("Self equality failed for item", item.equals(item));
    Precondition Violations (3)
    Row Violation
    1Expression item.hashCode() == item2.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression item.equals(item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables item, item3 , while Clone fragment #2 returns variables item2, item, item3