if (children[i].getName().equals("property")) { // $NON-NLS-1$ try { JMeterProperty prop = createProperty(children[i], newClass); if (prop!=null) { element.setProperty(prop); } } catch (Exception ex) { log.error("Problem loading property", ex); element.setProperty(children[i].getAttribute("name"), ""); // $NON-NLS-1$ // $NON-NLS-2$ } } else if (children[i].getName().equals("testelement")) { // $NON-NLS-1$ element.setProperty(new TestElementProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ createTestElement(children[i]))); } else if (children[i].getName().equals("collection")) { // $NON-NLS-1$ element.setProperty(new CollectionProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ createCollection(children[i], newClass))); } else if (children[i].getName().equals("map")) { // $NON-NLS-1$ element.setProperty(new MapProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ createMap(children[i],newClass))); }
for (int i = 0; i < items.length; i++) { if (items[i].getName().equals("property")) { // $NON-NLS-1$ JMeterProperty prop = createProperty(items[i], testClass); if (prop!=null) { map.put(prop.getName(), prop); } } else if (items[i].getName().equals("testelement")) { // $NON-NLS-1$ map.put(items[i].getAttribute("name", ""), new TestElementProperty(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ createTestElement(items[i]))); } else if (items[i].getName().equals("collection")) { // $NON-NLS-1$ map.put(items[i].getAttribute("name"), // $NON-NLS-1$ new CollectionProperty(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ createCollection(items[i], testClass))); } else if (items[i].getName().equals("map")) { // $NON-NLS-1$ map.put(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ new MapProperty(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$ createMap(items[i], testClass))); } }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/save/OldSaveService.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/save/OldSaveService.java
Method name: TestElement createTestElement(Configuration) Method name: Map createMap(Configuration, String)
Number of AST nodes: 11 Number of AST nodes: 11
1
if (children
1
for (int i = 0; i < items.length; i++) {
2
[i].getName().equals("property")) { // $NON-NLS-1$
2
			if (items[i].getName().equals("property")) { // $NON-NLS-1$ 
3
				try {
3
				
4
                    JMeterProperty prop = createProperty(children[i], newClass);
4
JMeterProperty prop = createProperty(items[i], testClass);
5
					if (prop!=null) {
5
				if (prop!=null) {
6
					    element.setProperty(prop);
6
				    
7
					}
8
				} catch (Exception ex) {
9
					log.error("Problem loading property", ex);
10
					element.setProperty(children[i].getAttribute("name"), ""); // $NON-NLS-1$ // $NON-NLS-2$
7
map.put(prop.getName(), prop);
11
				}
8
				}
12
			} else if (children[i].getName().equals("testelement")) { // $NON-NLS-1$
9
			} else if (items[i].getName().equals("testelement")) { // $NON-NLS-1$ 
13
				element.setProperty(new TestElementProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
10
				map.put(items[i].getAttribute("name", ""), new TestElementProperty(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
14
						createTestElement(children[i])));
11
						createTestElement(items[i])));
15
			} else if (children[i].getName().equals("collection")) { // $NON-NLS-1$
12
			} else if (items[i].getName().equals("collection")) { // $NON-NLS-1$ 
16
				element.setProperty(
13
				map.put(items[i].getAttribute("name"),  // $NON-NLS-1$ 
17
new CollectionProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
14
						new CollectionProperty(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
18
                        createCollection(children[i], newClass)));
15
						createCollection(items[i], testClass)));
19
			} else if (children[i].getName().equals("map")) { // $NON-NLS-1$
16
			} else if (items[i].getName().equals("map")) { // $NON-NLS-1$ 
20
				element.setProperty(
17
				map.put(items[i].getAttribute("name", ""),  // $NON-NLS-1$ // $NON-NLS-2$
21
new MapProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
18
						new MapProperty(items[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
22
                        createMap(children[i],newClass)));
19
						createMap(items[i], testClass)));
23
			}
20
			}
21
		}
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.2
Clones locationClones are declared in the same class
Number of node comparisons7
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    14
    JMeterProperty prop = createProperty(children[i], newClass);
    14
    JMeterProperty prop = createProperty(children[i], newClass);
    5
    JMeterProperty prop = createProperty(items[i], testClass);
    Differences
    Expression1Expression2Difference
    childrenitemsVARIABLE_NAME_MISMATCH
    newClasstestClassVARIABLE_NAME_MISMATCH
    5
    JMeterProperty prop = createProperty(items[i], testClass);
    15
    if (prop != null)
    6
    if (prop != null)
                                                                    
    7
    map.put(prop.getName(), prop);
    Preondition Violations
    Unmatched statement map.put(prop.getName(),prop); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    map.put(prop.getName(), prop);
    16
    element.setProperty(prop);
    16
    element.setProperty(prop);
    Preondition Violations
    Unmatched statement element.setProperty(prop); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                
    Precondition Violations (2)
    Row Violation
    1Unmatched statement map.put(prop.getName(),prop); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement element.setProperty(prop); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted