File path: /jfreechart-1.0.10/tests/org/jfree/chart/block/junit/ColorBlockTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/LegendTitleTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 14 | Number of AST nodes: 15 | |||
1 | GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,↵ | |||
2 | Color.blue);↵ | 1 | XYPlot plot = new XYPlot();↵ | |
3 | Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);↵ | 2 | Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);↵ | |
4 | ColorBlock b1 = new ColorBlock(gp, ↵ | 3 | LegendTitle t1 = new LegendTitle(plot);↵ | |
5 | 1.0, 2.0↵ | 4 | t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, ↵ | |
6 | );↵ | 5 | 4.0f, Color.yellow));↵ | |
7 | b1.setBounds(bounds1);↵ | 6 | t1.setBounds(bounds1);↵ | |
8 | ColorBlock b2 = null;↵ | 7 | LegendTitle t2 = null;↵ | |
9 | ↵ | |||
10 | try {↵ | 8 | try {↵ | |
11 | b2 = (ColorBlock) b1.clone();↵ | 9 | t2 = (LegendTitle) t1.clone();↵ | |
12 | }↵ | 10 | }↵ | |
13 | catch (CloneNotSupportedException e) {↵ | 11 | catch (CloneNotSupportedException e) {↵ | |
14 | fail(e.toString());↵ | 12 | e.printStackTrace();↵ | |
15 | }↵ | 13 | }↵ | |
16 | assertTrue(b1 != b2);↵ | 14 | assertTrue(t1 != t2);↵ | |
17 | assertTrue(b1.getClass() == b2.getClass());↵ | 15 | assertTrue(t1.getClass() == t2.getClass());↵ | |
18 | assertTrue(b1.equals(b2));↵ | 16 | assertTrue(t1.equals(t2));↵ | |
19 | ↵ | 17 | ↵ | |
20 | // check independence↵ | 18 | // check independence↵ | |
21 | bounds1.setRect(1.0, 2.0, 3.0, 4.0);↵ | 19 | bounds1.setFrame(40.0, 30.0, 20.0, 10.0);↵ | |
22 | assertFalse(b1.equals(b2));↵ | 20 | assertFalse(t1.equals(t2));↵ | |
23 | b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));↵ | 21 | t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0));↵ | |
24 | assertTrue(b1.equals(b2)); | 22 | assertTrue(t1.equals(t2)); | |
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.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 64 |
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 47.1 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | XYPlot plot = new XYPlot(); | ||||||||||||||||||||||||||||
1 | GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); |
| | ||||||||||||||||||||||||||||
2 | Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); | 2 | Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); | ||||||||||||||||||||||||||||
3 | ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); |
| 3 | LegendTitle t1 = new LegendTitle(plot); | |||||||||||||||||||||||||||
|
| 4 | t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); | ||||||||||||||||||||||||||||
4 | b1.setBounds(bounds1); |
| 5 | t1.setBounds(bounds1); | |||||||||||||||||||||||||||
5 | ColorBlock b2 = null; |
| 6 | LegendTitle t2 = null; | |||||||||||||||||||||||||||
6 | try |
| 7 | try | |||||||||||||||||||||||||||
7 | b2 = (ColorBlock)b1.clone(); |
| 8 | t2 = (LegendTitle)t1.clone(); | |||||||||||||||||||||||||||
8 | assertTrue(b1 != b2); |
| 9 | assertTrue(t1 != t2); | |||||||||||||||||||||||||||
9 | assertTrue(b1.getClass() == b2.getClass()); |
| 10 | assertTrue(t1.getClass() == t2.getClass()); | |||||||||||||||||||||||||||
10 | assertTrue(b1.equals(b2)); |
| 11 | assertTrue(t1.equals(t2)); | |||||||||||||||||||||||||||
11 | bounds1.setRect(1.0, 2.0, 3.0, 4.0); |
| 12 | bounds1.setFrame(40.0, 30.0, 20.0, 10.0); | |||||||||||||||||||||||||||
12 | assertFalse(b1.equals(b2)); |
| 13 | assertFalse(t1.equals(t2)); | |||||||||||||||||||||||||||
13 | b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); |
| 14 | t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0)); | |||||||||||||||||||||||||||
14 | assertTrue(b1.equals(b2)); |
| 15 | assertTrue(t1.equals(t2)); |
Row | Violation |
---|---|
1 | Unmatched statement XYPlot plot=new XYPlot(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Expression new ColorBlock(gp,1.0,2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression new LegendTitle(plot) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression new ColorBlock(gp,1.0,2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression new LegendTitle(plot) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement t1.setBackgroundPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized |
11 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
12 | Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized |
15 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
16 | Expression (ColorBlock)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression (LegendTitle)t1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression bounds1.setRect(1.0,2.0,3.0,4.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression bounds1.setFrame(40.0,30.0,20.0,10.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression bounds1.setRect(1.0,2.0,3.0,4.0) is a void method call, and thus it cannot be parameterized |
21 | Expression bounds1.setFrame(40.0,30.0,20.0,10.0) is a void method call, and thus it cannot be parameterized |
22 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables t1 |