GenericController controller = new GenericController(); WhileController while_cont = new WhileController(); setLastSampleStatus(false); while_cont.setCondition("${VAR}"); jmvars.put("VAR", ""); ValueReplacer vr = new ValueReplacer(); vr.replaceValues(while_cont); setRunning(while_cont); controller.addTestElement(new TestSampler("before")); controller.addTestElement(while_cont); GenericController simple = new GenericController(); while_cont.addTestElement(simple); simple.addTestElement(new TestSampler("one")); simple.addTestElement(new TestSampler("two")); while_cont.addTestElement(new TestSampler("three")); while_cont.addTestElement(new TestSampler("four")); controller.addTestElement(new TestSampler("after")); controller.initialize(); for (int i = 1; i <= 3; i++) { assertEquals("Loop: "+i,"before", nextName(controller)); assertEquals("Loop: "+i,"one", nextName(controller)); assertEquals("Loop: "+i,"two", nextName(controller)); assertEquals("Loop: "+i,"three", nextName(controller)); assertEquals("Loop: "+i,"four", nextName(controller)); assertEquals("Loop: "+i,"after", nextName(controller)); assertNull("Loop: "+i,nextName(controller)); } jmvars.put("VAR", "LAST"); // Should not enter the loop for (int i = 1; i <= 3; i++) { assertEquals("Loop: "+i,"before", nextName(controller)); assertEquals("Loop: "+i,"after", nextName(controller)); assertNull("Loop: "+i,nextName(controller)); } jmvars.put("VAR", ""); for (int i = 1; i <= 3; i++) { assertEquals("Loop: "+i,"before", nextName(controller)); if (i==1){ assertEquals("Loop: "+i,"one", nextName(controller)); assertEquals("Loop: "+i,"two", nextName(controller)); jmvars.put("VAR", "LAST"); // Should not enter the loop next time // But should continue to the end of the loop assertEquals("Loop: "+i,"three", nextName(controller)); assertEquals("Loop: "+i,"four", nextName(controller)); } assertEquals("Loop: "+i,"after", nextName(controller)); assertNull("Loop: "+i,nextName(controller)); }
GenericController controller = new GenericController(); WhileController while_cont = new WhileController(); setLastSampleStatus(false); while_cont.setCondition("${VAR}"); jmvars.put("VAR", ""); ValueReplacer vr = new ValueReplacer(); vr.replaceValues(while_cont); setRunning(while_cont); controller.addTestElement(new TestSampler("before")); controller.addTestElement(while_cont); while_cont.addTestElement(new TestSampler("one")); while_cont.addTestElement(new TestSampler("two")); GenericController simple = new GenericController(); while_cont.addTestElement(simple); simple.addTestElement(new TestSampler("three")); simple.addTestElement(new TestSampler("four")); controller.addTestElement(new TestSampler("after")); controller.initialize(); for (int i = 1; i <= 3; i++) { assertEquals("Loop: "+i,"before", nextName(controller)); assertEquals("Loop: "+i,"one", nextName(controller)); assertEquals("Loop: "+i,"two", nextName(controller)); assertEquals("Loop: "+i,"three", nextName(controller)); assertEquals("Loop: "+i,"four", nextName(controller)); assertEquals("Loop: "+i,"after", nextName(controller)); assertNull("Loop: "+i,nextName(controller)); } jmvars.put("VAR", "LAST"); // Should not enter the loop for (int i = 1; i <= 3; i++) { assertEquals("Loop: "+i,"before", nextName(controller)); assertEquals("Loop: "+i,"after", nextName(controller)); assertNull("Loop: "+i,nextName(controller)); } jmvars.put("VAR", ""); for (int i = 1; i <= 3; i++) { assertEquals("Loop: "+i,"before", nextName(controller)); if (i==1) { assertEquals("Loop: "+i,"one", nextName(controller)); assertEquals("Loop: "+i,"two", nextName(controller)); assertEquals("Loop: "+i,"three", nextName(controller)); jmvars.put("VAR", "LAST"); // Should not enter the loop next time assertEquals("Loop: "+i,"four", nextName(controller)); } assertEquals("Loop: "+i,"after", nextName(controller)); assertNull("Loop: "+i,nextName(controller)); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/control/TestWhileController.java File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/control/TestWhileController.java
Method name: void testVariable2() Method name: void testVariable1()
Number of AST nodes: 42 Number of AST nodes: 42
1
GenericController controller = new GenericController();
1
GenericController controller = new GenericController();
2
			WhileController while_cont = new WhileController();
