File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/LegendItemCollectionTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/data/time/ohlc/junit/OHLCSeriesCollectionTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 12 | Number of AST nodes: 12 | |||
1 | LegendItemCollection c1 = new LegendItemCollection();↵ | 1 | OHLCSeriesCollection c1 = new OHLCSeriesCollection();↵ | |
2 | LegendItem item1 = new LegendItem("Item 1"↵ | 2 | OHLCSeries s1 = new OHLCSeries("Series");↵ | |
3 | );↵ | 3 | s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);↵ | |
4 | c1.add(item1);↵ | 4 | c1.addSeries(s1);↵ | |
5 | LegendItemCollection c2 = null;↵ | 5 | OHLCSeriesCollection c2 = null;↵ | |
6 | try {↵ | 6 | try {↵ | |
7 | c2 = (LegendItemCollection) c1.clone();↵ | 7 | c2 = (OHLCSeriesCollection) c1.clone();↵ | |
8 | }↵ | 8 | }↵ | |
9 | catch (CloneNotSupportedException e) {↵ | 9 | catch (CloneNotSupportedException e) {↵ | |
10 | e.printStackTrace();↵ | 10 | e.printStackTrace();↵ | |
11 | }↵ | 11 | }↵ | |
12 | assertTrue(c1 != c2);↵ | 12 | assertTrue(c1 != c2);↵ | |
13 | assertTrue(c1.getClass() == c2.getClass());↵ | 13 | assertTrue(c1.getClass() == c2.getClass());↵ | |
14 | assertTrue(c1.equals(c2));↵ | 14 | assertTrue(c1.equals(c2));↵ | |
15 | ↵ | |||
15 | Rectangle2D item1Shape = (Rectangle2D) item1.getShape();↵ | 16 | ↵ | |
16 | item1Shape.setRect(1.0, 2.0, 3.0, 4.0↵ | 17 | // check independence↵ | |
17 | );↵ | 18 | s1.setDescription("XYZ");↵ | |
18 | assertFalse(c1.equals(c2)); | 19 |
| |
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 | 104 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 7 |
Number of unmapped statements in the second code fragment | 7 |
Time elapsed for statement mapping (ms) | 9.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | OHLCSeriesCollection c1 = new OHLCSeriesCollection(); | ||||||||||||||||
1 | LegendItemCollection c1 = new LegendItemCollection(); |
| | ||||||||||||||||
| 2 | OHLCSeries s1 = new OHLCSeries("Series"); | |||||||||||||||||
2 | LegendItem item1 = new LegendItem("Item 1"); |
| | ||||||||||||||||
|
| 3 | s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); | ||||||||||||||||
3 | c1.add(item1); |
| | ||||||||||||||||
|
| 4 | c1.addSeries(s1); | ||||||||||||||||
4 | LegendItemCollection c2 = null; | | |||||||||||||||||
| 5 | OHLCSeriesCollection c2 = null; | |||||||||||||||||
5 | try | 6 | try | ||||||||||||||||
6 | c2 = (LegendItemCollection)c1.clone(); |
| | ||||||||||||||||
|
| 7 | c2 = (OHLCSeriesCollection)c1.clone(); | ||||||||||||||||
7 | assertTrue(c1 != c2); |
| 8 | assertTrue(c1 != c2); | |||||||||||||||
8 | assertTrue(c1.getClass() == c2.getClass()); |
| 9 | assertTrue(c1.getClass() == c2.getClass()); | |||||||||||||||
9 | assertTrue(c1.equals(c2)); |
| 10 | assertTrue(c1.equals(c2)); | |||||||||||||||
10 | Rectangle2D item1Shape = (Rectangle2D)item1.getShape(); | | |||||||||||||||||
|
| 11 | s1.setDescription("XYZ"); | ||||||||||||||||
11 | item1Shape.setRect(1.0, 2.0, 3.0, 4.0); |
| | ||||||||||||||||
12 | assertFalse(c1.equals(c2)); |
| 12 | assertFalse(c1.equals(c2)); |
Row | Violation |
---|---|
1 | Unmatched statement OHLCSeriesCollection c1=new OHLCSeriesCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement LegendItemCollection c1=new LegendItemCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement LegendItem item1=new LegendItem("Item 1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement s1.add(new Year(2006),1.0,1.1,1.2,1.3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement c1.add(item1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement c1.addSeries(s1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Unmatched statement c2=(LegendItemCollection)c1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
8 | Unmatched statement c2=(OHLCSeriesCollection)c1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
9 | Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1 |
10 | Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2 |
11 | Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1 |
12 | Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2 |
13 | Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2 |
14 | Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1 |
15 | Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
16 | Unmatched statement item1Shape.setRect(1.0,2.0,3.0,4.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
17 | Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2 |
18 | Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1 |