ThroughputController sub_1 = new ThroughputController(); sub_1.setStyle(ThroughputController.BYNUMBER); sub_1.setMaxThroughput(0); sub_1.addTestElement(new TestSampler("one")); sub_1.addTestElement(new TestSampler("two")); LoopController controller = new LoopController(); controller.setLoops(5); controller.addTestElement(new TestSampler("zero")); controller.addTestElement(sub_1); controller.addIterationListener(sub_1); controller.addTestElement(new TestSampler("three")); String[] order = new String[] { "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three", }; int counter = 0; controller.setRunningVersion(true); sub_1.setRunningVersion(true); sub_1.testStarted(); controller.initialize(); for (int i = 0; i < 3; i++) { TestElement sampler = null; while ((sampler = controller.next()) != null) { assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName()); counter++; } assertEquals(counter, order.length); counter = 0; } sub_1.testEnded();
ThroughputController sub_1 = new ThroughputController(); sub_1.setStyle(ThroughputController.BYPERCENT); sub_1.setPercentThroughput(33.33f); sub_1.addTestElement(new TestSampler("one")); sub_1.addTestElement(new TestSampler("two")); LoopController controller = new LoopController(); controller.setLoops(6); controller.addTestElement(new TestSampler("zero")); controller.addTestElement(sub_1); controller.addIterationListener(sub_1); controller.addTestElement(new TestSampler("three")); // Expected results established using the DDA // algorithm (see // http://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/drawline.htm): String[] order = new String[] { "zero", // 0/1 vs. 1/1 -> 0 is // closer to 33.33 "three", "zero", // 0/2 vs. 1/2 -> 50.0 is closer to // 33.33 "one", "two", "three", "zero", // 1/3 vs. 2/3 -> 33.33 is // closer to 33.33 "three", "zero", // 1/4 vs. 2/4 -> 25.0 is closer to // 33.33 "three", "zero", // 1/5 vs. 2/5 -> 40.0 is closer to // 33.33 "one", "two", "three", "zero", // 2/6 vs. 3/6 -> 33.33 is // closer to 33.33 "three", // etc... }; int counter = 0; controller.setRunningVersion(true); sub_1.setRunningVersion(true); sub_1.testStarted(); controller.initialize(); for (int i = 0; i < 3; i++) { TestElement sampler = null; while ((sampler = controller.next()) != null) { assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName()); counter++; } assertEquals(counter, order.length); counter = 0; } sub_1.testEnded();
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/test/src/org/apache/jmeter/control/TestThroughputController.java
Method name: void testByNumberZero() Method name: void testByPercent33()
Number of AST nodes: 25 Number of AST nodes: 25
1
ThroughputController sub_1 = new ThroughputController();
1
ThroughputController sub_1 = new ThroughputController();
2
			sub_1.setStyle(ThroughputController.BYNUMBER);
2
			sub_1.setStyle(ThroughputController.BYPERCENT);
3
			sub_1.setMaxThroughput(0);
3
			sub_1.setPercentThroughput(33.33f);
4
			sub_1.addTestElement(new TestSampler("one"));
4
			sub_1.addTestElement(new TestSampler("one"));
5
			sub_1.addTestElement(new TestSampler("two"));
5
			sub_1.addTestElement(new TestSampler("two"));
6
			LoopController controller = new LoopController();
6
			LoopController controller = new LoopController();
7
			controller.setLoops(5);
7
			controller.setLoops(6);
8
			controller.addTestElement(new TestSampler("zero"));
8
			controller.addTestElement(new TestSampler("zero"));
9
			controller.addTestElement(sub_1);
9
			controller.addTestElement(sub_1);
10
			controller.addIterationListener(sub_1);
10
			controller.addIterationListener(sub_1);
11
			controller.addTestElement(new TestSampler("three"));
11
			controller.addTestElement(new TestSampler("three"));
12
			String[] order = new String[] { "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero",
13
					"three", 
12
			// Expected results established using the DDA
13
			// algorithm (see
14
			// http://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/drawline.htm):
15
			String[] order = new String[] { "zero", // 0/1 vs. 1/1 -> 0 is
16
													// closer to 33.33
17
					"three", "zero", // 0/2 vs. 1/2 -> 50.0 is closer to
18
										// 33.33
19
					"one", "two", "three", "zero", // 1/3 vs. 2/3 -> 33.33 is
20
													// closer to 33.33
21
					"three", "zero", // 1/4 vs. 2/4 -> 25.0 is closer to
22
										// 33.33
23
					"three", "zero", // 1/5 vs. 2/5 -> 40.0 is closer to
24
										// 33.33
25
					"one", "two", "three", "zero", // 2/6 vs. 3/6 -> 33.33 is
26
													// closer to 33.33
27
					"three",
28
			// etc...
14
};
29
			};
15
			int counter = 0;
30
			int counter = 0;
16
			controller.setRunningVersion(true);
31
			controller.setRunningVersion(true);
17
			sub_1.setRunningVersion(true);
32
			sub_1.setRunningVersion(true);
18
			sub_1.testStarted();
33
			sub_1.testStarted();
19
			controller.initialize();
34
			controller.initialize();
