This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
The following commit(s) were added to refs/heads/master by this push: new 304322a6 Use Assertions.assertInstanceOf() 304322a6 is described below commit 304322a65bbfbcba0720e293faca6e4ae822fa2c Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Sep 1 18:46:39 2024 -0400 Use Assertions.assertInstanceOf() --- .../commons/beanutils2/BeanUtilsBeanTestCase.java | 5 +- .../commons/beanutils2/DynaBeanUtilsTestCase.java | 5 +- .../beanutils2/DynaPropertyUtilsTestCase.java | 71 +++++++++--------- .../commons/beanutils2/MethodUtilsTestCase.java | 19 ++--- .../commons/beanutils2/PropertyUtilsTestCase.java | 83 +++++++++++----------- .../commons/beanutils2/WrapDynaBeanTestCase.java | 2 +- .../locale/LocaleConvertUtilsTestCase.java | 42 +++++------ .../beanutils2/sql/DynaResultSetTestCase.java | 14 ++-- .../commons/beanutils2/sql/DynaRowSetTestCase.java | 14 ++-- 9 files changed, 130 insertions(+), 125 deletions(-) diff --git a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java index 6bd9fc01..af40f674 100644 --- a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java @@ -18,6 +18,7 @@ package org.apache.commons.beanutils2; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -1373,7 +1374,7 @@ public class BeanUtilsBeanTestCase { BeanUtils.setProperty(bean, "stringArray", null); newValue = PropertyUtils.getSimpleProperty(bean, "stringArray"); assertNotNull(newValue, "stringArray is not null"); - assertTrue(newValue instanceof String[], "stringArray of correct type"); + assertInstanceOf(String[].class, newValue, "stringArray of correct type"); assertEquals(1, ((String[]) newValue).length, "stringArray length"); PropertyUtils.setProperty(bean, "stringArray", oldValue); @@ -1382,7 +1383,7 @@ public class BeanUtilsBeanTestCase { BeanUtils.setProperty(bean, "stringArray[2]", null); newValue = PropertyUtils.getSimpleProperty(bean, "stringArray"); assertNotNull(newValue, "stringArray is not null"); - assertTrue(newValue instanceof String[], "stringArray of correct type"); + assertInstanceOf(String[].class, newValue, "stringArray of correct type"); assertEquals(5, ((String[]) newValue).length, "stringArray length"); assertNull(((String[]) newValue)[2], "stringArray[2] is null"); PropertyUtils.setProperty(bean, "stringArray", oldValue); diff --git a/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java index a637d947..823c8ab4 100644 --- a/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java @@ -19,6 +19,7 @@ package org.apache.commons.beanutils2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -1021,7 +1022,7 @@ public class DynaBeanUtilsTestCase { BeanUtils.setProperty(bean, "stringArray", null); newValue = PropertyUtils.getSimpleProperty(bean, "stringArray"); assertNotNull(newValue, "stringArray is not null"); - assertTrue(newValue instanceof String[], "stringArray of correct type"); + assertInstanceOf(String[].class, newValue, "stringArray of correct type"); assertEquals(1, ((String[]) newValue).length, "stringArray length"); PropertyUtils.setProperty(bean, "stringArray", oldValue); @@ -1030,7 +1031,7 @@ public class DynaBeanUtilsTestCase { BeanUtils.setProperty(bean, "stringArray[2]", null); newValue = PropertyUtils.getSimpleProperty(bean, "stringArray"); assertNotNull(newValue, "stringArray is not null"); - assertTrue(newValue instanceof String[], "stringArray of correct type"); + assertInstanceOf(String[].class, newValue, "stringArray of correct type"); assertEquals(5, ((String[]) newValue).length, "stringArray length"); assertNull(((String[]) newValue)[2], "stringArray[2] is null"); PropertyUtils.setProperty(bean, "stringArray", oldValue); diff --git a/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java index f58cfd81..d4ba3de9 100644 --- a/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java @@ -19,6 +19,7 @@ package org.apache.commons.beanutils2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -252,7 +253,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intArray", i); assertNotNull(value, "intArray returned value " + i); - assertTrue(value instanceof Integer, "intArray returned Integer " + i); + assertInstanceOf(Integer.class, value, "intArray returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intArray returned correct " + i); } catch (final Throwable t) { fail("intArray " + i + " threw " + t); @@ -261,7 +262,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intIndexed", i); assertNotNull(value, "intIndexed returned value " + i); - assertTrue(value instanceof Integer, "intIndexed returned Integer " + i); + assertInstanceOf(Integer.class, value, "intIndexed returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intIndexed returned correct " + i); } catch (final Throwable t) { fail("intIndexed " + i + " threw " + t); @@ -270,7 +271,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "listIndexed", i); assertNotNull(value, "listIndexed returned value " + i); - assertTrue(value instanceof String, "list returned String " + i); + assertInstanceOf(String.class, value, "list returned String " + i); assertEquals("String " + i, (String) value, "listIndexed returned correct " + i); } catch (final Throwable t) { fail("listIndexed " + i + " threw " + t); @@ -279,7 +280,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringArray", i); assertNotNull(value, "stringArray returned value " + i); - assertTrue(value instanceof String, "stringArray returned String " + i); + assertInstanceOf(String.class, value, "stringArray returned String " + i); assertEquals("String " + i, (String) value, "stringArray returned correct " + i); } catch (final Throwable t) { fail("stringArray " + i + " threw " + t); @@ -288,7 +289,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", i); assertNotNull(value, "stringIndexed returned value " + i); - assertTrue(value instanceof String, "stringIndexed returned String " + i); + assertInstanceOf(String.class, value, "stringIndexed returned String " + i); assertEquals("String " + i, (String) value, "stringIndexed returned correct " + i); } catch (final Throwable t) { fail("stringIndexed " + i + " threw " + t); @@ -303,7 +304,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intArray[" + i + "]"); assertNotNull(value, "intArray returned value " + i); - assertTrue(value instanceof Integer, "intArray returned Integer " + i); + assertInstanceOf(Integer.class, value, "intArray returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intArray returned correct " + i); } catch (final Throwable t) { fail("intArray " + i + " threw " + t); @@ -312,7 +313,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intIndexed[" + i + "]"); assertNotNull(value, "intIndexed returned value " + i); - assertTrue(value instanceof Integer, "intIndexed returned Integer " + i); + assertInstanceOf(Integer.class, value, "intIndexed returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intIndexed returned correct " + i); } catch (final Throwable t) { fail("intIndexed " + i + " threw " + t); @@ -321,7 +322,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "listIndexed[" + i + "]"); assertNotNull(value, "listIndexed returned value " + i); - assertTrue(value instanceof String, "listIndexed returned String " + i); + assertInstanceOf(String.class, value, "listIndexed returned String " + i); assertEquals("String " + i, (String) value, "listIndexed returned correct " + i); } catch (final Throwable t) { fail("listIndexed " + i + " threw " + t); @@ -330,7 +331,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringArray[" + i + "]"); assertNotNull(value, "stringArray returned value " + i); - assertTrue(value instanceof String, "stringArray returned String " + i); + assertInstanceOf(String.class, value, "stringArray returned String " + i); assertEquals("String " + i, (String) value, "stringArray returned correct " + i); } catch (final Throwable t) { fail("stringArray " + i + " threw " + t); @@ -339,7 +340,7 @@ public class DynaPropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringIndexed[" + i + "]"); assertNotNull(value, "stringIndexed returned value " + i); - assertTrue(value instanceof String, "stringIndexed returned String " + i); + assertInstanceOf(String.class, value, "stringIndexed returned String " + i); assertEquals("String " + i, (String) value, "stringIndexed returned correct " + i); } catch (final Throwable t) { fail("stringIndexed " + i + " threw " + t); @@ -624,7 +625,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.booleanProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Boolean, "Got correct type"); + assertInstanceOf(Boolean.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals(((Boolean) value).booleanValue(), nested.getBooleanProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -648,7 +649,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.doubleProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Double, "Got correct type"); + assertInstanceOf(Double.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals(((Double) value).doubleValue(), nested.getDoubleProperty(), 0.005, "Got correct value"); @@ -673,7 +674,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.floatProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Float, "Got correct type"); + assertInstanceOf(Float.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals(((Float) value).floatValue(), nested.getFloatProperty(), (float) 0.005, "Got correct value"); @@ -698,7 +699,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.intProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Integer, "Got correct type"); + assertInstanceOf(Integer.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals(((Integer) value).intValue(), nested.getIntProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -722,7 +723,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.longProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Long, "Got correct type"); + assertInstanceOf(Long.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals(((Long) value).longValue(), nested.getLongProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -746,7 +747,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.readOnlyProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals((String) value, nested.getReadOnlyProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -770,7 +771,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.shortProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Short, "Got correct type"); + assertInstanceOf(Short.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals(((Short) value).shortValue(), nested.getShortProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -794,7 +795,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.stringProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); final TestBean nested = (TestBean) bean.get("nested"); assertEquals((String) value, nested.getStringProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -848,7 +849,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "booleanProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Boolean, "Got correct type"); + assertInstanceOf(Boolean.class, value, "Got correct type"); assertTrue(((Boolean) value).booleanValue(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -871,7 +872,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "doubleProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Double, "Got correct type"); + assertInstanceOf(Double.class, value, "Got correct type"); assertEquals(((Double) value).doubleValue(), 321.0, 0.005, "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -894,7 +895,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "floatProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Float, "Got correct type"); + assertInstanceOf(Float.class, value, "Got correct type"); assertEquals(((Float) value).floatValue(), (float) 123.0, (float) 0.005, "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -938,7 +939,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "intProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Integer, "Got correct type"); + assertInstanceOf(Integer.class, value, "Got correct type"); assertEquals(((Integer) value).intValue(), 123, "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -961,7 +962,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "longProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Long, "Got correct type"); + assertInstanceOf(Long.class, value, "Got correct type"); assertEquals(((Long) value).longValue(), 321, "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1005,7 +1006,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "shortProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Short, "Got correct type"); + assertInstanceOf(Short.class, value, "Got correct type"); assertEquals(((Short) value).shortValue(), (short) 987, "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1028,7 +1029,7 @@ public class DynaPropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "stringProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); assertEquals((String) value, "This is a string", "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1100,7 +1101,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intArray", 0, Integer.valueOf(1)); value = PropertyUtils.getIndexedProperty(bean, "intArray", 0); assertNotNull(value, "Returned new value 0"); - assertTrue(value instanceof Integer, "Returned Integer new value 0"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 0"); assertEquals(1, ((Integer) value).intValue(), "Returned correct new value 0"); } catch (final Throwable t) { fail("Threw " + t); @@ -1110,7 +1111,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intIndexed", 1, Integer.valueOf(11)); value = PropertyUtils.getIndexedProperty(bean, "intIndexed", 1); assertNotNull(value, "Returned new value 1"); - assertTrue(value instanceof Integer, "Returned Integer new value 1"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 1"); assertEquals(11, ((Integer) value).intValue(), "Returned correct new value 1"); } catch (final Throwable t) { fail("Threw " + t); @@ -1120,7 +1121,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "listIndexed", 2, "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "listIndexed", 2); assertNotNull(value, "Returned new value 2"); - assertTrue(value instanceof String, "Returned String new value 2"); + assertInstanceOf(String.class, value, "Returned String new value 2"); assertEquals("New Value 2", (String) value, "Returned correct new value 2"); } catch (final Throwable t) { fail("Threw " + t); @@ -1130,7 +1131,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray", 2, "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "stringArray", 2); assertNotNull(value, "Returned new value 2"); - assertTrue(value instanceof String, "Returned String new value 2"); + assertInstanceOf(String.class, value, "Returned String new value 2"); assertEquals("New Value 2", (String) value, "Returned correct new value 2"); } catch (final Throwable t) { fail("Threw " + t); @@ -1140,7 +1141,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray", 3, "New Value 3"); value = PropertyUtils.getIndexedProperty(bean, "stringArray", 3); assertNotNull(value, "Returned new value 3"); - assertTrue(value instanceof String, "Returned String new value 3"); + assertInstanceOf(String.class, value, "Returned String new value 3"); assertEquals("New Value 3", (String) value, "Returned correct new value 3"); } catch (final Throwable t) { fail("Threw " + t); @@ -1152,7 +1153,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intArray[4]", Integer.valueOf(1)); value = PropertyUtils.getIndexedProperty(bean, "intArray[4]"); assertNotNull(value, "Returned new value 4"); - assertTrue(value instanceof Integer, "Returned Integer new value 4"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 4"); assertEquals(1, ((Integer) value).intValue(), "Returned correct new value 4"); } catch (final Throwable t) { fail("Threw " + t); @@ -1162,7 +1163,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intIndexed[3]", Integer.valueOf(11)); value = PropertyUtils.getIndexedProperty(bean, "intIndexed[3]"); assertNotNull(value, "Returned new value 5"); - assertTrue(value instanceof Integer, "Returned Integer new value 5"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 5"); assertEquals(11, ((Integer) value).intValue(), "Returned correct new value 5"); } catch (final Throwable t) { fail("Threw " + t); @@ -1172,7 +1173,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "listIndexed[1]", "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "listIndexed[1]"); assertNotNull(value, "Returned new value 6"); - assertTrue(value instanceof String, "Returned String new value 6"); + assertInstanceOf(String.class, value, "Returned String new value 6"); assertEquals("New Value 2", (String) value, "Returned correct new value 6"); } catch (final Throwable t) { fail("Threw " + t); @@ -1182,7 +1183,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray[1]", "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "stringArray[2]"); assertNotNull(value, "Returned new value 6"); - assertTrue(value instanceof String, "Returned String new value 6"); + assertInstanceOf(String.class, value, "Returned String new value 6"); assertEquals("New Value 2", (String) value, "Returned correct new value 6"); } catch (final Throwable t) { fail("Threw " + t); @@ -1192,7 +1193,7 @@ public class DynaPropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray[0]", "New Value 3"); value = PropertyUtils.getIndexedProperty(bean, "stringArray[0]"); assertNotNull(value, "Returned new value 7"); - assertTrue(value instanceof String, "Returned String new value 7"); + assertInstanceOf(String.class, value, "Returned String new value 7"); assertEquals("New Value 3", (String) value, "Returned correct new value 7"); } catch (final Throwable t) { fail("Threw " + t); diff --git a/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java index 3bd060b0..3bf7691a 100644 --- a/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java @@ -18,6 +18,7 @@ package org.apache.commons.beanutils2; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -370,7 +371,7 @@ public class MethodUtilsTestCase { // Return initial value of the counter value = MethodUtils.invokeMethod(bean, "currentCounter", new Object[0], new Class[0]); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); // Increment via no-arguments version @@ -380,7 +381,7 @@ public class MethodUtilsTestCase { current++; value = MethodUtils.invokeMethod(bean, "currentCounter", new Object[0], new Class[0]); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); // Increment via specified-argument version @@ -390,7 +391,7 @@ public class MethodUtilsTestCase { current += 5; value = MethodUtils.invokeMethod(bean, "currentCounter", new Object[0], new Class[0]); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); } catch (final Exception e) { @@ -414,7 +415,7 @@ public class MethodUtilsTestCase { // Return initial value of the counter value = MethodUtils.invokeExactMethod(bean, "currentCounter", new Object[0], new Class[0]); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); // Increment via no-arguments version @@ -424,7 +425,7 @@ public class MethodUtilsTestCase { current++; value = MethodUtils.invokeExactMethod(bean, "currentCounter", new Object[0], new Class[0]); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); // Increment via specified-argument version @@ -434,7 +435,7 @@ public class MethodUtilsTestCase { current += 5; value = MethodUtils.invokeExactMethod(bean, "currentCounter", new Object[0], new Class[0]); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); } catch (final Exception e) { @@ -487,7 +488,7 @@ public class MethodUtilsTestCase { // Return initial value of the counter value = currentCounterMethod.invoke(null); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); // Increment via no-arguments version @@ -497,7 +498,7 @@ public class MethodUtilsTestCase { current++; value = currentCounterMethod.invoke(null); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); // Increment via specified-argument version @@ -507,7 +508,7 @@ public class MethodUtilsTestCase { current += 5; value = currentCounterMethod.invoke(null); assertNotNull(value, "currentCounter exists"); - assertTrue(value instanceof Integer, "currentCounter type"); + assertInstanceOf(Integer.class, value, "currentCounter type"); assertEquals(current, ((Integer) value).intValue(), "currentCounter value"); } catch (final Exception e) { diff --git a/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java index c53e6e81..a3e9ac79 100644 --- a/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java @@ -19,6 +19,7 @@ package org.apache.commons.beanutils2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -346,7 +347,7 @@ public class PropertyUtilsTestCase { } catch (final IllegalArgumentException t) { final Throwable cause = (Throwable) PropertyUtils.getProperty(t, "cause"); assertNotNull(cause, "Cause not found"); - assertTrue(cause instanceof IllegalArgumentException, + assertInstanceOf(IllegalArgumentException.class, cause, "Expected cause to be IllegalArgumentException, but was: " + cause.getClass()); // JDK 1.6 doesn't have "argument type mismatch" message // assertEquals("Check error message", "argument type mismatch", cause.getMessage()); @@ -722,7 +723,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "dupProperty", i); assertNotNull(value, "dupProperty returned value " + i); - assertTrue(value instanceof String, "dupProperty returned String " + i); + assertInstanceOf(String.class, value, "dupProperty returned String " + i); assertEquals("Dup " + i, (String) value, "dupProperty returned correct " + i); } catch (final Throwable t) { fail("dupProperty " + i + " threw " + t); @@ -731,7 +732,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intArray", i); assertNotNull(value, "intArray returned value " + i); - assertTrue(value instanceof Integer, "intArray returned Integer " + i); + assertInstanceOf(Integer.class, value, "intArray returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intArray returned correct " + i); } catch (final Throwable t) { fail("intArray " + i + " threw " + t); @@ -740,7 +741,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intIndexed", i); assertNotNull(value, "intIndexed returned value " + i); - assertTrue(value instanceof Integer, "intIndexed returned Integer " + i); + assertInstanceOf(Integer.class, value, "intIndexed returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intIndexed returned correct " + i); } catch (final Throwable t) { fail("intIndexed " + i + " threw " + t); @@ -749,7 +750,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "listIndexed", i); assertNotNull(value, "listIndexed returned value " + i); - assertTrue(value instanceof String, "list returned String " + i); + assertInstanceOf(String.class, value, "list returned String " + i); assertEquals("String " + i, (String) value, "listIndexed returned correct " + i); } catch (final Throwable t) { fail("listIndexed " + i + " threw " + t); @@ -758,7 +759,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringArray", i); assertNotNull(value, "stringArray returned value " + i); - assertTrue(value instanceof String, "stringArray returned String " + i); + assertInstanceOf(String.class, value, "stringArray returned String " + i); assertEquals("String " + i, (String) value, "stringArray returned correct " + i); } catch (final Throwable t) { fail("stringArray " + i + " threw " + t); @@ -767,7 +768,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", i); assertNotNull(value, "stringIndexed returned value " + i); - assertTrue(value instanceof String, "stringIndexed returned String " + i); + assertInstanceOf(String.class, value, "stringIndexed returned String " + i); assertEquals("String " + i, (String) value, "stringIndexed returned correct " + i); } catch (final Throwable t) { fail("stringIndexed " + i + " threw " + t); @@ -782,7 +783,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "dupProperty[" + i + "]"); assertNotNull(value, "dupProperty returned value " + i); - assertTrue(value instanceof String, "dupProperty returned String " + i); + assertInstanceOf(String.class, value, "dupProperty returned String " + i); assertEquals("Dup " + i, (String) value, "dupProperty returned correct " + i); } catch (final Throwable t) { fail("dupProperty " + i + " threw " + t); @@ -791,7 +792,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intArray[" + i + "]"); assertNotNull(value, "intArray returned value " + i); - assertTrue(value instanceof Integer, "intArray returned Integer " + i); + assertInstanceOf(Integer.class, value, "intArray returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intArray returned correct " + i); } catch (final Throwable t) { fail("intArray " + i + " threw " + t); @@ -800,7 +801,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "intIndexed[" + i + "]"); assertNotNull(value, "intIndexed returned value " + i); - assertTrue(value instanceof Integer, "intIndexed returned Integer " + i); + assertInstanceOf(Integer.class, value, "intIndexed returned Integer " + i); assertEquals(i * 10, ((Integer) value).intValue(), "intIndexed returned correct " + i); } catch (final Throwable t) { fail("intIndexed " + i + " threw " + t); @@ -809,7 +810,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "listIndexed[" + i + "]"); assertNotNull(value, "listIndexed returned value " + i); - assertTrue(value instanceof String, "listIndexed returned String " + i); + assertInstanceOf(String.class, value, "listIndexed returned String " + i); assertEquals("String " + i, (String) value, "listIndexed returned correct " + i); } catch (final Throwable t) { fail("listIndexed " + i + " threw " + t); @@ -818,7 +819,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringArray[" + i + "]"); assertNotNull(value, "stringArray returned value " + i); - assertTrue(value instanceof String, "stringArray returned String " + i); + assertInstanceOf(String.class, value, "stringArray returned String " + i); assertEquals("String " + i, (String) value, "stringArray returned correct " + i); } catch (final Throwable t) { fail("stringArray " + i + " threw " + t); @@ -827,7 +828,7 @@ public class PropertyUtilsTestCase { try { value = PropertyUtils.getIndexedProperty(bean, "stringIndexed[" + i + "]"); assertNotNull(value, "stringIndexed returned value " + i); - assertTrue(value instanceof String, "stringIndexed returned String " + i); + assertInstanceOf(String.class, value, "stringIndexed returned String " + i); assertEquals("String " + i, (String) value, "stringIndexed returned correct " + i); } catch (final Throwable t) { fail("stringIndexed " + i + " threw " + t); @@ -1193,7 +1194,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.booleanProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Boolean, "Got correct type"); + assertInstanceOf(Boolean.class, value, "Got correct type"); assertEquals(((Boolean) value).booleanValue(), bean.getNested().getBooleanProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -1216,7 +1217,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.doubleProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Double, "Got correct type"); + assertInstanceOf(Double.class, value, "Got correct type"); assertEquals(((Double) value).doubleValue(), bean.getNested().getDoubleProperty(), 0.005, "Got correct value"); } catch (final IllegalAccessException e) { @@ -1240,7 +1241,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.floatProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Float, "Got correct type"); + assertInstanceOf(Float.class, value, "Got correct type"); assertEquals(((Float) value).floatValue(), bean.getNested().getFloatProperty(), (float) 0.005, "Got correct value"); } catch (final IllegalAccessException e) { @@ -1264,7 +1265,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.intProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Integer, "Got correct type"); + assertInstanceOf(Integer.class, value, "Got correct type"); assertEquals(((Integer) value).intValue(), bean.getNested().getIntProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -1288,7 +1289,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.longProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Long, "Got correct type"); + assertInstanceOf(Long.class, value, "Got correct type"); assertEquals(((Long) value).longValue(), bean.getNested().getLongProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -1312,7 +1313,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.readOnlyProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); assertEquals((String) value, bean.getReadOnlyProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1335,7 +1336,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.shortProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Short, "Got correct type"); + assertInstanceOf(Short.class, value, "Got correct type"); assertEquals(((Short) value).shortValue(), bean.getNested().getShortProperty(), "Got correct value"); } catch (final IllegalAccessException e) { @@ -1359,7 +1360,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getNestedProperty(bean, "nested.stringProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); assertEquals((String) value, bean.getNested().getStringProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1724,7 +1725,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "booleanProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Boolean, "Got correct type"); + assertInstanceOf(Boolean.class, value, "Got correct type"); assertEquals(((Boolean) value).booleanValue(), bean.getBooleanProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1747,7 +1748,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "doubleProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Double, "Got correct type"); + assertInstanceOf(Double.class, value, "Got correct type"); assertEquals(((Double) value).doubleValue(), bean.getDoubleProperty(), 0.005, "Got correct value"); } catch (final IllegalAccessException e) { @@ -1771,7 +1772,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "floatProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Float, "Got correct type"); + assertInstanceOf(Float.class, value, "Got correct type"); assertEquals(((Float) value).floatValue(), bean.getFloatProperty(), (float) 0.005, "Got correct value"); } catch (final IllegalAccessException e) { @@ -1816,7 +1817,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "intProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Integer, "Got correct type"); + assertInstanceOf(Integer.class, value, "Got correct type"); assertEquals(((Integer) value).intValue(), bean.getIntProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1839,7 +1840,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "longProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Long, "Got correct type"); + assertInstanceOf(Long.class, value, "Got correct type"); assertEquals(((Long) value).longValue(), bean.getLongProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1883,7 +1884,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "readOnlyProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); assertEquals((String) value, bean.getReadOnlyProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1906,7 +1907,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "shortProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof Short, "Got correct type"); + assertInstanceOf(Short.class, value, "Got correct type"); assertEquals(((Short) value).shortValue(), bean.getShortProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -1929,7 +1930,7 @@ public class PropertyUtilsTestCase { try { final Object value = PropertyUtils.getSimpleProperty(bean, "stringProperty"); assertNotNull(value, "Got a value"); - assertTrue(value instanceof String, "Got correct type"); + assertInstanceOf(String.class, value, "Got correct type"); assertEquals((String) value, bean.getStringProperty(), "Got correct value"); } catch (final IllegalAccessException e) { fail("IllegalAccessException"); @@ -2581,7 +2582,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "dupProperty", 0, "New 0"); value = PropertyUtils.getIndexedProperty(bean, "dupProperty", 0); assertNotNull(value, "Returned new value 0"); - assertTrue(value instanceof String, "Returned String new value 0"); + assertInstanceOf(String.class, value, "Returned String new value 0"); assertEquals("New 0", (String) value, "Returned correct new value 0"); } catch (final Throwable t) { fail("Threw " + t); @@ -2591,7 +2592,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intArray", 0, Integer.valueOf(1)); value = PropertyUtils.getIndexedProperty(bean, "intArray", 0); assertNotNull(value, "Returned new value 0"); - assertTrue(value instanceof Integer, "Returned Integer new value 0"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 0"); assertEquals(1, ((Integer) value).intValue(), "Returned correct new value 0"); } catch (final Throwable t) { fail("Threw " + t); @@ -2601,7 +2602,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intIndexed", 1, Integer.valueOf(11)); value = PropertyUtils.getIndexedProperty(bean, "intIndexed", 1); assertNotNull(value, "Returned new value 1"); - assertTrue(value instanceof Integer, "Returned Integer new value 1"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 1"); assertEquals(11, ((Integer) value).intValue(), "Returned correct new value 1"); } catch (final Throwable t) { fail("Threw " + t); @@ -2611,7 +2612,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "listIndexed", 2, "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "listIndexed", 2); assertNotNull(value, "Returned new value 2"); - assertTrue(value instanceof String, "Returned String new value 2"); + assertInstanceOf(String.class, value, "Returned String new value 2"); assertEquals("New Value 2", (String) value, "Returned correct new value 2"); } catch (final Throwable t) { fail("Threw " + t); @@ -2621,7 +2622,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray", 2, "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "stringArray", 2); assertNotNull(value, "Returned new value 2"); - assertTrue(value instanceof String, "Returned String new value 2"); + assertInstanceOf(String.class, value, "Returned String new value 2"); assertEquals("New Value 2", (String) value, "Returned correct new value 2"); } catch (final Throwable t) { fail("Threw " + t); @@ -2631,7 +2632,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray", 3, "New Value 3"); value = PropertyUtils.getIndexedProperty(bean, "stringArray", 3); assertNotNull(value, "Returned new value 3"); - assertTrue(value instanceof String, "Returned String new value 3"); + assertInstanceOf(String.class, value, "Returned String new value 3"); assertEquals("New Value 3", (String) value, "Returned correct new value 3"); } catch (final Throwable t) { fail("Threw " + t); @@ -2643,7 +2644,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "dupProperty[4]", "New 4"); value = PropertyUtils.getIndexedProperty(bean, "dupProperty[4]"); assertNotNull(value, "Returned new value 4"); - assertTrue(value instanceof String, "Returned String new value 4"); + assertInstanceOf(String.class, value, "Returned String new value 4"); assertEquals("New 4", (String) value, "Returned correct new value 4"); } catch (final Throwable t) { fail("Threw " + t); @@ -2653,7 +2654,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intArray[4]", Integer.valueOf(1)); value = PropertyUtils.getIndexedProperty(bean, "intArray[4]"); assertNotNull(value, "Returned new value 4"); - assertTrue(value instanceof Integer, "Returned Integer new value 4"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 4"); assertEquals(1, ((Integer) value).intValue(), "Returned correct new value 4"); } catch (final Throwable t) { fail("Threw " + t); @@ -2663,7 +2664,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "intIndexed[3]", Integer.valueOf(11)); value = PropertyUtils.getIndexedProperty(bean, "intIndexed[3]"); assertNotNull(value, "Returned new value 5"); - assertTrue(value instanceof Integer, "Returned Integer new value 5"); + assertInstanceOf(Integer.class, value, "Returned Integer new value 5"); assertEquals(11, ((Integer) value).intValue(), "Returned correct new value 5"); } catch (final Throwable t) { fail("Threw " + t); @@ -2673,7 +2674,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "listIndexed[1]", "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "listIndexed[1]"); assertNotNull(value, "Returned new value 6"); - assertTrue(value instanceof String, "Returned String new value 6"); + assertInstanceOf(String.class, value, "Returned String new value 6"); assertEquals("New Value 2", (String) value, "Returned correct new value 6"); } catch (final Throwable t) { fail("Threw " + t); @@ -2683,7 +2684,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray[1]", "New Value 2"); value = PropertyUtils.getIndexedProperty(bean, "stringArray[2]"); assertNotNull(value, "Returned new value 6"); - assertTrue(value instanceof String, "Returned String new value 6"); + assertInstanceOf(String.class, value, "Returned String new value 6"); assertEquals("New Value 2", (String) value, "Returned correct new value 6"); } catch (final Throwable t) { fail("Threw " + t); @@ -2693,7 +2694,7 @@ public class PropertyUtilsTestCase { PropertyUtils.setIndexedProperty(bean, "stringArray[0]", "New Value 3"); value = PropertyUtils.getIndexedProperty(bean, "stringArray[0]"); assertNotNull(value, "Returned new value 7"); - assertTrue(value instanceof String, "Returned String new value 7"); + assertInstanceOf(String.class, value, "Returned String new value 7"); assertEquals("New Value 3", (String) value, "Returned correct new value 7"); } catch (final Throwable t) { fail("Threw " + t); diff --git a/src/test/java/org/apache/commons/beanutils2/WrapDynaBeanTestCase.java b/src/test/java/org/apache/commons/beanutils2/WrapDynaBeanTestCase.java index 5f35387d..ec0ca5cd 100644 --- a/src/test/java/org/apache/commons/beanutils2/WrapDynaBeanTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/WrapDynaBeanTestCase.java @@ -138,7 +138,7 @@ public class WrapDynaBeanTestCase extends BasicDynaBeanTestCase { final AlphaBean alphaBean = new AlphaBean("Now On Air... John Peel"); final WrapDynaBean dynaBean = new WrapDynaBean(alphaBean); final Object wrappedInstance = dynaBean.getInstance(); - assertTrue(wrappedInstance instanceof AlphaBean, "Object type is AlphaBean"); + assertInstanceOf(AlphaBean.class, wrappedInstance, "Object type is AlphaBean"); final AlphaBean wrappedAlphaBean = (AlphaBean) wrappedInstance; assertSame(wrappedAlphaBean, alphaBean, "Same Object"); } diff --git a/src/test/java/org/apache/commons/beanutils2/locale/LocaleConvertUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/locale/LocaleConvertUtilsTestCase.java index 7de7933b..1e6372d0 100644 --- a/src/test/java/org/apache/commons/beanutils2/locale/LocaleConvertUtilsTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/locale/LocaleConvertUtilsTestCase.java @@ -442,41 +442,41 @@ public class LocaleConvertUtilsTestCase { Object value; /* - * fixme Boolean converters not implemented value = LocaleConvertUtils.convert("true", Boolean.TYPE); assertTrue(value instanceof Boolean); + * fixme Boolean converters not implemented value = LocaleConvertUtils.convert("true", Boolean.TYPE); assertInstanceOf(Boolean.class, value); * assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("true", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), + * value = LocaleConvertUtils.convert("true", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), * true); * - * value = LocaleConvertUtils.convert("yes", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), true); + * value = LocaleConvertUtils.convert("yes", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("yes", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), true); + * value = LocaleConvertUtils.convert("yes", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("y", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), true); + * value = LocaleConvertUtils.convert("y", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("y", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), true); + * value = LocaleConvertUtils.convert("y", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("on", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), true); + * value = LocaleConvertUtils.convert("on", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("on", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), true); + * value = LocaleConvertUtils.convert("on", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), true); * - * value = LocaleConvertUtils.convert("false", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), + * value = LocaleConvertUtils.convert("false", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), * false); * - * value = LocaleConvertUtils.convert("false", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), + * value = LocaleConvertUtils.convert("false", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), * false); * - * value = LocaleConvertUtils.convert("no", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), false); + * value = LocaleConvertUtils.convert("no", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), false); * - * value = LocaleConvertUtils.convert("no", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), false); + * value = LocaleConvertUtils.convert("no", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), false); * - * value = LocaleConvertUtils.convert("n", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), false); + * value = LocaleConvertUtils.convert("n", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), false); * - * value = LocaleConvertUtils.convert("n", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), false); + * value = LocaleConvertUtils.convert("n", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), false); * - * value = LocaleConvertUtils.convert("off", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), false); + * value = LocaleConvertUtils.convert("off", Boolean.TYPE); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), false); * - * value = LocaleConvertUtils.convert("off", Boolean.class); assertTrue(value instanceof Boolean); assertEquals(((Boolean) value).booleanValue(), + * value = LocaleConvertUtils.convert("off", Boolean.class); assertInstanceOf(Boolean.class, value); assertEquals(((Boolean) value).booleanValue(), * false); */ @@ -489,14 +489,14 @@ public class LocaleConvertUtilsTestCase { assertEquals(((Byte) value).byteValue(), (byte) 123); /* - * fixme Character conversion not implemented yet value = LocaleConvertUtils.convert("a", Character.TYPE); assertTrue(value instanceof Character); + * fixme Character conversion not implemented yet value = LocaleConvertUtils.convert("a", Character.TYPE); assertInstanceOf(Character.class, value); * assertEquals(((Character) value).charValue(), 'a'); * - * value = LocaleConvertUtils.convert("a", Character.class); assertTrue(value instanceof Character); assertEquals(((Character) value).charValue(), 'a'); + * value = LocaleConvertUtils.convert("a", Character.class); assertInstanceOf(Character.class, value); assertEquals(((Character) value).charValue(), 'a'); */ /* * fixme - this is a discrepancy with standard converters ( probably not major issue ) value = LocaleConvertUtils.convert("java.lang.String", - * Class.class); assertTrue(value instanceof Class); assertEquals(String.class, (Class) value); + * Class.class); assertInstanceOf(Class.class, value); assertEquals(String.class, (Class) value); */ value = LocaleConvertUtils.convert("123" + decimalSeparator + "456", Double.TYPE); @@ -532,10 +532,10 @@ public class LocaleConvertUtilsTestCase { assertEquals(((Long) value).longValue(), 123456); /* - * fixme - Short conversion not implemented at this point value = LocaleConvertUtils.convert("123", Short.TYPE); assertTrue(value instanceof Short); + * fixme - Short conversion not implemented at this point value = LocaleConvertUtils.convert("123", Short.TYPE); assertInstanceOf(Short.class, value); * assertEquals(((Short) value).shortValue(), (short) 123); * - * value = LocaleConvertUtils.convert("123", Short.class); assertTrue(value instanceof Short); assertEquals(((Short) value).shortValue(), (short) 123); + * value = LocaleConvertUtils.convert("123", Short.class); assertInstanceOf(Short.class, value); assertEquals(((Short) value).shortValue(), (short) 123); */ String input; diff --git a/src/test/java/org/apache/commons/beanutils2/sql/DynaResultSetTestCase.java b/src/test/java/org/apache/commons/beanutils2/sql/DynaResultSetTestCase.java index 8e606623..5f9f5c8b 100644 --- a/src/test/java/org/apache/commons/beanutils2/sql/DynaResultSetTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/sql/DynaResultSetTestCase.java @@ -18,10 +18,10 @@ package org.apache.commons.beanutils2.sql; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; @@ -139,13 +139,13 @@ public class DynaResultSetTestCase { final Object bigDecimalProperty = row.get("bigdecimalproperty"); assertNotNull(bigDecimalProperty, "bigDecimalProperty exists"); - assertTrue(bigDecimalProperty instanceof BigDecimal, "bigDecimalProperty type"); + assertInstanceOf(BigDecimal.class, bigDecimalProperty, "bigDecimalProperty type"); assertEquals(123.45, ((BigDecimal) bigDecimalProperty).doubleValue(), 0.005, "bigDecimalProperty value"); final Object intProperty = row.get("intproperty"); assertNotNull(intProperty, "intProperty exists"); - assertTrue(intProperty instanceof Integer, "intProperty type"); + assertInstanceOf(Integer.class, intProperty, "intProperty type"); assertEquals(103, ((Integer) intProperty).intValue(), "intProperty value"); final Object nullProperty = row.get("nullproperty"); @@ -153,7 +153,7 @@ public class DynaResultSetTestCase { final Object stringProperty = row.get("stringproperty"); assertNotNull(stringProperty, "stringProperty exists"); - assertTrue(stringProperty instanceof String, "stringProperty type"); + assertInstanceOf(String.class, stringProperty, "stringProperty type"); assertEquals("This is a string", (String) stringProperty, "stringProperty value"); } @@ -188,13 +188,13 @@ public class DynaResultSetTestCase { final Object bigDecimalProperty = row.get("bigDecimalProperty"); assertNotNull(bigDecimalProperty, "bigDecimalProperty exists"); - assertTrue(bigDecimalProperty instanceof BigDecimal, "bigDecimalProperty type"); + assertInstanceOf(BigDecimal.class, bigDecimalProperty, "bigDecimalProperty type"); assertEquals(123.45, ((BigDecimal) bigDecimalProperty).doubleValue(), 0.005, "bigDecimalProperty value"); final Object intProperty = row.get("intProperty"); assertNotNull(intProperty, "intProperty exists"); - assertTrue(intProperty instanceof Integer, "intProperty type"); + assertInstanceOf(Integer.class, intProperty, "intProperty type"); assertEquals(103, ((Integer) intProperty).intValue(), "intProperty value"); final Object nullProperty = row.get("nullProperty"); @@ -202,7 +202,7 @@ public class DynaResultSetTestCase { final Object stringProperty = row.get("stringProperty"); assertNotNull(stringProperty, "stringProperty exists"); - assertTrue(stringProperty instanceof String, "stringProperty type"); + assertInstanceOf(String.class, stringProperty, "stringProperty type"); assertEquals("This is a string", (String) stringProperty, "stringProperty value"); } diff --git a/src/test/java/org/apache/commons/beanutils2/sql/DynaRowSetTestCase.java b/src/test/java/org/apache/commons/beanutils2/sql/DynaRowSetTestCase.java index 92e089c9..12909f4b 100644 --- a/src/test/java/org/apache/commons/beanutils2/sql/DynaRowSetTestCase.java +++ b/src/test/java/org/apache/commons/beanutils2/sql/DynaRowSetTestCase.java @@ -18,10 +18,10 @@ package org.apache.commons.beanutils2.sql; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; @@ -257,13 +257,13 @@ public class DynaRowSetTestCase { final Object bigDecimalProperty = row.get("bigdecimalproperty"); assertNotNull(bigDecimalProperty, "bigDecimalProperty exists"); - assertTrue(bigDecimalProperty instanceof BigDecimal, "bigDecimalProperty type"); + assertInstanceOf(BigDecimal.class, bigDecimalProperty, "bigDecimalProperty type"); assertEquals(123.45, ((BigDecimal) bigDecimalProperty).doubleValue(), 0.005, "bigDecimalProperty value"); final Object intProperty = row.get("intproperty"); assertNotNull(intProperty, "intProperty exists"); - assertTrue(intProperty instanceof Integer, "intProperty type"); + assertInstanceOf(Integer.class, intProperty, "intProperty type"); assertEquals(103, ((Integer) intProperty).intValue(), "intProperty value"); final Object nullProperty = row.get("nullproperty"); @@ -271,7 +271,7 @@ public class DynaRowSetTestCase { final Object stringProperty = row.get("stringproperty"); assertNotNull(stringProperty, "stringProperty exists"); - assertTrue(stringProperty instanceof String, "stringProperty type"); + assertInstanceOf(String.class, stringProperty, "stringProperty type"); assertEquals("This is a string", (String) stringProperty, "stringProperty value"); } @@ -304,13 +304,13 @@ public class DynaRowSetTestCase { final Object bigDecimalProperty = row.get("bigDecimalProperty"); assertNotNull(bigDecimalProperty, "bigDecimalProperty exists"); - assertTrue(bigDecimalProperty instanceof BigDecimal, "bigDecimalProperty type"); + assertInstanceOf(BigDecimal.class, bigDecimalProperty, "bigDecimalProperty type"); assertEquals(123.45, ((BigDecimal) bigDecimalProperty).doubleValue(), 0.005, "bigDecimalProperty value"); final Object intProperty = row.get("intProperty"); assertNotNull(intProperty, "intProperty exists"); - assertTrue(intProperty instanceof Integer, "intProperty type"); + assertInstanceOf(Integer.class, intProperty, "intProperty type"); assertEquals(103, ((Integer) intProperty).intValue(), "intProperty value"); final Object nullProperty = row.get("nullProperty"); @@ -318,7 +318,7 @@ public class DynaRowSetTestCase { final Object stringProperty = row.get("stringProperty"); assertNotNull(stringProperty, "stringProperty exists"); - assertTrue(stringProperty instanceof String, "stringProperty type"); + assertInstanceOf(String.class, stringProperty, "stringProperty type"); assertEquals("This is a string", (String) stringProperty, "stringProperty value"); }