for (int counter = 0; counter < order.length; counter++) { TestElement sampler = test.next(); assertNotNull(sampler); assertEquals("Counter: " + counter, order[counter], sampler.getName()); }
while (iter.hasNext()) { Object item = iter.next(); add(item); getTree(item).add(newTree.getTree(item)); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/control/TestThroughputController.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jorphan/collections/HashTree.java
Method name: void testByNumber() Method name: void add(HashTree)
Number of AST nodes: 4 Number of AST nodes: 4
1
for (int counter = 0; counter < order.length; counter++) {
2
				TestElement sampler
1
while (iter.hasNext()) {
3
 = test.next();
2
			Object item = iter.next();
4
				assertNotNull(sampler);
3
			a
5
				assertEquals("Counter: " + counter, order[counter], sampler.getName(
4
dd(item);
6
));
5
			getTree(item).add(newTree.getTree(item));
7
			}
6
		}
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.6
Clones locationClones are in different classes
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)928.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    21
    for (int counter = 0; counter < order.length; counter++)
    21
    for (int counter = 0; counter < order.length; counter++)
    2
    while (iter.hasNext())
    Differences
    Expression1Expression2Difference
    counter < order.lengthiter.hasNext()TYPE_COMPATIBLE_REPLACEMENT
    java.lang.String[]java.util.CollectionVARIABLE_TYPE_MISMATCH
    java.lang.String[]java.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable order.length does not match with type java.util.Collection of variable newTree.list()
    • Make classes java.lang.String[] and java.util.Collection extend a common superclass
    Type java.lang.String[] of variable order does not match with type java.util.Collection of variable newTree.list()
    • Make classes java.lang.String[] and java.util.Collection extend a common superclass
    2
    while (iter.hasNext())
                                                          
    3
    Object item = iter.next();
                              
    4
    add(item);
    Preondition Violations
    Unmatched statement add(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    add(item);
                                                                                            
    5
    getTree(item).add(newTree.getTree(item));
    Preondition Violations
    Unmatched statement getTree(item).add(newTree.getTree(item)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    getTree(item).add(newTree.getTree(item));
    22
    TestElement sampler = test.next();
    22
    TestElement sampler = test.next();
    Preondition Violations
    Unmatched statement TestElement sampler=test.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement TestElement sampler=test.next(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                            
    23
    assertNotNull(sampler);
                                                          
    24
    assertEquals("Counter: " + counter, order[counter], sampler.getName());
    24
    assertEquals("Counter: " + counter, order[counter], sampler.getName());
    Preondition Violations
    Unmatched statement assertEquals("Counter: " + counter,order[counter],sampler.getName()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                      
    Precondition Violations (9)
    Row Violation
    1Type int of variable order.length does not match with type java.util.Collection of variable newTree.list()
    2Type java.lang.String[] of variable order does not match with type java.util.Collection of variable newTree.list()
    3Unmatched statement add(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement getTree(item).add(newTree.getTree(item)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement TestElement sampler=test.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement TestElement sampler=test.next(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7Unmatched statement assertEquals("Counter: " + counter,order[counter],sampler.getName()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Clone fragment #1 returns variable counter with type int , while Clone fragment #2 returns variable item with type java.lang.Object
    9The refactoring of the clones is infeasible, because classes org.apache.jmeter.control.TestThroughputController and org.apache.jorphan.collections.HashTree do not have a common superclass