Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 30, 2024
2 parents ec3ec7b + 776b6e8 commit a4cf95e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ public WrapperWithReadTimestampsAsNanosEnabled() { }

@Test
public void testDeserializationAsFloat01() throws Exception {
assertEquals("The value is not correct.", Instant.ofEpochSecond(0L),
assertEquals(Instant.ofEpochSecond(0L),
READER.readValue("0.000000000"));
}

@Test
public void testDeserializationAsFloat02() throws Exception {
assertEquals("The value is not correct.", Instant.ofEpochSecond(123456789L, 183917322),
assertEquals(Instant.ofEpochSecond(123456789L, 183917322),
READER.readValue("123456789.183917322"));
}

Expand All @@ -109,7 +109,7 @@ public void testDeserializationAsFloat03() throws Exception
Instant date = Instant.now();
Instant value = READER.readValue(
DecimalUtils.toDecimal(date.getEpochSecond(), date.getNano()));
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

/**
Expand Down Expand Up @@ -232,7 +232,7 @@ public void testDeserializationAsInt01Nanoseconds() throws Exception
Instant value = READER
.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.readValue("0");
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -243,7 +243,7 @@ public void testDeserializationAsInt02Nanoseconds() throws Exception
Instant value = READER
.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.readValue(String.valueOf(ts));
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -255,7 +255,7 @@ public void testDeserializationAsInt03Nanoseconds() throws Exception
Instant value = READER
.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.readValue(Long.toString(date.getEpochSecond()));
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -268,7 +268,7 @@ public void testDeserializationAsInt04Nanoseconds() throws Exception
new WrapperWithReadTimestampsAsNanosEnabled(date);
WrapperWithReadTimestampsAsNanosEnabled actual = reader.readValue(
a2q("{'value':" + date.getEpochSecond() + "}"));
assertEquals("The value is not correct.", expected.value, actual.value);
assertEquals(expected.value, actual.value);
}

/*
Expand All @@ -284,7 +284,7 @@ public void testDeserializationAsInt01Milliseconds() throws Exception
Instant value = READER
.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.readValue("0");
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -294,7 +294,7 @@ public void testDeserializationAsInt02Milliseconds() throws Exception
Instant value = READER
.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.readValue("123456789422");
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -306,7 +306,7 @@ public void testDeserializationAsInt03Milliseconds() throws Exception
Instant value = READER
.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.readValue(Long.toString(date.toEpochMilli()));
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -319,7 +319,7 @@ public void testDeserializationAsInt04Milliseconds() throws Exception
new WrapperWithReadTimestampsAsNanosDisabled(date);
WrapperWithReadTimestampsAsNanosDisabled actual = reader.readValue(
a2q("{'value':" + date.toEpochMilli() + "}"));
assertEquals("The value is not correct.", expected.value, actual.value);
assertEquals(expected.value, actual.value);
}

/*
Expand All @@ -333,15 +333,15 @@ public void testDeserializationAsString01() throws Exception
{
Instant date = Instant.ofEpochSecond(0L);
Instant value = READER.readValue('"' + FORMATTER.format(date) + '"');
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
public void testDeserializationAsString02() throws Exception
{
Instant date = Instant.ofEpochSecond(123456789L, 183917322);
Instant value = READER.readValue('"' + FORMATTER.format(date) + '"');
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -350,7 +350,7 @@ public void testDeserializationAsString03() throws Exception
Instant date = Instant.now();

Instant value = READER.readValue('"' + FORMATTER.format(date) + '"');
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

/*
Expand All @@ -370,7 +370,7 @@ public void testDeserializationWithTypeInfo01() throws Exception
"[\"" + Instant.class.getName() + "\",123456789.183917322]", Temporal.class
);
assertTrue("The value should be an Instant.", value instanceof Instant);
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -385,7 +385,7 @@ public void testDeserializationWithTypeInfo02() throws Exception
"[\"" + Instant.class.getName() + "\",123456789]", Temporal.class
);
assertTrue("The value should be an Instant.", value instanceof Instant);
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -401,7 +401,7 @@ public void testDeserializationWithTypeInfo03() throws Exception
);

assertTrue("The value should be an Instant.", value instanceof Instant);
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

@Test
Expand All @@ -415,7 +415,7 @@ public void testDeserializationWithTypeInfo04() throws Exception
"[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class
);
assertTrue("The value should be an Instant.", value instanceof Instant);
assertEquals("The value is not correct.", date, value);
assertEquals(date, value);
}

/*
Expand Down Expand Up @@ -468,23 +468,23 @@ public void testDeserializationFromStringWithZeroZoneOffset01() throws Exception
Instant date = Instant.now();
String json = formatWithZeroZoneOffset(date, "+00:00");
Instant result = READER.readValue(json);
assertEquals("The value is not correct.", date, result);
assertEquals(date, result);
}

@Test
public void testDeserializationFromStringWithZeroZoneOffset02() throws Exception {
Instant date = Instant.now();
String json = formatWithZeroZoneOffset(date, "+0000");
Instant result = READER.readValue(json);
assertEquals("The value is not correct.", date, result);
assertEquals(date, result);
}

@Test
public void testDeserializationFromStringWithZeroZoneOffset03() throws Exception {
Instant date = Instant.now();
String json = formatWithZeroZoneOffset(date, "+00");
Instant result = READER.readValue(json);
assertEquals("The value is not correct.", date, result);
assertEquals(date, result);
}

@Test
Expand All @@ -493,7 +493,7 @@ public void testDeserializationFromStringWithZeroZoneOffset04() throws Exception
Instant date = Instant.now();
String json = formatWithZeroZoneOffset(date, "+00:30");
Instant result = READER.readValue(json);
assertNotEquals("The value is not correct.", date, result);
assertNotEquals(date, result);
}

@Test
Expand All @@ -502,7 +502,7 @@ public void testDeserializationFromStringWithZeroZoneOffset05() throws Exception
Instant date = Instant.now();
String json = formatWithZeroZoneOffset(date, "+01:30");
Instant result = READER.readValue(json);
assertNotEquals("The value is not correct.", date, result);
assertNotEquals(date, result);
}

@Test
Expand All @@ -511,7 +511,7 @@ public void testDeserializationFromStringWithZeroZoneOffset06() throws Exception
Instant date = Instant.now();
String json = formatWithZeroZoneOffset(date, "-00:00");
Instant result = READER.readValue(json);
assertEquals("The value is not correct.", date, result);
assertEquals(date, result);
}

private String formatWithZeroZoneOffset(Instant date, String offset){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public void ZonedDateTime_with_zone_name_can_be_deserialized() throws Exception
assertEquals("2015-07-24T12:23:34.184Z[UTC]", entry.getKey().toString());
}

// 29-Oct-2024, tatu: Following two tests are for Java 8+ only vs Java 9 or later

@Test
public void ZonedDateTime_with_place_name_can_be_deserialized() throws Exception {
assumeFalse(System.getProperty("java.version").startsWith("1.8"));
Expand Down
Loading

0 comments on commit a4cf95e

Please sign in to comment.