385-9-13

Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.MARCH, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Quarter q = new Quarter(1, 2006); assertEquals(cal.getTime(), q.getEnd()); Locale.setDefault(saved);
Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59); cal.set(Calendar.MILLISECOND, 999); Hour h = new Hour(1, 8, 1, 2006); assertEquals(cal.getTime(), h.getEnd()); Locale.setDefault(saved);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/QuarterTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/HourTests.java
Method name: `void testGetEnd()` |  | Method name: `void testGetEnd()`
Number of AST nodes: 8 |  | Number of AST nodes: 8

1

    Locale saved = Locale.getDefault();↵

1

    Locale saved = Locale.getDefault();↵

2

            Locale.setDefault(Locale.ITALY);↵

2

            Locale.setDefault(Locale.ITALY);↵

3

            Calendar cal = Calendar.getInstance(Locale.ITALY);↵

3

            Calendar cal = Calendar.getInstance(Locale.ITALY);↵

4

            cal.set(2006, Calendar.MARCH, 31, 23, 59, 59);↵

4

            cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59);↵

5

            cal.set(Calendar.MILLISECOND, 999);↵

5

            cal.set(Calendar.MILLISECOND, 999);↵

6

            Quarter q = new Quarter(1, 2006);↵

6

            Hour h = new Hour(1, 8, 1, 2006);↵

7

            assertEquals(cal.getTime(), q.getEnd());↵

7

            assertEquals(cal.getTime(), h.getEnd());↵

8

            Locale.setDefault(saved);

8

            Locale.setDefault(saved);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 30

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 0.0
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       Locale saved = Locale.getDefault();

   1

       Locale saved = Locale.getDefault();

   2

       Locale.setDefault(Locale.ITALY);

   2

       Locale.setDefault(Locale.ITALY);

   3

       Calendar cal = Calendar.getInstance(Locale.ITALY);

   3

       Calendar cal = Calendar.getInstance(Locale.ITALY);

   4

       cal.set(2006, Calendar.MARCH, 31, 23, 59, 59);

   4 | cal.set(2006, Calendar.MARCH, 31, 23, 59, 59);
   4 | cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   MARCH | JANUARY | VARIABLE_NAME_MISMATCH
   31 | 8 | LITERAL_VALUE_MISMATCH
   23 | 1 | LITERAL_VALUE_MISMATCH

   4

       cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59);

   5

       cal.set(Calendar.MILLISECOND, 999);

   5

       cal.set(Calendar.MILLISECOND, 999);

   6

       Quarter q = new Quarter(1, 2006);

   6 | Quarter q = new Quarter(1, 2006);
   6 | Hour h = new Hour(1, 8, 1, 2006);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Quarter | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH
   q | h | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Quarter | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.time.Quarter | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH
   new Quarter(1,2006) | new Hour(1,8,1,2006) | ARGUMENT_NUMBER_MISMATCH

   6

       Hour h = new Hour(1, 8, 1, 2006);

   7

       assertEquals(cal.getTime(), q.getEnd());

   7 | assertEquals(cal.getTime(), q.getEnd());
   7 | assertEquals(cal.getTime(), h.getEnd());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   q | h | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Quarter | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH

   7

       assertEquals(cal.getTime(), h.getEnd());

   8

       Locale.setDefault(saved);

   8

       Locale.setDefault(saved);

   Precondition Violations (0)
   Row | Violation
   --- | ---