20
			for (int i = 0; i < 3; i++) {
35
			for (int i = 0; i < 3; i++) {
21
				TestElement sampler = null;
36
				TestElement sampler = null;
22
				while ((sampler = controller.next()) != null) {
37
				while ((sampler = controller.next()) != null) {
23
					assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());
38
					assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());
24
					counter++;
39
					counter++;
25
				}
40
				}
26
				assertEquals(counter, order.length);
41
				assertEquals(counter, order.length);
27
				counter = 0;
42
				counter = 0;
28
			}
43
			}
29
			sub_1.testEnded();
44
			sub_1.testEnded();
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.3
Clones locationClones are declared in the same class
Number of node comparisons172
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements25
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)35.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    ThroughputController sub_1 = new ThroughputController();
    1
    ThroughputController sub_1 = new ThroughputController();
    2
    sub_1.setStyle(ThroughputController.BYNUMBER);
    2
    sub_1.setStyle(ThroughputController.BYNUMBER);
    2
    sub_1.setStyle(ThroughputController.BYPERCENT);
    Differences
    Expression1Expression2Difference
    BYNUMBERBYPERCENTVARIABLE_NAME_MISMATCH
    2
    sub_1.setStyle(ThroughputController.BYPERCENT);
    3
    sub_1.setMaxThroughput(0);
    3
    sub_1.setMaxThroughput(0);
    3
    sub_1.setPercentThroughput(33.33f);
    Differences
    Expression1Expression2Difference
    setMaxThroughputsetPercentThroughputMETHOD_INVOCATION_NAME_MISMATCH
    033.33fLITERAL_VALUE_MISMATCH
    Preondition Violations
    Expression sub_1.setMaxThroughput(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sub_1.setPercentThroughput(33.33f) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sub_1.setMaxThroughput(0) is a void method call, and thus it cannot be parameterized
    Expression sub_1.setPercentThroughput(33.33f) is a void method call, and thus it cannot be parameterized
    3
    sub_1.setPercentThroughput(33.33f);
    4
    sub_1.addTestElement(new TestSampler("one"));
    4
    sub_1.addTestElement(new TestSampler("one"));
    5
    sub_1.addTestElement(new TestSampler("two"));
    5
    sub_1.addTestElement(new TestSampler("two"));
    6
    LoopController controller = new LoopController();
    6
    LoopController controller = new LoopController();
    7
    controller.setLoops(5);
    7
    controller.setLoops(5);
    7
    controller.setLoops(6);
    Differences
    Expression1Expression2Difference
    56LITERAL_VALUE_MISMATCH
    7
    controller.setLoops(6);
    8
    controller.addTestElement(new TestSampler("zero"));
    8
    controller.addTestElement(new TestSampler("zero"));
    9
    controller.addTestElement(sub_1);
    9
    controller.addTestElement(sub_1);
    10
    controller.addIterationListener(sub_1);
    10
    controller.addIterationListener(sub_1);
    11
    controller.addTestElement(new TestSampler("three"));
    11
    controller.addTestElement(new TestSampler("three"));
    12
    String[] order = new String[] {"zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three"};
    12
    String[] order = new String[] {"zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three"};
    12
    String[] order = new String[] {"zero", "three", "zero", "one", "two", "three", "zero", "three", "zero", "three", "zero", "one", "two", "three", "zero", "three"};
    Differences
    Expression1Expression2Difference
    {"zero","three","zero","three","zero","three","zero","three","zero","three"}{"zero","three","zero","one","two","three","zero","three","zero","three","zero","one","two","three","zero","three"}ARRAY_INITIALIZER_EXPRESSION_NUMBER_MISMATCH
    12
    String[] order = new String[] {"zero", "three", "zero", "one", "two", "three", "zero", "three", "zero", "three", "zero", "one", "two", "three", "zero", "three"};
    13
    int counter = 0;
    13
    int counter = 0;
    14
    controller.setRunningVersion(true);
    14
    controller.setRunningVersion(true);
    15
    sub_1.setRunningVersion(true);
    15
    sub_1.setRunningVersion(true);
    16
    sub_1.testStarted();
    16
    sub_1.testStarted();
    17
    controller.initialize();
    17
    controller.initialize();
    18
    for (int i = 0; i < 3; i++)
    18
    for (int i = 0; i < 3; i++)
    19
    TestElement sampler = null;
    19
    TestElement sampler = null;
    20
    while ((sampler = controller.next()) != null)
    20
    while ((sampler = controller.next()) != null)
    21
    assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());
    21
    assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());
    22
    counter++;
    22
    counter++;
    23
    assertEquals(counter, order.length);
    23
    assertEquals(counter, order.length);
    24
    counter = 0;
    24
    counter = 0;
    25
    sub_1.testEnded();
    25
    sub_1.testEnded();
    Precondition Violations (4)
    Row Violation
    1Expression sub_1.setMaxThroughput(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression sub_1.setPercentThroughput(33.33f) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression sub_1.setMaxThroughput(0) is a void method call, and thus it cannot be parameterized
    4Expression sub_1.setPercentThroughput(33.33f) is a void method call, and thus it cannot be parameterized