while (i.hasNext()) { JavaSampler sampler = (JavaSampler) i.next(); sampler.releaseJavaClient(); i.remove(); }
for (int counter = 0; counter < order.length; counter++) { TestElement sampler = test.next(); assertNotNull(sampler); assertEquals("Counter: " + counter, order[counter], sampler.getName()); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/java/sampler/JavaSampler.java File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/control/TestThroughputController.java
Method name: void testEnded() Method name: void testByNumber()
Number of AST nodes: 4 Number of AST nodes: 4
1
while (i.hasNext()) {
2
				JavaSampler sampler = (JavaSampler) i.next();
3
				sampler.releaseJavaClient();
4
				i.remov
1
for (int counter = 0; counter < order.length; counter++) {
2
				TestElement sampler = test.next();
3
				assertNotNull(sampler);
5
e();
4
				assertEquals("Counter: " + counter, order[counter], sampler.getName());
6
			}
5
			}
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)1.1
Clones locationClones are in different classes
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)923.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    while (i.hasNext())
    4
    while (i.hasNext())
    21
    for (int counter = 0; counter < order.length; counter++)
    Differences
    Expression1Expression2Difference
    i.hasNext()counter < order.lengthTYPE_COMPATIBLE_REPLACEMENT
    java.util.Setjava.lang.String[]VARIABLE_TYPE_MISMATCH
    java.util.Setjava.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Set of variable allSamplers does not match with type int of variable order.length
    • Make classes java.util.Set and java.lang.String[] extend a common superclass
    Type java.util.Set of variable allSamplers does not match with type java.lang.String[] of variable order
    • Make classes java.util.Set and java.lang.String[] extend a common superclass
    21
    for (int counter = 0; counter < order.length; counter++)
    5
    JavaSampler sampler = (JavaSampler)i.next();
    5
    JavaSampler sampler = (JavaSampler)i.next();
    22
    TestElement sampler = test.next();
    Differences
    Expression1Expression2Difference
    org.apache.jmeter.protocol.java.sampler.JavaSamplerorg.apache.jmeter.testelement.TestElementSUBCLASS_TYPE_MISMATCH
    org.apache.jmeter.protocol.java.sampler.JavaSamplerorg.apache.jmeter.testelement.TestElementSUBCLASS_TYPE_MISMATCH
    org.apache.jmeter.protocol.java.sampler.JavaSamplerorg.apache.jmeter.samplers.SamplerSUBCLASS_TYPE_MISMATCH
    (JavaSampler)i.next()test.next()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (JavaSampler)i.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression test.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22
    TestElement sampler = test.next();
    6
    sampler.releaseJavaClient();
    6
    sampler.releaseJavaClient();
    Preondition Violations
    Unmatched statement sampler.releaseJavaClient(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    7
    i.remove();
                                
                                                          
    23
    assertNotNull(sampler);
    Preondition Violations
    Unmatched statement assertNotNull(sampler); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23
    assertNotNull(sampler);
                                                                                                                                                      
    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
    24
    assertEquals("Counter: " + counter, order[counter], sampler.getName());
    Precondition Violations (9)
    Row Violation
    1Type java.util.Set of variable allSamplers does not match with type int of variable order.length
    2Type java.util.Set of variable allSamplers does not match with type java.lang.String[] of variable order
    3Expression (JavaSampler)i.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression test.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement sampler.releaseJavaClient(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement assertNotNull(sampler); cannot be moved before or after the extracted code, because it has dependencies to/from statements 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 variables sampler , while Clone fragment #2 returns variables sampler, counter
    9The refactoring of the clones is infeasible, because classes org.apache.jmeter.protocol.java.sampler.JavaSampler and org.apache.jmeter.control.TestThroughputController do not have a common superclass