2
			WhileController while_cont = new WhileController();
3
			setLastSampleStatus(false);
3
			setLastSampleStatus(false);
4
			while_cont.setCondition("${VAR}");
4
			while_cont.setCondition("${VAR}");
5
			jmvars.put("VAR", "");
5
			jmvars.put("VAR", "");
6
			ValueReplacer vr = new ValueReplacer();
6
			ValueReplacer vr = new ValueReplacer();
7
			vr.replaceValues(while_cont);
7
			vr.replaceValues(while_cont);
8
			setRunning(while_cont);
8
			setRunning(while_cont);
9
			controller.addTestElement(new TestSampler("before"));
9
			controller.addTestElement(new TestSampler("before"));
10
			controller.addTestElement(while_cont);
10
			controller.addTestElement(while_cont);
11
			
11
			while_cont.addTestElement(new TestSampler("one"));
12
			while_cont.addTestElement(new TestSampler("two"));
12
GenericController simple = new GenericController();
13
			GenericController simple = new GenericController();
13
			while_cont.addTestElement(simple);
14
			while_cont.addTestElement(simple);
14
			simple.addTestElement(new TestSampler("one"));
15
			simple.addTestElement(new 
15
			simple.addTestElement(new TestSampler("two"));
16
			while_cont.addTestElement(new TestSampler("three"));
16
TestSampler("three"));
17
			while_cont.addTestElement(new TestSampler("four"));
17
			simple.addTestElement(new TestSampler("four"));
18
			controller.addTestElement(new TestSampler("after"));
18
			controller.addTestElement(new TestSampler("after"));
19
			controller.initialize();
19
			controller.initialize();
20
			for (int i = 1; i <= 3; i++) {
20
			for (int i = 1; i <= 3; i++) {
21
				assertEquals("Loop: "+i,"before", nextName(controller));
21
				assertEquals("Loop: "+i,"before", nextName(controller));
22
				assertEquals("Loop: "+i,"one", nextName(controller));
22
				assertEquals("Loop: "+i,"one", nextName(controller));
23
				assertEquals("Loop: "+i,"two", nextName(controller));
23
				assertEquals("Loop: "+i,"two", nextName(controller));
24
				assertEquals("Loop: "+i,"three", nextName(controller));
24
				assertEquals("Loop: "+i,"three", nextName(controller));
25
				assertEquals("Loop: "+i,"four", nextName(controller));
25
				assertEquals("Loop: "+i,"four", nextName(controller));
26
				assertEquals("Loop: "+i,"after", nextName(controller));
26
				assertEquals("Loop: "+i,"after", nextName(controller));
27
				assertNull("Loop: "+i,nextName(controller));
27
				assertNull("Loop: "+i,nextName(controller));
28
			}
28
			}
29
			jmvars.put("VAR", "LAST"); // Should not enter the loop
29
			jmvars.put("VAR", "LAST"); // Should not enter the loop
30
			for (int i = 1; i <= 3; i++) {
30
			for (int i = 1; i <= 3; i++) {
31
				assertEquals("Loop: "+i,"before", nextName(controller));
31
				assertEquals("Loop: "+i,"before", nextName(controller));
32
				assertEquals("Loop: "+i,"after", nextName(controller));
32
				assertEquals("Loop: "+i,"after", nextName(controller));
33
				assertNull("Loop: "+i,nextName(controller));
33
				assertNull("Loop: "+i,nextName(controller));
34
			}
34
			}
