Skip to content

Commit

Permalink
Sort methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
joehni committed Feb 18, 2017
1 parent 602caae commit dcbac9e
Showing 1 changed file with 109 additions and 109 deletions.
218 changes: 109 additions & 109 deletions xstream/src/test/com/thoughtworks/acceptance/Time18TypesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,39 @@
*/
public class Time18TypesTest extends AbstractAcceptanceTest {

public void testDuration() {
assertBothWays(Duration.ofDays(1000), "<duration>PT24000H</duration>");
assertBothWays(Duration.ofHours(50), "<duration>PT50H</duration>");
assertBothWays(Duration.ofMinutes(77), "<duration>PT1H17M</duration>");
assertBothWays(Duration.ofSeconds(55), "<duration>PT55S</duration>");
assertBothWays(Duration.ofMillis(4444), "<duration>PT4.444S</duration>");
assertBothWays(Duration.ofNanos(123456789), "<duration>PT0.123456789S</duration>");
assertBothWays(Duration.ofNanos(100000000), "<duration>PT0.1S</duration>");
assertBothWays(Duration.ofNanos(9), "<duration>PT0.000000009S</duration>");
assertBothWays(Duration.ofNanos(6333123456789L), "<duration>PT1H45M33.123456789S</duration>");
assertBothWays(Duration.ofSeconds(-3), "<duration>PT-3S</duration>");
assertBothWays(Duration.ofSeconds(-30001), "<duration>PT-8H-20M-1S</duration>");
}

public void testDurationWithOldFormat() {
assertEquals(Duration.ofSeconds(7777), xstream.fromXML("" //
+ "<java.time.Duration resolves-to=\"java.time.Ser\">\n" //
+ " <byte>1</byte>\n" //
+ " <long>7777</long>\n" //
+ " <int>0</int>\n" //
+ "</java.time.Duration>"));
}

public void testDurationIsImmutable() {
final Duration[] array = new Duration[2];
array[0] = array[1] = Duration.ofHours(50);
assertBothWays(array, "" //
+ "<duration-array>\n" //
+ " <duration>PT50H</duration>\n" //
+ " <duration>PT50H</duration>\n" //
+ "</duration-array>");
}

public void testInstant() {
assertBothWays(Instant.from(ZonedDateTime.of(2017, 7, 30, 20, 40, 0, 0, ZoneOffset.of("Z"))),
"<instant>2017-07-30T20:40:00Z</instant>");
Expand All @@ -54,11 +87,11 @@ public void testInstant() {

public void testInstantWithOldFormat() {
assertEquals(Instant.parse("2017-02-15T18:49:25Z"), xstream.fromXML("" //
+ "<java.time.ZoneOffset resolves-to=\"java.time.Ser\">\n" //
+ "<java.time.Instant resolves-to=\"java.time.Ser\">\n" //
+ " <byte>2</byte>\n" //
+ " <long>1487184565</long>\n" //
+ " <int>0</int>\n" //
+ "</java.time.ZoneOffset>"));
+ "</java.time.Instant>"));
}

public void testInstantIsImmutable() {
Expand All @@ -71,89 +104,6 @@ public void testInstantIsImmutable() {
+ "</instant-array>");
}

public void testZoneOffest() {
assertBothWays(ZoneOffset.of("Z"), "<zone-id>Z</zone-id>");
assertBothWays(ZoneOffset.ofTotalSeconds(7777), "<zone-id>+02:09:37</zone-id>");
assertBothWays(ZoneId.ofOffset("GMT", ZoneOffset.ofTotalSeconds(7777)), "<zone-id>GMT+02:09:37</zone-id>");
assertBothWays(ZoneId.of("ECT", ZoneId.SHORT_IDS), "<zone-id>Europe/Paris</zone-id>");
assertBothWays(ZoneId.of("CET"), "<zone-id>CET</zone-id>");
}

public void testZoneOffestWithOldFormat() {
assertEquals(ZoneOffset.ofTotalSeconds(7777), xstream.fromXML("" //
+ "<java.time.ZoneOffset resolves-to=\"java.time.Ser\">\n" //
+ " <byte>8</byte>\n" //
+ " <byte>127</byte>\n" //
+ " <int>7777</int>\n" //
+ "</java.time.ZoneOffset>"));
}

public void testZoneOffestIsImmutable() {
final ZoneOffset[] array = new ZoneOffset[2];
array[0] = array[1] = ZoneOffset.of("Z");
assertBothWays(array, "" //
+ "<zone-id-array>\n" //
+ " <zone-id>Z</zone-id>\n" //
+ " <zone-id>Z</zone-id>\n" //
+ "</zone-id-array>");
}

public void testZoneRegion() {
assertBothWays(ZoneId.of("America/Caracas"), "<zone-id>America/Caracas</zone-id>");
assertBothWays(ZoneId.of("Europe/Berlin"), "<zone-id>Europe/Berlin</zone-id>");
}

public void testZoneRegionWithOldFormat() {
assertEquals(ZoneId.of("America/Caracas"), xstream.fromXML("" //
+ "<java.time.ZoneRegion resolves-to=\"java.time.Ser\">\n" //
+ " <byte>7</byte>\n" //
+ " <string>America/Caracas</string>\n" //
+ "</java.time.ZoneRegion>"));
}

public void testZoneRegionIsImmutable() {
final ZoneId[] array = new ZoneId[2];
array[0] = array[1] = ZoneId.of("Europe/Rome");
assertBothWays(array, "" //
+ "<zone-id-array>\n" //
+ " <zone-id>Europe/Rome</zone-id>\n" //
+ " <zone-id>Europe/Rome</zone-id>\n" //
+ "</zone-id-array>");
}

public void testDuration() {
assertBothWays(Duration.ofDays(1000), "<duration>PT24000H</duration>");
assertBothWays(Duration.ofHours(50), "<duration>PT50H</duration>");
assertBothWays(Duration.ofMinutes(77), "<duration>PT1H17M</duration>");
assertBothWays(Duration.ofSeconds(55), "<duration>PT55S</duration>");
assertBothWays(Duration.ofMillis(4444), "<duration>PT4.444S</duration>");
assertBothWays(Duration.ofNanos(123456789), "<duration>PT0.123456789S</duration>");
assertBothWays(Duration.ofNanos(100000000), "<duration>PT0.1S</duration>");
assertBothWays(Duration.ofNanos(9), "<duration>PT0.000000009S</duration>");
assertBothWays(Duration.ofNanos(6333123456789L), "<duration>PT1H45M33.123456789S</duration>");
assertBothWays(Duration.ofSeconds(-3), "<duration>PT-3S</duration>");
assertBothWays(Duration.ofSeconds(-30001), "<duration>PT-8H-20M-1S</duration>");
}

public void testDurationWithOldFormat() {
assertEquals(Duration.ofSeconds(7777), xstream.fromXML("" //
+ "<java.time.Duration resolves-to=\"java.time.Ser\">\n" //
+ " <byte>1</byte>\n" //
+ " <long>7777</long>\n" //
+ " <int>0</int>\n" //
+ "</java.time.Duration>"));
}

public void testDurationIsImmutable() {
final Duration[] array = new Duration[2];
array[0] = array[1] = Duration.ofHours(50);
assertBothWays(array, "" //
+ "<duration-array>\n" //
+ " <duration>PT50H</duration>\n" //
+ " <duration>PT50H</duration>\n" //
+ "</duration-array>");
}

public void testPeriod() {
assertBothWays(Period.ofDays(1000), "<period>P1000D</period>");
assertBothWays(Period.ofWeeks(70), "<period>P490D</period>");
Expand Down Expand Up @@ -272,6 +222,30 @@ public void testLocalTimeIsImmutable() {
+ "</local-time-array>");
}

public void testMonthDay() {
assertBothWays(MonthDay.of(1, 13), "<month-day>--01-13</month-day>");
assertBothWays(MonthDay.of(2, 29), "<month-day>--02-29</month-day>");
}

public void testMonthDayWithOldFormat() {
assertEquals(MonthDay.of(Month.JANUARY, 13), xstream.fromXML("" //
+ "<java.time.MonthDay resolves-to=\"java.time.Ser\">\n" //
+ " <byte>13</byte>\n" //
+ " <byte>1</byte>\n" //
+ " <byte>13</byte>\n" //
+ "</java.time.MonthDay>"));
}

public void testMonthDayIsImmutable() {
final MonthDay array[] = new MonthDay[2];
array[0] = array[1] = MonthDay.of(Month.APRIL, 10);
assertBothWays(array, "" //
+ "<month-day-array>\n"
+ " <month-day>--04-10</month-day>\n" //
+ " <month-day>--04-10</month-day>\n" //
+ "</month-day-array>");
}

public void testOffsetDateTime() {
assertBothWays(OffsetDateTime.of(2017, 7, 30, 20, 40, 0, 0, ZoneOffset.ofHours(0)),
"<offset-date-time>2017-07-30T20:40:00Z</offset-date-time>");
Expand Down Expand Up @@ -359,30 +333,6 @@ public void testOffsetTimeIsImmutable() {
+ "</offset-time-array>");
}

public void testMonthDay() {
assertBothWays(MonthDay.of(1, 13), "<month-day>--01-13</month-day>");
assertBothWays(MonthDay.of(2, 29), "<month-day>--02-29</month-day>");
}

public void testMonthDayWithOldFormat() {
assertEquals(MonthDay.of(Month.JANUARY, 13), xstream.fromXML("" //
+ "<java.time.MonthDay resolves-to=\"java.time.Ser\">\n" //
+ " <byte>13</byte>\n" //
+ " <byte>1</byte>\n" //
+ " <byte>13</byte>\n" //
+ "</java.time.MonthDay>"));
}

public void testMonthDayIsImmutable() {
final MonthDay array[] = new MonthDay[2];
array[0] = array[1] = MonthDay.of(Month.APRIL, 10);
assertBothWays(array, "" //
+ "<month-day-array>\n"
+ " <month-day>--04-10</month-day>\n" //
+ " <month-day>--04-10</month-day>\n" //
+ "</month-day-array>");
}

public void testYear() {
assertBothWays(Year.of(2017), "<year>2017</year>");
assertBothWays(Year.of(0), "<year>0</year>");
Expand Down Expand Up @@ -475,4 +425,54 @@ public void testZonedDateTimeIsImmutable() {
+ " <zoned-date-time>2017-10-30T20:40:15+01:00[Europe/Paris]</zoned-date-time>\n"
+ "</zoned-date-time-array>");
}

public void testZoneOffest() {
assertBothWays(ZoneOffset.of("Z"), "<zone-id>Z</zone-id>");
assertBothWays(ZoneOffset.ofTotalSeconds(7777), "<zone-id>+02:09:37</zone-id>");
assertBothWays(ZoneId.ofOffset("GMT", ZoneOffset.ofTotalSeconds(7777)), "<zone-id>GMT+02:09:37</zone-id>");
assertBothWays(ZoneId.of("ECT", ZoneId.SHORT_IDS), "<zone-id>Europe/Paris</zone-id>");
assertBothWays(ZoneId.of("CET"), "<zone-id>CET</zone-id>");
}

public void testZoneOffestWithOldFormat() {
assertEquals(ZoneOffset.ofTotalSeconds(7777), xstream.fromXML("" //
+ "<java.time.ZoneOffset resolves-to=\"java.time.Ser\">\n" //
+ " <byte>8</byte>\n" //
+ " <byte>127</byte>\n" //
+ " <int>7777</int>\n" //
+ "</java.time.ZoneOffset>"));
}

public void testZoneOffestIsImmutable() {
final ZoneOffset[] array = new ZoneOffset[2];
array[0] = array[1] = ZoneOffset.of("Z");
assertBothWays(array, "" //
+ "<zone-id-array>\n" //
+ " <zone-id>Z</zone-id>\n" //
+ " <zone-id>Z</zone-id>\n" //
+ "</zone-id-array>");
}

public void testZoneRegion() {
assertBothWays(ZoneId.of("America/Caracas"), "<zone-id>America/Caracas</zone-id>");
assertBothWays(ZoneId.of("Europe/Berlin"), "<zone-id>Europe/Berlin</zone-id>");
}

public void testZoneRegionWithOldFormat() {
assertEquals(ZoneId.of("America/Caracas"), xstream.fromXML("" //
+ "<java.time.ZoneRegion resolves-to=\"java.time.Ser\">\n" //
+ " <byte>7</byte>\n" //
+ " <string>America/Caracas</string>\n" //
+ "</java.time.ZoneRegion>"));
}

public void testZoneRegionIsImmutable() {
final ZoneId[] array = new ZoneId[2];
array[0] = array[1] = ZoneId.of("Europe/Rome");
assertBothWays(array, "" //
+ "<zone-id-array>\n" //
+ " <zone-id>Europe/Rome</zone-id>\n" //
+ " <zone-id>Europe/Rome</zone-id>\n" //
+ "</zone-id-array>");
}
}

0 comments on commit dcbac9e

Please sign in to comment.