File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialBackgroundTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java | |||
Method name: void testSerialization()
|
Method name: void testSerialization()
|
|||
Number of AST nodes: 24 | Number of AST nodes: 25 | |||
1 | DialBackground b1 = new DialBackground();↵ | 1 | StandardDialScale s1 = new StandardDialScale();↵ | |
2 | DialBackground b2 = null;↵ | 2 | StandardDialScale s2 = null;↵ | |
3 | try {↵ | 3 | try {↵ | |
4 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | 4 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | |
5 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | 5 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | |
6 | out.writeObject(b1);↵ | 6 | out.writeObject(s1);↵ | |
7 | out.close();↵ | 7 | out.close();↵ | |
8 | ObjectInput in = new ObjectInputStream(↵ | 8 | ObjectInput in = new ObjectInputStream(↵ | |
9 | new ByteArrayInputStream(buffer.toByteArray()));↵ | 9 | new ByteArrayInputStream(buffer.toByteArray()));↵ | |
10 | b2 = (DialBackground) in.readObject();↵ | 10 | s2 = (StandardDialScale) in.readObject();↵ | |
11 | in.close();↵ | 11 | in.close();↵ | |
12 | }↵ | 12 | }↵ | |
13 | catch (Exception e) {↵ | 13 | catch (Exception e) {↵ | |
14 | e.printStackTrace();↵ | 14 | e.printStackTrace();↵ | |
15 | }↵ | 15 | }↵ | |
16 | assertEquals(b1, b2);↵ | 16 | assertEquals(s1, s2);↵ | |
17 | ↵ | 17 | ↵ | |
18 | // test a customised instance↵ | 18 | // try a customised instance↵ | |
19 | b1 = new DialBackground(↵ | 19 | s1 = new StandardDialScale();↵ | |
20 | );↵ | 20 | s1.setExtent(123.4);↵ | |
21 | b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,↵ | 21 | s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, ↵ | |
22 | Color.green));↵ | 22 | 4.0f, Color.white));↵ | |
23 | b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(↵ | 23 | s1.set↵ | |
24 | GradientPaintTransformType.CENTER_VERTICAL));↵ | 24 | MajorTickStroke(new BasicStroke(2.0f));↵ | |
25 | b2 = null;↵ | 25 | s2 = null;↵ | |
26 | try {↵ | 26 | try {↵ | |
27 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | 27 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | |
28 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | 28 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | |
29 | out.writeObject(b1);↵ | 29 | out.writeObject(s1);↵ | |
30 | out.close();↵ | 30 | out.close();↵ | |
31 | ObjectInput in = new ObjectInputStream(↵ | 31 | ObjectInput in = new ObjectInputStream(↵ | |
32 | new ByteArrayInputStream(buffer.toByteArray()));↵ | 32 | new ByteArrayInputStream(buffer.toByteArray()));↵ | |
33 | b2 = (DialBackground) in.readObject();↵ | 33 | s2 = (StandardDialScale) in.readObject();↵ | |
34 | in.close();↵ | 34 | in.close();↵ | |
35 | }↵ | 35 | }↵ | |
36 | catch (Exception e) {↵ | 36 | catch (Exception e) {↵ | |
37 | e.printStackTrace();↵ | 37 | e.printStackTrace();↵ | |
38 | }↵ | 38 | }↵ | |
39 | assertEquals(b1, b2); | 39 | assertEquals(s1, s2); | |
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.5 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 241 |
Number of mapped statements | 23 |
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) | 68.9 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DialBackground b1 = new DialBackground(); |
| 1 | StandardDialScale s1 = new StandardDialScale(); | ||||||||||||||||||||||||
2 | DialBackground b2 = null; |
| 2 | StandardDialScale s2 = null; | ||||||||||||||||||||||||
3 | try | 3 | try | |||||||||||||||||||||||||
4 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | 4 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | |||||||||||||||||||||||||
5 | ObjectOutput out = new ObjectOutputStream(buffer); | 5 | ObjectOutput out = new ObjectOutputStream(buffer); | |||||||||||||||||||||||||
6 | out.writeObject(b1); |
| 6 | out.writeObject(s1); | ||||||||||||||||||||||||
7 | out.close(); | 7 | out.close(); | |||||||||||||||||||||||||
8 | ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); | 8 | ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); | |||||||||||||||||||||||||
9 | b2 = (DialBackground)in.readObject(); |
| 9 | s2 = (StandardDialScale)in.readObject(); | ||||||||||||||||||||||||
10 | in.close(); | 10 | in.close(); | |||||||||||||||||||||||||
11 | assertEquals(b1, b2); |
| 11 | assertEquals(s1, s2); | ||||||||||||||||||||||||
12 | b1 = new DialBackground(); |
| 12 | s1 = new StandardDialScale(); | ||||||||||||||||||||||||
|
| 13 | s1.setExtent(123.4); | |||||||||||||||||||||||||
13 | b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); |
| 14 | s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); | ||||||||||||||||||||||||
14 | b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); |
| | |||||||||||||||||||||||||
|
| 15 | s1.setMajorTickStroke(new BasicStroke(2.0f)); | |||||||||||||||||||||||||
15 | b2 = null; |
| 16 | s2 = null; | ||||||||||||||||||||||||
16 | try | 17 | try | |||||||||||||||||||||||||
17 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | 18 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | |||||||||||||||||||||||||
18 | ObjectOutput out = new ObjectOutputStream(buffer); | 19 | ObjectOutput out = new ObjectOutputStream(buffer); | |||||||||||||||||||||||||
19 | out.writeObject(b1); |
| 20 | out.writeObject(s1); | ||||||||||||||||||||||||
20 | out.close(); | 21 | out.close(); | |||||||||||||||||||||||||
21 | ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); | 22 | ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); | |||||||||||||||||||||||||
22 | b2 = (DialBackground)in.readObject(); |
| 23 | s2 = (StandardDialScale)in.readObject(); | ||||||||||||||||||||||||
23 | in.close(); | 24 | in.close(); | |||||||||||||||||||||||||
24 | assertEquals(b1, b2); |
| 25 | assertEquals(s1, s2); |
Row | Violation |
---|---|
1 | Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement s1.setExtent(123.4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) is a void method call, and thus it cannot be parameterized |
11 | Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) is a void method call, and thus it cannot be parameterized |
12 | Expression b1 cannot be unified with expression s1 , because common superclass org.jfree.chart.plot.dial.AbstractDialLayer does not declare member(s) public void setPaint(java.awt.Paint) , public void setMajorTickPaint(java.awt.Paint) |
13 | Unmatched statement b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement s1.setMajorTickStroke(new BasicStroke(2.0f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Clone fragment #1 returns variable b1 with type org.jfree.chart.plot.dial.DialBackground , while Clone fragment #2 returns variable s1 with type org.jfree.chart.plot.dial.StandardDialScale |