TestSuite allTests = new TestSuite(testClass); Set failureExpected = new HashSet(); Enumeration tests = allTests.tests(); while (tests.hasMoreElements()) { Test t = (Test) tests.nextElement(); if (t instanceof TestCase) { String name = ((TestCase) t).getName(); if (name.endsWith("FailureExpected")) failureExpected.add(name); } } TestSuite result = new TestSuite(); tests = allTests.tests(); 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); } } } return result;
TestSuite allTests = new TestSuite(testClass); Set failureExpected = new HashSet(); Enumeration tests = allTests.tests(); while (tests.hasMoreElements()) { Test t = (Test) tests.nextElement(); if (t instanceof TestCase) { String name = ((TestCase) t).getName(); if (name.endsWith("FailureExpected")) failureExpected.add(name); } } TestSuite result = new TestSuite(); tests = allTests.tests(); 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); } } } return result;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestUtil.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: 18 Number of AST nodes: 18
1
TestSuite allTests = new TestSuite(testClass);
1
TestSuite allTests = new TestSuite(testClass);
2
       Set failureExpected = new HashSet();
2
       Set failureExpected = new HashSet();
3
    
4
   Enumeration tests = allTests.tests();
3
	   Enumeration tests = allTests.tests();
5
   
6
    while (tests.hasMoreElements()) {
4
	   while (tests.hasMoreElements()) {
7
   
8
       Test t = (Test) tests.nextElement();
5
	      Test t = (Test) tests.nextElement();
9
    
10
      if (t instanceof TestCase) {
6
	      if (t instanceof TestCase) {
11
    
12
         String name = ((TestCase) t).getName();
7
	         String name = ((TestCase) t).getName();
13
  
14
           if (name.endsWith("FailureExpected"))
8
	         if (name.endsWith("FailureExpected"))
15
  
16
              failureExpected.add(name);
9
	            failureExpected.add(name);
17
 
18
         }       
10
	      }	      
19
       }
20
       
21
    
11
	   }
12
	   
22
   TestSuite result = new TestSuite();
13
	   TestSuite result = new TestSuite();
23
       tests = allTests.tests();
14
       tests = allTests.tests();
24
       while (tests.hasMoreElements()) {
15
       while (tests.hasMoreElements()) {
25
          Test t = (Test) tests.nextElement();
16
          Test t = (Test) tests.nextElement();
26
          if (t instanceof TestCase) {
17
          if (t instanceof TestCase) {
27
             String name = ((TestCase) t).getName();
18
             String name = ((TestCase) t).getName();
28
             if (!failureExpected.contains(name + "FailureExpected")) {
19
             if (!failureExpected.contains(name + "FailureExpected")) {
29
                result.addTest(t);
20
                result.addTest(t);
30
             }
21
             }
31
          }       
22
          }       
32
       }
23
       }
33
       
34
    
24
	   
35
   return result;
25
	   return result;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.6
Clones locationClones are in different classes
Number of node comparisons49
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.4
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    TestSuite allTests = new TestSuite(testClass);
    1
    TestSuite allTests = new TestSuite(testClass);
    2
    Set failureExpected = new HashSet();
    2
    Set failureExpected = new HashSet();
    3
    Enumeration tests = allTests.tests();
    3
    Enumeration tests = allTests.tests();
    4
    while (tests.hasMoreElements())
    4
    while (tests.hasMoreElements())
    5
    Test t = (Test)tests.nextElement();
    5
    Test t = (Test)tests.nextElement();
    6
    if (t instanceof TestCase)
    6
    if (t instanceof TestCase)
    7
    String name = ((TestCase)t).getName();
    7
    String name = ((TestCase)t).getName();
    8
    if (name.endsWith("FailureExpected"))
    8
    if (name.endsWith("FailureExpected"))
    9
    failureExpected.add(name);
    9
    failureExpected.add(name);
    10
    TestSuite result = new TestSuite();
    10
    TestSuite result = new TestSuite();
    11
    tests = allTests.tests();
    11
    tests = allTests.tests();
    12
    while (tests.hasMoreElements())
    12
    while (tests.hasMoreElements())
    13
    Test t = (Test)tests.nextElement();
    13
    Test t = (Test)tests.nextElement();
    14
    if (t instanceof TestCase)
    14
    if (t instanceof TestCase)
    15
    String name = ((TestCase)t).getName();
    15
    String name = ((TestCase)t).getName();
    16
    if (!failureExpected.contains(name + "FailureExpected"))
    16
    if (!failureExpected.contains(name + "FailureExpected"))
    17
    result.addTest(t);
    17
    result.addTest(t);
    18
    return result;
    18
    return result;
    Precondition Violations (0)
    Row Violation