File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/PaintMapTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/LegendGraphicTests.java | |||
Method name: void testSerialization2()
|
Method name: void testSerialization()
|
|||
Number of AST nodes: 13 | Number of AST nodes: 13 | |||
1 | PaintMap m1 = new PaintMap();↵ | |||
2 | m1.put("K1", Color.red);↵ | |||
3 | m1.put("K2", new GradientPaint↵ | 1 | Stroke s = new BasicStroke(1.23f);↵ | |
4 | (1.0f, 2.0f, Color.green, 3.0f, 4.0f, ↵ | 2 | LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), ↵ | |
5 | Color.yellow));↵ | |||
6 | PaintMap m↵ | 3 | Color.black);↵ | |
4 | g1.setOutlineStroke(s);↵ | |||
7 | 2 = null;↵ | 5 | LegendGraphic g2 = null;↵ | |
8 | try {↵ | 6 | try {↵ | |
9 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | 7 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | |
10 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | 8 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | |
11 | out.writeObject(m1);↵ | 9 | out.writeObject(g1);↵ | |
12 | out.close();↵ | 10 | out.close();↵ | |
13 | ObjectInput in = new ObjectInputStream(↵ | 11 | ObjectInput in = new ObjectInputStream(↵ | |
14 | new ByteArrayInputStream(↵ | 12 | new ByteArrayInputStream(↵ | |
15 | buffer.toByteArray())↵ | 13 | buffer.toByteArray())↵ | |
16 | );↵ | 14 | );↵ | |
17 | m2 = (PaintMap) in.readObject();↵ | 15 | g2 = (LegendGraphic) in.readObject();↵ | |
18 | in.close();↵ | 16 | in.close();↵ | |
19 | }↵ | 17 | }↵ | |
20 | catch (Exception e) {↵ | 18 | catch (Exception e) {↵ | |
21 | e.printStackTrace();↵ | 19 | System.out.println(e.toString());↵ | |
22 | }↵ | 20 | }↵ | |
23 | assertEquals(m1, m2); | 21 | assertTrue(g1.equals(g2)); | |
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.3 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 89 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 21.2 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Stroke s = new BasicStroke(1.23f); | |||||||||||||||||||||||||||
1 | PaintMap m1 = new PaintMap(); |
| | ||||||||||||||||||||||||||
|
| 2 | LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); | ||||||||||||||||||||||||||
2 | m1.put("K1", Color.red); |
| | ||||||||||||||||||||||||||
|
| 3 | g1.setOutlineStroke(s); | ||||||||||||||||||||||||||
3 | m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); |
| | ||||||||||||||||||||||||||
| 4 | LegendGraphic g2 = null; | |||||||||||||||||||||||||||
4 | PaintMap m2 = null; | | |||||||||||||||||||||||||||
5 | try |
| 5 | try | |||||||||||||||||||||||||
6 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | 6 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | ||||||||||||||||||||||||||
7 | ObjectOutput out = new ObjectOutputStream(buffer); | 7 | ObjectOutput out = new ObjectOutputStream(buffer); | ||||||||||||||||||||||||||
8 | out.writeObject(m1); |
| 8 | out.writeObject(g1); | |||||||||||||||||||||||||
9 | out.close(); | 9 | out.close(); | ||||||||||||||||||||||||||
10 | ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); | 10 | ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); | ||||||||||||||||||||||||||
|
| 11 | g2 = (LegendGraphic)in.readObject(); | ||||||||||||||||||||||||||
11 | m2 = (PaintMap)in.readObject(); |
| | ||||||||||||||||||||||||||
12 | in.close(); | 12 | in.close(); | ||||||||||||||||||||||||||
13 | assertEquals(m1, m2); |
| 13 | assertTrue(g1.equals(g2)); |
Row | Violation |
---|---|
1 | Unmatched statement PaintMap m1=new PaintMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement LegendGraphic g1=new LegendGraphic(new Rectangle2D.Double(1.0,2.0,3.0,4.0),Color.black); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement m1.put("K1",Color.red); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement g1.setOutlineStroke(s); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement m1.put("K2",new GradientPaint(1.0f,2.0f,Color.green,3.0f,4.0f,Color.yellow)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
9 | Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized |
10 | Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
14 | Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized |
15 | Type org.jfree.chart.PaintMap of variable m1 does not match with type org.jfree.chart.title.LegendGraphic of variable g1 |
16 | Unmatched statement g2=(LegendGraphic)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement g2=(LegendGraphic)in.readObject(); 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 |
18 | Unmatched statement m2=(PaintMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement m2=(PaintMap)in.readObject(); 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 |
20 | Expression assertEquals(m1,m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression assertTrue(g1.equals(g2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression assertEquals(m1,m2) is a void method call, and thus it cannot be parameterized |
23 | Expression assertTrue(g1.equals(g2)) is a void method call, and thus it cannot be parameterized |
24 | Expression assertEquals(m1,m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression assertTrue(g1.equals(g2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression assertEquals(m1,m2) is a void method call, and thus it cannot be parameterized |
27 | Expression assertTrue(g1.equals(g2)) is a void method call, and thus it cannot be parameterized |