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-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new a9bb7e90f Use Assertions.assertInstanceOf()
a9bb7e90f is described below

commit a9bb7e90fa74d03fac17ac27e6e20cb631127f3c
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Sep 1 19:02:47 2024 -0400

    Use Assertions.assertInstanceOf()
---
 .../java/org/apache/commons/lang3/ArrayUtilsTest.java   |  3 ++-
 .../java/org/apache/commons/lang3/FunctionsTest.java    | 17 +++++++++--------
 .../apache/commons/lang3/SerializationUtilsTest.java    |  7 ++++---
 .../commons/lang3/event/EventListenerSupportTest.java   |  4 ++--
 .../commons/lang3/function/FailableFunctionsTest.java   | 17 +++++++++--------
 .../java/org/apache/commons/lang3/tuple/PairTest.java   |  5 +++--
 .../java/org/apache/commons/lang3/tuple/TripleTest.java |  5 +++--
 7 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index f952bb85c..a91383bbd 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.lang3;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 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.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNotSame;
@@ -115,7 +116,7 @@ public class ArrayUtilsTest extends AbstractLangTest {
     @Test
     public void testArrayCreationWithGeneralReturnType() {
         final Object obj = ArrayUtils.toArray("foo", "bar");
-        assertTrue(obj instanceof String[]);
+        assertInstanceOf(String[].class, obj);
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/lang3/FunctionsTest.java 
b/src/test/java/org/apache/commons/lang3/FunctionsTest.java
index 138ad4298..a8c1a4202 100644
--- a/src/test/java/org/apache/commons/lang3/FunctionsTest.java
+++ b/src/test/java/org/apache/commons/lang3/FunctionsTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.lang3;
 
 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.assertSame;
@@ -543,7 +544,7 @@ public class FunctionsTest extends AbstractLangTest {
         final UndeclaredThrowableException e = 
assertThrows(UndeclaredThrowableException.class, callable::call);
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final FailureOnOddInvocations instance;
         try {
@@ -585,7 +586,7 @@ public class FunctionsTest extends AbstractLangTest {
         final UndeclaredThrowableException e = 
assertThrows(UndeclaredThrowableException.class, runnable::run);
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
 
         // Even invocations, should not throw an exception
@@ -600,7 +601,7 @@ public class FunctionsTest extends AbstractLangTest {
         final UndeclaredThrowableException e = 
assertThrows(UndeclaredThrowableException.class, supplier::get);
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         assertNotNull(supplier.get());
     }
@@ -669,7 +670,7 @@ public class FunctionsTest extends AbstractLangTest {
             () -> predicate.test(null, null));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final boolean instance = predicate.test(null, null);
         assertNotNull(instance);
@@ -682,7 +683,7 @@ public class FunctionsTest extends AbstractLangTest {
             () -> Functions.run(FailureOnOddInvocations::new));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final FailureOnOddInvocations instance = 
Functions.call(FailureOnOddInvocations::new);
         assertNotNull(instance);
@@ -729,7 +730,7 @@ public class FunctionsTest extends AbstractLangTest {
             () -> Functions.run(FailureOnOddInvocations::new));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final FailureOnOddInvocations instance = 
Functions.call(FailureOnOddInvocations::new);
         assertNotNull(instance);
@@ -771,7 +772,7 @@ public class FunctionsTest extends AbstractLangTest {
             () -> predicate.test(null));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final boolean instance = predicate.test(null);
         assertNotNull(instance);
@@ -784,7 +785,7 @@ public class FunctionsTest extends AbstractLangTest {
             () -> Functions.run(FailureOnOddInvocations::new));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
 
         // Even invocations, should not throw an exception
diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
index 9d85a7ce2..f82229e4d 100644
--- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.lang3;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 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.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -75,7 +76,7 @@ public class SerializationUtilsTest extends AbstractLangTest {
     public void testClone() {
         final Object test = SerializationUtils.clone(iMap);
         assertNotNull(test);
-        assertTrue(test instanceof HashMap<?, ?>);
+        assertInstanceOf(HashMap.class, test);
         assertNotSame(test, iMap);
         final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
         assertEquals(iString, testMap.get("FOO"));
@@ -117,7 +118,7 @@ public class SerializationUtilsTest extends 
AbstractLangTest {
 
         final Object test = 
SerializationUtils.deserialize(streamReal.toByteArray());
         assertNotNull(test);
-        assertTrue(test instanceof HashMap<?, ?>);
+        assertInstanceOf(HashMap.class, test);
         assertNotSame(test, iMap);
         final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
         assertEquals(iString, testMap.get("FOO"));
@@ -172,7 +173,7 @@ public class SerializationUtilsTest extends 
AbstractLangTest {
         final ByteArrayInputStream inTest = new 
ByteArrayInputStream(streamReal.toByteArray());
         final Object test = SerializationUtils.deserialize(inTest);
         assertNotNull(test);
-        assertTrue(test instanceof HashMap<?, ?>);
+        assertInstanceOf(HashMap.class, test);
         assertNotSame(test, iMap);
         final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
         assertEquals(iString, testMap.get("FOO"));
diff --git 
a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java 
b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
index a8fceef4e..a3ce7fe9c 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
@@ -18,9 +18,9 @@
 package org.apache.commons.lang3.event;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyVetoException;
@@ -248,7 +248,7 @@ public class EventListenerSupportTest extends 
AbstractLangTest {
         final Exception e = assertThrows(UndeclaredThrowableException.class,
                 () -> listenerSupport.fire().vetoableChange(new 
PropertyChangeEvent(new Date(), "Day", 0, 1)));
         final Throwable rootCause = ExceptionUtils.getRootCause(e);
-        assertTrue(rootCause instanceof PropertyVetoException);
+        assertInstanceOf(PropertyVetoException.class, rootCause);
         assertEquals(vetoLimit + 1, count.get());
     }
 
diff --git 
a/src/test/java/org/apache/commons/lang3/function/FailableFunctionsTest.java 
b/src/test/java/org/apache/commons/lang3/function/FailableFunctionsTest.java
index 4914c054b..2052205ac 100644
--- a/src/test/java/org/apache/commons/lang3/function/FailableFunctionsTest.java
+++ b/src/test/java/org/apache/commons/lang3/function/FailableFunctionsTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.lang3.function;
 
 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.assertSame;
@@ -550,7 +551,7 @@ public class FailableFunctionsTest extends AbstractLangTest 
{
         final UndeclaredThrowableException e = 
assertThrows(UndeclaredThrowableException.class, callable::call);
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final FailureOnOddInvocations instance;
         try {
@@ -590,7 +591,7 @@ public class FailableFunctionsTest extends AbstractLangTest 
{
         final UndeclaredThrowableException e = 
assertThrows(UndeclaredThrowableException.class, runnable::run);
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
 
         // Even invocations, should not throw an exception
@@ -605,7 +606,7 @@ public class FailableFunctionsTest extends AbstractLangTest 
{
         final UndeclaredThrowableException e = 
assertThrows(UndeclaredThrowableException.class, supplier::get);
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         assertNotNull(supplier.get());
     }
@@ -719,7 +720,7 @@ public class FailableFunctionsTest extends AbstractLangTest 
{
             () -> predicate.test(null, null));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         assertTrue(predicate.test(null, null));
     }
@@ -765,7 +766,7 @@ public class FailableFunctionsTest extends AbstractLangTest 
{
             () -> Failable.run(FailureOnOddInvocations::new));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final FailureOnOddInvocations instance = 
Failable.call(FailureOnOddInvocations::new);
         assertNotNull(instance);
@@ -1195,7 +1196,7 @@ public class FailableFunctionsTest extends 
AbstractLangTest {
             () -> Failable.run(FailureOnOddInvocations::new));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final FailureOnOddInvocations instance = 
Failable.call(FailureOnOddInvocations::new);
         assertNotNull(instance);
@@ -1444,7 +1445,7 @@ public class FailableFunctionsTest extends 
AbstractLangTest {
             () -> predicate.test(null));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
         final boolean instance = predicate.test(null);
         assertNotNull(instance);
@@ -1487,7 +1488,7 @@ public class FailableFunctionsTest extends 
AbstractLangTest {
             () -> Failable.run(FailureOnOddInvocations::new));
         final Throwable cause = e.getCause();
         assertNotNull(cause);
-        assertTrue(cause instanceof SomeException);
+        assertInstanceOf(SomeException.class, cause);
         assertEquals("Odd Invocation: 1", cause.getMessage());
 
         // Even invocations, should not throw an exception
diff --git a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java 
b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
index a72032d10..ad368a287 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.lang3.tuple;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -177,11 +178,11 @@ public class PairTest extends AbstractLangTest {
     @Test
     public void testPairOfObjects() {
         final Pair<Integer, String> pair = Pair.of(0, "foo");
-        assertTrue(pair instanceof ImmutablePair<?, ?>);
+        assertInstanceOf(ImmutablePair.class, pair);
         assertEquals(0, ((ImmutablePair<Integer, String>) 
pair).left.intValue());
         assertEquals("foo", ((ImmutablePair<Integer, String>) pair).right);
         final Pair<Object, String> pair2 = Pair.of(null, "bar");
-        assertTrue(pair2 instanceof ImmutablePair<?, ?>);
+        assertInstanceOf(ImmutablePair.class, pair2);
         assertNull(((ImmutablePair<Object, String>) pair2).left);
         assertEquals("bar", ((ImmutablePair<Object, String>) pair2).right);
         final Pair<?, ?> pair3 = Pair.of(null, null);
diff --git a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java 
b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
index f7171a22a..e7e76dfa8 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.lang3.tuple;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -138,12 +139,12 @@ public class TripleTest extends AbstractLangTest {
     @Test
     public void testTripleOf() {
         final Triple<Integer, String, Boolean> triple = Triple.of(0, "foo", 
Boolean.TRUE);
-        assertTrue(triple instanceof ImmutableTriple<?, ?, ?>);
+        assertInstanceOf(ImmutableTriple.class, triple);
         assertEquals(0, ((ImmutableTriple<Integer, String, Boolean>) 
triple).left.intValue());
         assertEquals("foo", ((ImmutableTriple<Integer, String, Boolean>) 
triple).middle);
         assertEquals(Boolean.TRUE, ((ImmutableTriple<Integer, String, 
Boolean>) triple).right);
         final Triple<Object, String, Long> triple2 = Triple.of(null, "bar", 
Long.valueOf(200L));
-        assertTrue(triple2 instanceof ImmutableTriple<?, ?, ?>);
+        assertInstanceOf(ImmutableTriple.class, triple2);
         assertNull(((ImmutableTriple<Object, String, Long>) triple2).left);
         assertEquals("bar", ((ImmutableTriple<Object, String, Long>) 
triple2).middle);
         assertEquals(Long.valueOf(200L), ((ImmutableTriple<Object, String, 
Long>) triple2).right);

Reply via email to