From a515a2fb5924b4840e00cec6708442c99421bae4 Mon Sep 17 00:00:00 2001 From: Marcel Pfotenhauer Date: Tue, 25 Aug 2020 15:22:36 +0200 Subject: [PATCH] #135: update to Java 11 --- pom.xml | 5 +++-- .../neodymium/module/StatementBuilder.java | 19 ++++++++++++++++++- .../testclasses/datautils/DataUtilsTests.java | 6 +++--- .../datautils/DataUtilsTestsXml.java | 6 +++--- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 4a6327440..19615381a 100644 --- a/pom.xml +++ b/pom.xml @@ -51,8 +51,8 @@ UTF-8 - 1.8 - 1.8 + 11 + 11 2.22.2 2.13.3 5.7.0 @@ -135,6 +135,7 @@ 8 + false diff --git a/src/main/java/com/xceptance/neodymium/module/StatementBuilder.java b/src/main/java/com/xceptance/neodymium/module/StatementBuilder.java index 035168ced..b162014c6 100644 --- a/src/main/java/com/xceptance/neodymium/module/StatementBuilder.java +++ b/src/main/java/com/xceptance/neodymium/module/StatementBuilder.java @@ -3,6 +3,7 @@ import java.lang.annotation.Annotation; import java.lang.annotation.Repeatable; import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -25,7 +26,7 @@ public static T instantiate(Class clazz) { try { - return clazz.newInstance(); + return clazz.getDeclaredConstructor().newInstance(); } catch (InstantiationException e) { @@ -35,6 +36,22 @@ public static T instantiate(Class clazz) { throw new RuntimeException(e); } + catch (IllegalArgumentException e) + { + throw new RuntimeException(e); + } + catch (InvocationTargetException e) + { + throw new RuntimeException(e); + } + catch (NoSuchMethodException e) + { + throw new RuntimeException(e); + } + catch (SecurityException e) + { + throw new RuntimeException(e); + } } @SuppressWarnings("unchecked") diff --git a/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTests.java b/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTests.java index 9de8d1baf..89f1899a3 100644 --- a/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTests.java +++ b/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTests.java @@ -210,7 +210,7 @@ public void testGetClass() throws Exception Assert.assertEquals("1234567890", testCompound.getClubCardNumber()); Assert.assertEquals(null, testCompound.getNotSet()); Assert.assertEquals(null, testCompound.getNullValue()); - Assert.assertEquals(new Double(12.34), testCompound.getNumberValue()); + Assert.assertEquals(Double.valueOf(12.34), testCompound.getNumberValue()); Assert.assertEquals("containing strange things like spaces and äüø", testCompound.getDescription()); Assert.assertEquals("4111111111111111", testCompound.getCreditCard().getCardNumber()); Assert.assertEquals("123", testCompound.getCreditCard().getCcv()); @@ -235,7 +235,7 @@ public void testGetClass() throws Exception public void testGetByPath() throws Exception { Double numberValue = DataUtils.get("$.numberValue", Double.class); - Assert.assertEquals(new Double(12.34), numberValue); + Assert.assertEquals(Double.valueOf(12.34), numberValue); String description = DataUtils.get("$.description", String.class); Assert.assertEquals("containing strange things like spaces and äüø", description); @@ -276,7 +276,7 @@ public void testGetClassByPath() throws Exception Assert.assertEquals("1234567890", testCompound.getClubCardNumber()); Assert.assertEquals(null, testCompound.getNotSet()); Assert.assertEquals(null, testCompound.getNullValue()); - Assert.assertEquals(new Double(12.34), testCompound.getNumberValue()); + Assert.assertEquals(Double.valueOf(12.34), testCompound.getNumberValue()); Assert.assertEquals("containing strange things like spaces and äüø", testCompound.getDescription()); Assert.assertEquals("4111111111111111", testCompound.getCreditCard().getCardNumber()); Assert.assertEquals("123", testCompound.getCreditCard().getCcv()); diff --git a/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTestsXml.java b/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTestsXml.java index acdd98051..704ce1aa0 100644 --- a/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTestsXml.java +++ b/src/test/java/com/xceptance/neodymium/testclasses/datautils/DataUtilsTestsXml.java @@ -210,7 +210,7 @@ public void testGetClass() throws Exception Assert.assertEquals(null, testCompound.getNotSet()); // our XML parer does not support explicit null value // Assert.assertEquals(null, testCompound.getNullValue()); - Assert.assertEquals(new Double(12.34), testCompound.getNumberValue()); + Assert.assertEquals(Double.valueOf(12.34), testCompound.getNumberValue()); Assert.assertEquals("containing strange things like spaces and äüø", testCompound.getDescription()); Assert.assertEquals("4111111111111111", testCompound.getCreditCard().getCardNumber()); Assert.assertEquals("123", testCompound.getCreditCard().getCcv()); @@ -235,7 +235,7 @@ public void testGetClass() throws Exception public void testGetByPath() throws Exception { Double numberValue = DataUtils.get("$.numberValue", Double.class); - Assert.assertEquals(new Double(12.34), numberValue); + Assert.assertEquals(Double.valueOf(12.34), numberValue); String description = DataUtils.get("$.description", String.class); Assert.assertEquals("containing strange things like spaces and äüø", description); @@ -277,7 +277,7 @@ public void testGetClassByPath() throws Exception Assert.assertEquals(null, testCompound.getNotSet()); // our XML parer does not support explicit null value // Assert.assertEquals(null, testCompound.getNullValue()); - Assert.assertEquals(new Double(12.34), testCompound.getNumberValue()); + Assert.assertEquals(Double.valueOf(12.34), testCompound.getNumberValue()); Assert.assertEquals("containing strange things like spaces and äüø", testCompound.getDescription()); Assert.assertEquals("4111111111111111", testCompound.getCreditCard().getCardNumber()); Assert.assertEquals("123", testCompound.getCreditCard().getCcv());