35
			jmvars.put("VAR", "");
35
			jmvars.put("VAR", "");
36
			for (int i = 1; i <= 3; i++) {
36
			for (int i = 1; i <= 3; i++) {
37
				assertEquals("Loop: "+i,"before", nextName(controller));
37
				assertEquals("Loop: "+i,"before", nextName(controller));
38
				if (i==1){
38
				if (i==1) {
39
					assertEquals("Loop: "+i,"one", nextName(controller));
39
					assertEquals("Loop: "+i,"one", nextName(controller));
40
					assertEquals("Loop: "+i,"two", nextName(controller));
40
					assertEquals("Loop: "+i,"two", nextName(controller));
41
					
41
					assertEquals("Loop: "+i,"three", nextName(controller));
42
jmvars.put("VAR", "LAST"); // Should not enter the loop next time
42
					jmvars.put("VAR", "LAST"); // Should not enter the loop next time
43
					// But should continue to the end of the loop
43
					
44
					assertEquals("Loop: "+i,"three", nextName(controller));
45
					assertEquals("Loop: "+i,"four", nextName(controller));
44
assertEquals("Loop: "+i,"four", nextName(controller));
46
				}
45
				}
47
				assertEquals("Loop: "+i,"after", nextName(controller));
46
				assertEquals("Loop: "+i,"after", nextName(controller));
48
				assertNull("Loop: "+i,nextName(controller));
47
				assertNull("Loop: "+i,nextName(controller));
49
			}
48
			}
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.7
Clones locationClones are declared in the same class
Number of node comparisons330
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements42
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3112.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    GenericController controller = new GenericController();
    1
    GenericController controller = new GenericController();
    2
    WhileController while_cont = new WhileController();
    2
    WhileController while_cont = new WhileController();
    3
    setLastSampleStatus(false);
    3
    setLastSampleStatus(false);
    4
    while_cont.setCondition("${VAR}");
    4
    while_cont.setCondition("${VAR}");
    5
    jmvars.put("VAR", "");
    5
    jmvars.put("VAR", "");
    6
    ValueReplacer vr = new ValueReplacer();
    6
    ValueReplacer vr = new ValueReplacer();
    7
    vr.replaceValues(while_cont);
    7
    vr.replaceValues(while_cont);
    8
    setRunning(while_cont);
    8
    setRunning(while_cont);
    9
    controller.addTestElement(new TestSampler("before"));
    9
    controller.addTestElement(new TestSampler("before"));
    10
    controller.addTestElement(while_cont);
    10
    controller.addTestElement(while_cont);
    11
    GenericController simple = new GenericController();
    13
    GenericController simple = new GenericController();
    12
    while_cont.addTestElement(simple);
    12
    while_cont.addTestElement(simple);
    11
    while_cont.addTestElement(new TestSampler("one"));
    Differences
    Expression1Expression2Difference
    simplenew TestSampler("one")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression simple cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    while_cont.addTestElement(new TestSampler("one"));
    13
    simple.addTestElement(new TestSampler("one"));
    13
    simple.addTestElement(new TestSampler("one"));
    15
    simple.addTestElement(new TestSampler("three"));
    Differences
    Expression1Expression2Difference
    "one""three"LITERAL_VALUE_MISMATCH
    15
    simple.addTestElement(new TestSampler("three"));
    14
    simple.addTestElement(new TestSampler("two"));
    14
    simple.addTestElement(new TestSampler("two"));
    16
    simple.addTestElement(new TestSampler("four"));
    Differences
    Expression1Expression2Difference
    "two""four"LITERAL_VALUE_MISMATCH
    16
    simple.addTestElement(new TestSampler("four"));
    15
    while_cont.addTestElement(new TestSampler("three"));
    15
    while_cont.addTestElement(new TestSampler("three"));
    12
    while_cont.addTestElement(new TestSampler("two"));
    Differences
    Expression1Expression2Difference
    "three""two"LITERAL_VALUE_MISMATCH
    12
    while_cont.addTestElement(new TestSampler("two"));
    16
    while_cont.addTestElement(new TestSampler("four"));
    16
    while_cont.addTestElement(new TestSampler("four"));
    14
    while_cont.addTestElement(simple);
    Differences
    Expression1Expression2Difference
    new TestSampler("four")simpleTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression simple cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    while_cont.addTestElement(simple);
    17
    controller.addTestElement(new TestSampler("after"));
    17
    controller.addTestElement(new TestSampler("after"));
    18
    controller.initialize();
    18
    controller.initialize();
    19
    for (int i = 1; i <= 3; i++)
    19
    for (int i = 1; i <= 3; i++)
    20
    assertEquals("Loop: " + i, "before", nextName(controller));
    20
    assertEquals("Loop: " + i, "before", nextName(controller));
    21
    assertEquals("Loop: " + i, "one", nextName(controller));
    21
    assertEquals("Loop: " + i, "one", nextName(controller));
    22
    assertEquals("Loop: " + i, "two", nextName(controller));
    22
    assertEquals("Loop: " + i, "two", nextName(controller));
    23
    assertEquals("Loop: " + i, "three", nextName(controller));
    23
    assertEquals("Loop: " + i, "three", nextName(controller));
    24
    assertEquals("Loop: " + i, "four", nextName(controller));
    24
    assertEquals("Loop: " + i, "four", nextName(controller));
    25
    assertEquals("Loop: " + i, "after", nextName(controller));
    25
    assertEquals("Loop: " + i, "after", nextName(controller));
    26
    assertNull("Loop: " + i, nextName(controller));
    26
    assertNull("Loop: " + i, nextName(controller));
    27
    jmvars.put("VAR", "LAST");
    27
    jmvars.put("VAR", "LAST");
    28
    for (int i = 1; i <= 3; i++)
    28
    for (int i = 1; i <= 3; i++)
    29
    assertEquals("Loop: " + i, "before", nextName(controller));
    29
    assertEquals("Loop: " + i, "before", nextName(controller));
    30
    assertEquals("Loop: " + i, "after", nextName(controller));
    30
    assertEquals("Loop: " + i, "after", nextName(controller));
    31
    assertNull("Loop: " + i, nextName(controller));
    31
    assertNull("Loop: " + i, nextName(controller));
    32
    jmvars.put("VAR", "");
    32
    jmvars.put("VAR", "");
    33
    for (int i = 1; i <= 3; i++)
    33
    for (int i = 1; i <= 3; i++)
    34
    assertEquals("Loop: " + i, "before", nextName(controller));
    34
    assertEquals("Loop: " + i, "before", nextName(controller));
    35
    if (i == 1)
    35
    if (i == 1)
    36
    assertEquals("Loop: " + i, "one", nextName(controller));
    36
    assertEquals("Loop: " + i, "one", nextName(controller));
    37
    assertEquals("Loop: " + i, "two", nextName(controller));
    37
    assertEquals("Loop: " + i, "two", nextName(controller));
    38
    jmvars.put("VAR", "LAST");
    39
    jmvars.put("VAR", "LAST");
    39
    assertEquals("Loop: " + i, "three", nextName(controller));
    38
    assertEquals("Loop: " + i, "three", nextName(controller));
    40
    assertEquals("Loop: " + i, "four", nextName(controller));
    40
    assertEquals("Loop: " + i, "four", nextName(controller));
    41
    assertEquals("Loop: " + i, "after", nextName(controller));
    41
    assertEquals("Loop: " + i, "after", nextName(controller));
    42
    assertNull("Loop: " + i, nextName(controller));
    42
    assertNull("Loop: " + i, nextName(controller));
    Precondition Violations (2)
    Row Violation
    1Expression simple cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression simple cannot be parameterized, because it has dependencies to/from statements that will be extracted