JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel(); JMeterTreeNode myNode = treeModel.getNodeOf(this); Enumeration kids = myNode.children(); while (kids.hasMoreElements()) { JMeterTreeNode subNode = (JMeterTreeNode) kids.nextElement(); if (subNode.isEnabled()) { TestElement testElement = subNode.getTestElement(); if (testElement instanceof SampleListener) { ((SampleListener) testElement).sampleOccurred(event); } } }
JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel(); JMeterTreeNode myNode = treeModel.getNodeOf(this); Enumeration kids = myNode.children(); while (kids.hasMoreElements()) { JMeterTreeNode subNode = (JMeterTreeNode) kids.nextElement(); if (subNode.isEnabled()) { TestElement testElement = subNode.getTestElement(); if (testElement instanceof TestListener) { ((TestListener) testElement).testStarted(); } } }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/proxy/ProxyControl.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
Method name: void notifySampleListeners(SampleEvent) Method name: void notifyTestListenersOfStart()
Number of AST nodes: 9 Number of AST nodes: 9
1
JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
1
JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
2
		JMeterTreeNode myNode = treeModel.getNodeOf(this);
2
		JMeterTreeNode myNode = treeModel.getNodeOf(this);
3
		Enumeration kids = myNode.children();
3
		Enumeration kids = myNode.children();
4
		while (kids.hasMoreElements()) {
4
		while (kids.hasMoreElements()) {
5
			JMeterTreeNode subNode = (JMeterTreeNode) kids.nextElement();
5
			JMeterTreeNode subNode = (JMeterTreeNode) kids.nextElement();
6
			if (subNode.isEnabled()) {
6
			if (subNode.isEnabled()) {
7
				TestElement testElement = subNode.getTestElement();
7
				TestElement testElement = subNode.getTestElement();
8
				if (testElement instanceof SampleListener) {
8
				if (testElement instanceof TestListener) {
9
					((SampleListener) testElement).sampleOccurred(event);
9
					((TestListener) testElement).testStarted();
10
				}
10
				}
11
			}
11
			}
12
		}
12
		}
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 comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
    1
    JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
    2
    JMeterTreeNode myNode = treeModel.getNodeOf(this);
    2
    JMeterTreeNode myNode = treeModel.getNodeOf(this);
    3
    Enumeration kids = myNode.children();
    3
    Enumeration kids = myNode.children();
    4
    while (kids.hasMoreElements())
    4
    while (kids.hasMoreElements())
    5
    JMeterTreeNode subNode = (JMeterTreeNode)kids.nextElement();
    5
    JMeterTreeNode subNode = (JMeterTreeNode)kids.nextElement();
    6
    if (subNode.isEnabled())
    6
    if (subNode.isEnabled())
    7
    TestElement testElement = subNode.getTestElement();
    7
    TestElement testElement = subNode.getTestElement();
    8
    if (testElement instanceof SampleListener)
    8
    if (testElement instanceof SampleListener)
    8
    if (testElement instanceof TestListener)
    Differences
    Expression1Expression2Difference
    org.apache.jmeter.samplers.SampleListenerorg.apache.jmeter.testelement.TestListenerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression testElement instanceof SampleListener cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testElement instanceof TestListener cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.apache.jmeter.samplers.SampleListener does not match with type org.apache.jmeter.testelement.TestListener
    • Make classes org.apache.jmeter.samplers.SampleListener and org.apache.jmeter.testelement.TestListener extend a common superclass
    8
    if (testElement instanceof TestListener)
                                                                                              
    9
    ((TestListener)testElement).testStarted();
    Preondition Violations
    Unmatched statement ((TestListener)testElement).testStarted(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    ((TestListener)testElement).testStarted();
    9
    ((SampleListener)testElement).sampleOccurred(event);
    9
    ((SampleListener)testElement).sampleOccurred(event);
    Preondition Violations
    Unmatched statement ((SampleListener)testElement).sampleOccurred(event); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                  
    Precondition Violations (5)
    Row Violation
    1Expression testElement instanceof SampleListener cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression testElement instanceof TestListener cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type org.apache.jmeter.samplers.SampleListener does not match with type org.apache.jmeter.testelement.TestListener
    4Unmatched statement ((TestListener)testElement).testStarted(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement ((SampleListener)testElement).sampleOccurred(event); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted