build on jdk11 (#1637)

This commit is contained in:
Roland Praml
2019-02-11 22:42:05 +13:00
committed by Rob Bygrave
parent 829dfcb013
commit cb74ef01e0
5 changed files with 40 additions and 15 deletions
@@ -16,13 +16,21 @@ public class ScalarTypeInstantTest {
ScalarTypeInstant type = new ScalarTypeInstant(JsonConfig.DateTime.MILLIS);
private Instant now() {
// in JDK11 Instant.now() returns a nanosecond precise instant.
// as ScalarTypeInstant is only milliSecond precise, tests may fail with
// expected:<2019-02-10T15:39:36.702700200Z> but was:<2019-02-10T15:39:36.702Z>
// if we use Instant.now() - so we use this workaround here.
return Instant.ofEpochMilli(System.currentTimeMillis());
}
@Test
public void testReadData() throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(os);
Instant now = Instant.now();
Instant now = now();
type.writeData(out, now);
type.writeData(out, null);
out.flush();
@@ -41,7 +49,7 @@ public class ScalarTypeInstantTest {
@Test
public void testToJdbcType() throws Exception {
Instant now = Instant.now();
Instant now = now();
Timestamp timestamp = Timestamp.from(now);
Object val1 = type.toJdbcType(now);
Object val2 = type.toJdbcType(timestamp);
@@ -53,7 +61,7 @@ public class ScalarTypeInstantTest {
@Test
public void testToBeanType() throws Exception {
Instant now = Instant.now();
Instant now = now();
Instant val1 = type.toBeanType(now);
Instant val2 = type.toBeanType(Timestamp.from(now));
@@ -64,7 +72,7 @@ public class ScalarTypeInstantTest {
@Test
public void testFormatValue() throws Exception {
Instant now = Instant.now();
Instant now = now();
Timestamp timestamp = Timestamp.from(now);
String formatted = type.formatValue(now);
assertEquals("" + timestamp.getTime(), formatted);
@@ -73,7 +81,7 @@ public class ScalarTypeInstantTest {
@Test
public void testParse_when_epochMillis() throws Exception {
Instant now = Instant.now();
Instant now = now();
Timestamp timestamp = Timestamp.from(now);
Instant val1 = type.parse("" + timestamp.getTime());
assertEquals(now, val1);
@@ -82,7 +90,7 @@ public class ScalarTypeInstantTest {
@Test
public void testParse_when_timestampForm() throws Exception {
Instant now = Instant.now();
Instant now = now();
Timestamp timestamp = Timestamp.from(now);
Instant val1 = type.parse(timestamp.toString());
assertEquals(now, val1);
@@ -91,7 +99,7 @@ public class ScalarTypeInstantTest {
@Test
public void testFormatAndParse() throws Exception {
Instant now = Instant.now();
Instant now = now();
String format = type.format(now);
Instant val1 = type.parse(format);
@@ -107,7 +115,7 @@ public class ScalarTypeInstantTest {
@Test
public void testConvertFromMillis() throws Exception {
Instant now = Instant.now();
Instant now = now();
Instant val = type.convertFromMillis(now.toEpochMilli());
assertEquals(now, val);
}
@@ -116,7 +124,7 @@ public class ScalarTypeInstantTest {
public void testJsonRead() throws Exception {
Instant now = Instant.now();
Instant now = now();
JsonTester<Instant> jsonTester = new JsonTester<>(type);
jsonTester.test(now);
@@ -28,7 +28,7 @@ public class ScalarTypeLocalDateTimeTest {
@Test
public void testConvertToMillis() throws Exception {
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now().withNano(123_000_000); // jdk11 workaround
long asMillis = type.convertToMillis(now);
LocalDateTime fromMillis = type.convertFromMillis(asMillis);
@@ -74,7 +74,7 @@ public class ScalarTypeLocalDateTimeTest {
@Test
public void testJson() throws Exception {
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now().withNano(123_000_000); // jdk11 workaround
JsonTester<LocalDateTime> jsonTester = new JsonTester<>(type);
jsonTester.test(now);
@@ -61,7 +61,7 @@ public class ScalarTypeOffsetDateTimeTest {
@Test
public void testJson() throws Exception {
OffsetDateTime now = OffsetDateTime.now();
OffsetDateTime now = OffsetDateTime.now().withNano(123_000_000); // jdk11 workaround
JsonTester<OffsetDateTime> jsonTester = new JsonTester<>(type);
jsonTester.test(now);
@@ -62,7 +62,7 @@ public class ScalarTypeZonedDateTimeTest {
@Test
public void testJson() throws Exception {
ZonedDateTime now = ZonedDateTime.now();
ZonedDateTime now = ZonedDateTime.now().withNano(123_000_000); // jdk11 workaround
JsonTester<ZonedDateTime> jsonTester = new JsonTester<>(type);
jsonTester.test(now);