File path: /jfreechart-1.0.10/tests/org/jfree/chart/labels/junit/MultipleXYSeriesLabelGeneratorTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 11 | Number of AST nodes: 11 | |||
1 | MultipleXYSeriesLabelGenerator g1↵ | |||
2 | = new MultipleXYSeriesLabelGenerator();↵ | |||
3 | MultipleXYSeriesLabelGenerator g↵ | 1 | DialTextAnnotation a1 = new DialTextAnnotation("A1");↵ | |
4 | 2 = null;↵ | 2 | DialTextAnnotation a2 = null;↵ | |
5 | try {↵ | 3 | try {↵ | |
6 | g2 = (MultipleXYSeriesLabelGenerator) g1.clone();↵ | 4 | a2 = (DialTextAnnotation) a1.clone();↵ | |
7 | }↵ | 5 | }↵ | |
8 | catch (CloneNotSupportedException e) {↵ | 6 | catch (CloneNotSupportedException e) {↵ | |
9 | e.printStackTrace();↵ | 7 | e.printStackTrace();↵ | |
10 | }↵ | 8 | }↵ | |
11 | assertTrue(g1 != g2);↵ | 9 | assertTrue(a1 != a2);↵ | |
12 | assertTrue(g1.getClass() == g2.getClass());↵ | 10 | assertTrue(a1.getClass() == a2.getClass());↵ | |
13 | assertTrue(g1.equals(g2));↵ | 11 | assertTrue(a1.equals(a2));↵ | |
12 | ↵ | |||
14 | // check independence↵ | 13 | // check that the listener lists are independent↵ | |
15 | g1.addSeriesLabel(3, "Add3");↵ | 14 | ↵ | |
16 | assertFalse(g1.equals(g2));↵ | 15 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵ | |
17 | g2.addSeriesLabel(3, "Add3");↵ | 16 | a1.addChangeListener(l1);↵ | |
18 | assertTrue(g1.equals(g2↵ | 17 | assertTrue(a1.hasListener(l1));↵ | |
19 | )); | 18 | assertFalse(a2.hasListener(l1)); | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 58 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 37.7 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); |
| 1 | DialTextAnnotation a1 = new DialTextAnnotation("A1"); | ||||||||||||||||||||||||||||
2 | MultipleXYSeriesLabelGenerator g2 = null; |
| 2 | DialTextAnnotation a2 = null; | ||||||||||||||||||||||||||||
3 | try | 3 | try | |||||||||||||||||||||||||||||
4 | g2 = (MultipleXYSeriesLabelGenerator)g1.clone(); |
| 4 | a2 = (DialTextAnnotation)a1.clone(); | ||||||||||||||||||||||||||||
5 | assertTrue(g1 != g2); |
| 5 | assertTrue(a1 != a2); | ||||||||||||||||||||||||||||
6 | assertTrue(g1.getClass() == g2.getClass()); |
| 6 | assertTrue(a1.getClass() == a2.getClass()); | ||||||||||||||||||||||||||||
7 | assertTrue(g1.equals(g2)); |
| 7 | assertTrue(a1.equals(a2)); | ||||||||||||||||||||||||||||
| 8 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); | ||||||||||||||||||||||||||||||
8 | g1.addSeriesLabel(3, "Add3"); |
| 9 | a1.addChangeListener(l1); | ||||||||||||||||||||||||||||
9 | assertFalse(g1.equals(g2)); |
| | |||||||||||||||||||||||||||||
|
| 10 | assertTrue(a1.hasListener(l1)); | |||||||||||||||||||||||||||||
10 | g2.addSeriesLabel(3, "Add3"); |
| | |||||||||||||||||||||||||||||
|
| 11 | assertFalse(a2.hasListener(l1)); | |||||||||||||||||||||||||||||
11 | assertTrue(g1.equals(g2)); |
| |
Row | Violation |
---|---|
1 | Expression new MultipleXYSeriesLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression new MultipleXYSeriesLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression (MultipleXYSeriesLabelGenerator)g1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression g2 cannot be unified with expression a2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
8 | Expression g2 cannot be unified with expression a2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
9 | Expression g1 cannot be unified with expression a1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
10 | Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression a1.addChangeListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized |
13 | Expression a1.addChangeListener(l1) is a void method call, and thus it cannot be parameterized |
14 | Expression g1 cannot be unified with expression a1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addSeriesLabel(int, java.lang.String) , public void addChangeListener(org.jfree.chart.plot.dial.DialLayerChangeListener) |
15 | Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression a1.addChangeListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized |
18 | Expression a1.addChangeListener(l1) is a void method call, and thus it cannot be parameterized |
19 | Unmatched statement assertFalse(g1.equals(g2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Unmatched statement assertTrue(a1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Unmatched statement g2.addSeriesLabel(3,"Add3"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | Unmatched statement assertFalse(a2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | Unmatched statement assertTrue(g1.equals(g2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | Clone fragment #1 returns variables g1, g2 , while Clone fragment #2 returns variables a1, a2 |