while (tests.hasMoreElements()) { Test t = (Test) tests.nextElement(); if (t instanceof TestCase) { String name = ((TestCase) t).getName(); if (name.endsWith("FailureExpected")) failureExpected.add(name); } }
while (tests.hasMoreElements()) { Test t = (Test) tests.nextElement(); if (t instanceof TestCase) { String name = ((TestCase) t).getName(); if (!failureExpected.contains(name + "FailureExpected")) { result.addTest(t); } } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testing/src/main/java/org/hibernate/junit/UnitTestCase.java File path: /hibernate-distribution-3.3.2.GA/project/testing/src/main/java/org/hibernate/junit/UnitTestCase.java
Method name: TestSuite createFailureExpectedSuite(Class) Method name: TestSuite createFailureExpectedSuite(Class)
Number of AST nodes: 6 Number of AST nodes: 6
1
while (tests.hasMoreElements()) {
1
while (tests.hasMoreElements()) {
2
	      Test t = (Test) tests.nextElement();
2
          Test t = (Test) tests.nextElement();
3
	      if (t instanceof TestCase) {
3
          if (t instanceof TestCase) {
4
	         String name = ((TestCase) t).getName();
4
             String name = ((TestCase) t).getName();
5
	         if (name.endsWith("FailureExpected"))
5
             if (!failureExpected.contains(name + "FailureExpected")) {
6
	            failureExpected.add(name);
6
            
7
	      }	
7
    result.addTest(t);
8
             }
8
      
9
          }       
9
	   }
10
       }
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 in the same method
Number of node comparisons12
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    while (tests.hasMoreElements())
    12
    while (tests.hasMoreElements())
    5
    Test t = (Test)tests.nextElement();
    13
    Test t = (Test)tests.nextElement();
    6
    if (t instanceof TestCase)
    14
    if (t instanceof TestCase)
    7
    String name = ((TestCase)t).getName();
    15
    String name = ((TestCase)t).getName();
    8
    if (name.endsWith("FailureExpected"))
    8
    if (name.endsWith("FailureExpected"))
    16
    if (!failureExpected.contains(name + "FailureExpected"))
    Differences
    Expression1Expression2Difference
    name.endsWith("FailureExpected")!failureExpected.contains(name + "FailureExpected")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression name.endsWith("FailureExpected") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression !failureExpected.contains(name + "FailureExpected") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16
    if (!failureExpected.contains(name + "FailureExpected"))
    9
    failureExpected.add(name);
    9
    failureExpected.add(name);
    Preondition Violations
    Unmatched statement failureExpected.add(name); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                              
                                                
    17
    result.addTest(t);
    Preondition Violations
    Unmatched statement result.addTest(t); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    result.addTest(t);
    Precondition Violations (5)
    Row Violation
    1Expression name.endsWith("FailureExpected") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression !failureExpected.contains(name + "FailureExpected") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement failureExpected.add(name); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement result.addTest(t); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variable name with type java.lang.String , while Clone fragment #2 returns variable t with type junit.framework.Test