This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 011cc65b8 Test modernization
011cc65b8 is described below
commit 011cc65b875263d8e1e1135d46e2558bd3b38668
Author: James Bognar <[email protected]>
AuthorDate: Sat Aug 30 17:26:54 2025 -0400
Test modernization
---
.../juneau/assertions/FluentObjectAssertion.java | 4 ++-
.../apache/juneau/common/internal/StringUtils.java | 6 ++--
.../org/apache/juneau/common/internal/Utils.java | 42 ++++++++++------------
.../java/org/apache/juneau/BeanDictionaryMap.java | 4 ++-
.../main/java/org/apache/juneau/BeanRegistry.java | 2 +-
.../org/apache/juneau/collections/JsonMap.java | 2 +-
.../html/HtmlStrippedDocSerializerSession.java | 4 ++-
.../apache/juneau/internal/AnnotationUtils.java | 3 +-
.../org/apache/juneau/internal/ArrayUtils.java | 14 ++------
.../org/apache/juneau/internal/ListBuilder.java | 3 +-
.../org/apache/juneau/internal/SetBuilder.java | 3 +-
.../apache/juneau/objecttools/ObjectSearcher.java | 4 ++-
.../apache/juneau/objecttools/ObjectSorter.java | 3 +-
.../org/apache/juneau/reflect/AnnotationInfo.java | 6 ++--
.../juneau/serializer/SerializerSession.java | 2 +-
.../org/apache/juneau/svl/VarResolverSession.java | 3 +-
.../org/apache/juneau/rest/client/RestRequest.java | 12 +++----
.../rest/processor/ResponseBeanProcessor.java | 2 +-
.../src/test/java/org/apache/juneau/TestUtils.java | 6 ++--
.../annotation/BeanConfigAnnotation_Test.java | 3 +-
.../juneau/html/HtmlDocConfigAnnotation_Test.java | 2 +-
.../apache/juneau/reflect/ExecutableInfo_Test.java | 2 +-
.../org/apache/juneau/reflect/ParamInfoTest.java | 2 +-
.../apache/juneau/xml/XmlConfigAnnotationTest.java | 3 +-
24 files changed, 69 insertions(+), 68 deletions(-)
diff --git
a/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
b/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
index 44b88ec4e..efaf464a3 100644
---
a/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
+++
b/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
@@ -14,6 +14,8 @@ package org.apache.juneau.assertions;
import static org.apache.juneau.common.internal.StringUtils.*;
import static org.apache.juneau.common.internal.ThrowableUtils.*;
+import static org.apache.juneau.common.internal.Utils.*;
+
import java.io.*;
import java.util.*;
import java.util.function.*;
@@ -668,7 +670,7 @@ public class FluentObjectAssertion<T,R> extends
FluentAssertion<R> {
return false;
if (o1.equals(o2))
return true;
- if (o1.getClass().isArray())
+ if (isArray(o1))
return stringifyDeep(o1).equals(stringifyDeep(o2));
return false;
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
index 1f9b1db2f..8f288879c 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
@@ -327,7 +327,7 @@ public final class StringUtils {
return ((Class<?>)o).getName();
if (o instanceof Method)
return Method.class.cast(o).getName();
- if (o.getClass().isArray())
+ if (isArray(o))
return
arrayAsList(o).stream().map(StringUtils::convertToReadable).collect(Collectors.joining(",
", "[", "]"));
return o.toString();
}
@@ -1590,7 +1590,7 @@ public final class StringUtils {
public static String stringifyDeep(Object o) {
if (o == null)
return null;
- if (! o.getClass().isArray())
+ if (! isArray(o))
return o.toString();
if (o.getClass().getComponentType().isPrimitive())
return
PRIMITIVE_ARRAY_STRINGIFIERS.get(o.getClass()).apply(o);
@@ -1647,7 +1647,7 @@ public final class StringUtils {
public static String toCdl(Object o) {
if (o == null)
return null;
- if (o.getClass().isArray()) {
+ if (isArray(o)) {
var sb = new StringBuilder();
for (int i = 0, j = Array.getLength(o); i < j; i++) {
if (i > 0)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
index 3cdc06401..d7afe128f 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
@@ -93,12 +93,10 @@ public class Utils {
*/
public static List<Object> arrayToList(Object array) {
if (array == null) {
- return null;
+ return null; // NOSONAR
}
- if (!array.getClass().isArray()) {
- throw new IllegalArgumentException("Input must be an
array, but was: " + array.getClass().getName());
- }
+ assertArg(isArray(array), "Input must be an array but was {0}",
array.getClass().getName());
var componentType = array.getClass().getComponentType();
var length = Array.getLength(array);
@@ -525,7 +523,7 @@ public class Utils {
return new IllegalArgumentException(args.length == 0 ? msg :
f(msg, args));
}
- private static boolean isArray(Object o) {
+ public static boolean isArray(Object o) {
return o != null && o.getClass().isArray();
}
@@ -553,7 +551,7 @@ public class Utils {
return o2.isEmpty();
if (o instanceof Map<?,?> o2)
return o2.isEmpty();
- if (o.getClass().isArray())
+ if (isArray(o))
return (Array.getLength(o) == 0);
return o.toString().isEmpty();
}
@@ -589,7 +587,7 @@ public class Utils {
if (value instanceof CharSequence x) return ! x.isEmpty();
if (value instanceof Collection<?> x) return ! x.isEmpty();
if (value instanceof Map<?,?> x) return ! x.isEmpty();
- if (value.getClass().isArray()) return Array.getLength(value) >
0;
+ if (isArray(value)) return Array.getLength(value) > 0;
return isNotEmpty(s(value));
}
@@ -955,9 +953,9 @@ public class Utils {
/**
* Converts an arbitrary object to a readable string format suitable
for debugging and testing.
- *
- * <p>This method provides intelligent formatting for various Java
types, recursively processing
- * nested structures to create human-readable representations. It's
extensively used throughout
+ *
+ * <p>This method provides intelligent formatting for various Java
types, recursively processing
+ * nested structures to create human-readable representations. It's
extensively used throughout
* the Juneau framework for test assertions and debugging output.</p>
*
* <h5 class='section'>Type-Specific Formatting:</h5>
@@ -983,17 +981,17 @@ public class Utils {
* <jc>// Collections</jc>
* r(List.of("a", "b", "c")) <jc>// Returns: "[a,b,c]"</jc>
* r(Set.of(1, 2, 3)) <jc>// Returns: "[1,2,3]" (order may
vary)</jc>
- *
+ *
* <jc>// Maps</jc>
* r(Map.of("foo", "bar", "baz", 123)) <jc>// Returns:
"{foo=bar,baz=123}"</jc>
- *
+ *
* <jc>// Arrays</jc>
* r(new int[]{1, 2, 3}) <jc>// Returns: "[1,2,3]"</jc>
* r(new String[]{"a", "b"}) <jc>// Returns: "[a,b]"</jc>
- *
+ *
* <jc>// Nested structures</jc>
* r(List.of(Map.of("x", 1), Set.of("a", "b"))) <jc>// Returns:
"[{x=1},[a,b]]"</jc>
- *
+ *
* <jc>// Special types</jc>
* r(Optional.of("test")) <jc>// Returns: "test"</jc>
* r(Optional.empty()) <jc>// Returns: null</jc>
@@ -1001,13 +999,13 @@ public class Utils {
* </p>
*
* <h5 class='section'>Recursive Processing:</h5>
- * <p>The method recursively processes nested structures, so complex
objects containing
- * collections, maps, and arrays are fully flattened into readable
format. This makes it
+ * <p>The method recursively processes nested structures, so complex
objects containing
+ * collections, maps, and arrays are fully flattened into readable
format. This makes it
* ideal for test assertions where you need to compare complex object
structures.</p>
*
* <h5 class='section'>Error Handling:</h5>
- * <p>IO operations (reading files, streams) are wrapped in safe()
calls, converting
- * any exceptions to RuntimeExceptions. Binary data (InputStreams, byte
arrays) is
+ * <p>IO operations (reading files, streams) are wrapped in safe()
calls, converting
+ * any exceptions to RuntimeExceptions. Binary data (InputStreams, byte
arrays) is
* converted to hexadecimal representation for readability.</p>
*
* @param o The object to convert to readable format. Can be
<jk>null</jk>.
@@ -1043,7 +1041,7 @@ public class Utils {
return safe(()->IOUtils.read(o2));
if (o instanceof byte[] o2)
return toHex(o2);
- if (o.getClass().isArray()) {
+ if (isArray(o)) {
var l = list();
for (var i = 0; i < Array.getLength(o); i++) {
l.add(Array.get(o, i));
@@ -1661,9 +1659,7 @@ public class Utils {
* @return A new stream.
*/
public static Stream<Object> toStream(Object array) {
- if (array == null || ! array.getClass().isArray()) {
- throw illegalArg("Not an array: " + array);
- }
+ assertArg(isArray(array), "Arg was not an array. Type: {0}",
array.getClass().getName());
var length = Array.getLength(array);
return IntStream.range(0, length).mapToObj(i ->
Array.get(array, i));
}
@@ -1697,7 +1693,7 @@ public class Utils {
o2.forEach(x -> traverse(x, c));
else if (o instanceof Stream<?> o2)
o2.forEach(x -> traverse(x, c));
- else if (o.getClass().isArray())
+ else if (isArray(o))
toStream(o).forEach(x -> traverse(x, c));
else
c.accept((T)o);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanDictionaryMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanDictionaryMap.java
index 55f279fe3..7b7421e2b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanDictionaryMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanDictionaryMap.java
@@ -12,6 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau;
+import static org.apache.juneau.common.internal.Utils.*;
+
import java.lang.reflect.*;
import java.util.*;
@@ -116,7 +118,7 @@ public class BeanDictionaryMap extends
LinkedHashMap<String,Object> {
if (o != null) {
if (o instanceof Class)
return;
- if (o.getClass().isArray()) {
+ if (isArray(o)) {
for (int i = 0; i < Array.getLength(o); i++)
assertValidParameter(Array.get(o, i));
return;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
index e36c00e58..96754ccb1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
@@ -83,7 +83,7 @@ public class BeanRegistry {
ClassMeta<?> val = null;
if (v instanceof Type)
val =
beanContext.getClassMeta((Type)v);
- else if (v.getClass().isArray())
+ else if (isArray(v))
val =
getTypedClassMeta(v);
else
throw new
BeanRuntimeException("Class ''{0}'' was passed to BeanRegistry but value of
type ''{1}'' found in map is not a Type object.", className(c), className(v));
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
index 311daf694..5cdb7b793 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
@@ -541,7 +541,7 @@ public class JsonMap extends LinkedHashMap<String,Object> {
x == null
|| (x instanceof Boolean && x.equals(false))
|| (x instanceof Number && ((Number)x).intValue() == -1)
- || (x.getClass().isArray() && Array.getLength(x) == 0)
+ || (isArray(x) && Array.getLength(x) == 0)
|| (x instanceof Map && ((Map<?,?>)x).isEmpty())
|| (x instanceof Collection &&
((Collection<?>)x).isEmpty())
));
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
index 93751f0ac..b4416d09b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
@@ -12,6 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau.html;
+import static org.apache.juneau.common.internal.Utils.*;
+
import java.io.IOException;
import java.lang.reflect.*;
import java.nio.charset.*;
@@ -215,7 +217,7 @@ public class HtmlStrippedDocSerializerSession extends
HtmlSerializerSession {
try (HtmlWriter w = getHtmlWriter(out)) {
if (o == null
|| (o instanceof Collection &&
((Collection<?>)o).isEmpty())
- || (o.getClass().isArray() &&
Array.getLength(o) == 0))
+ || (isArray(o) && Array.getLength(o) == 0))
w.sTag(1, "p").append("No
Results").eTag("p").nl(1);
else
super.doSerialize(out, o);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
index f24d1268f..d16f1422f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
@@ -12,7 +12,6 @@
//
***************************************************************************************************************************
package org.apache.juneau.internal;
-import static org.apache.juneau.common.internal.ThrowableUtils.*;
import static org.apache.juneau.common.internal.Utils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -81,7 +80,7 @@ public class AnnotationUtils {
int part1 = name.hashCode() * 127;
if (value == null)
return part1;
- if (value.getClass().isArray())
+ if (isArray(value))
return part1 ^
arrayMemberHash(value.getClass().getComponentType(), value);
if (value instanceof Annotation)
return part1 ^ hashCode((Annotation) value);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
index 53c23ee8c..b5a51c7a6 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
@@ -12,6 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau.internal;
+import static org.apache.juneau.common.internal.Utils.*;
+
import java.lang.reflect.*;
import java.util.*;
@@ -142,16 +144,6 @@ public final class ArrayUtils {
return a;
}
- /**
- * Returns <jk>true</jk> if the specified object is an array.
- *
- * @param array The array to test.
- * @return <jk>true</jk> if the specified object is an array.
- */
- public static boolean isArray(Object array) {
- return array != null && array.getClass().isArray();
- }
-
/**
* Converts the specified array to an <c>ArrayList</c>
*
@@ -180,7 +172,7 @@ public final class ArrayUtils {
List<Object> l = new ArrayList<>(Array.getLength(array));
for (int i = 0; i < Array.getLength(array); i++) {
Object o = Array.get(array, i);
- if (o != null && o.getClass().isArray())
+ if (isArray(o))
o = toObjectList(o);
l.add(o);
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java
index a4378d213..59a1791f7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java
@@ -14,6 +14,7 @@ package org.apache.juneau.internal;
import static org.apache.juneau.common.internal.StringUtils.*;
import static org.apache.juneau.common.internal.ThrowableUtils.*;
+import static org.apache.juneau.common.internal.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import static java.util.Collections.*;
@@ -235,7 +236,7 @@ public final class ListBuilder<E> {
if (o != null) {
if (o instanceof Collection) {
((Collection<?>)o).forEach(x -> addAny(x));
- } else if
(o.getClass().isArray()) {
+ } else if (isArray(o)) {
for (int i = 0; i <
Array.getLength(o); i++)
addAny(Array.get(o, i));
} else if (isJsonArray(o,
false)) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java
index 1b80097d9..67a97c4a2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java
@@ -14,6 +14,7 @@ package org.apache.juneau.internal;
import static org.apache.juneau.common.internal.StringUtils.*;
import static org.apache.juneau.common.internal.ThrowableUtils.*;
+import static org.apache.juneau.common.internal.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import static java.util.Collections.*;
@@ -218,7 +219,7 @@ public final class SetBuilder<E> {
if (o != null) {
if (o instanceof Collection) {
((Collection<?>)o).forEach(x -> addAny(x));
- } else if
(o.getClass().isArray()) {
+ } else if (isArray(o)) {
for (int i = 0; i <
Array.getLength(o); i++)
addAny(Array.get(o, i));
} else if (isJsonArray(o,
false)) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSearcher.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSearcher.java
index d798ee2af..85efaa1fa 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSearcher.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSearcher.java
@@ -12,6 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau.objecttools;
+import static org.apache.juneau.common.internal.Utils.*;
+
import java.lang.reflect.*;
import java.util.*;
@@ -160,7 +162,7 @@ public final class ObjectSearcher implements
ObjectTool<SearchArgs> {
return (List<R>)r;
if (r instanceof Collection)
return new ArrayList<R>((Collection)r);
- if (r.getClass().isArray())
+ if (isArray(r))
return Arrays.asList((R[])r);
return null;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
index 705855727..465195ba0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
@@ -12,6 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.objecttools;
+import static org.apache.juneau.common.internal.Utils.*;
import static org.apache.juneau.internal.CollectionUtils.*;
import java.lang.reflect.*;
@@ -89,7 +90,7 @@ public final class ObjectSorter implements
ObjectTool<SortArgs> {
return (List<R>)r;
if (r instanceof Collection)
return new ArrayList<R>((Collection)r);
- if (r.getClass().isArray())
+ if (isArray(r))
return Arrays.asList((R[])r);
return null;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
index 1618a343b..c138ddef5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
@@ -12,8 +12,9 @@
//
***************************************************************************************************************************
package org.apache.juneau.reflect;
-import static org.apache.juneau.common.internal.ThrowableUtils.*;
+import static org.apache.juneau.common.internal.Utils.*;
import static org.apache.juneau.internal.ConsumerUtils.*;
+
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
@@ -23,7 +24,6 @@ import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.internal.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.marshaller.*;
import org.apache.juneau.svl.*;
@@ -175,7 +175,7 @@ public final class AnnotationInfo<T extends Annotation> {
Object v = x.invoke(a);
Object d = x.inner().getDefaultValue();
if (Utils.ne(v, d)) {
- if (! (ArrayUtils.isArray(v) &&
Array.getLength(v) == 0 && Array.getLength(d) == 0))
+ if (! (isArray(v) && Array.getLength(v)
== 0 && Array.getLength(d) == 0))
ja.put(m.getName(), v);
}
} catch (Exception e) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index e72a1c612..07ac9cdf7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -562,7 +562,7 @@ public class SerializerSession extends BeanTraverseSession {
cm = object();
if (isTrimEmptyCollections()) {
- if (cm.isArray() || (cm.isObject() &&
value.getClass().isArray())) {
+ if (cm.isArray() || (cm.isObject() && isArray(value))) {
if (((Object[])value).length == 0)
return true;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/svl/VarResolverSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/svl/VarResolverSession.java
index ad5cbb716..f887360ef 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/svl/VarResolverSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/svl/VarResolverSession.java
@@ -14,6 +14,7 @@ package org.apache.juneau.svl;
import static org.apache.juneau.common.internal.StringUtils.*;
import static org.apache.juneau.common.internal.ThrowableUtils.*;
+import static org.apache.juneau.common.internal.Utils.*;
import java.io.*;
import java.lang.reflect.*;
@@ -135,7 +136,7 @@ public class VarResolverSession {
return null;
if (o instanceof CharSequence)
return (T)resolve(o.toString());
- if (o.getClass().isArray()) {
+ if (isArray(o)) {
if (! containsVars(o))
return o;
Object o2 =
Array.newInstance(o.getClass().getComponentType(), Array.getLength(o));
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
index 9d1a8a85e..50e7ce314 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
@@ -1506,7 +1506,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
((HeaderList)value).forEach(x->l.add(x));
} else if (value instanceof Collection) {
((Collection<?>)value).forEach(x ->
l.add(HttpHeaders.cast(x)));
- } else if (value != null && value.getClass().isArray()) {
+ } else if (isArray(value)) {
for (int i = 0; i < Array.getLength(value); i++)
l.add(HttpHeaders.cast(Array.get(value, i)));
} else if (value instanceof Map) {
@@ -1542,7 +1542,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
((PartList)value).forEach(x->l.add(x));
} else if (value instanceof Collection) {
((Collection<?>)value).forEach(x ->
l.add(HttpParts.cast(x)));
- } else if (value != null && value.getClass().isArray()) {
+ } else if (isArray(value)) {
for (int i = 0; i < Array.getLength(value); i++)
l.add(HttpParts.cast(Array.get(value, i)));
} else if (value instanceof Map) {
@@ -1579,7 +1579,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
((PartList)value).forEach(x->l.add(x));
} else if (value instanceof Collection) {
((Collection<?>)value).forEach(x ->
l.add(HttpParts.cast(x)));
- } else if (value != null && value.getClass().isArray()) {
+ } else if (isArray(value)) {
for (int i = 0; i < Array.getLength(value); i++)
l.add(HttpParts.cast(Array.get(value, i)));
} else if (value instanceof Map) {
@@ -1613,7 +1613,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
((PartList)value).forEach(x->l.add(x));
} else if (value instanceof Collection) {
((Collection<?>)value).forEach(x ->
l.add(HttpParts.cast(x)));
- } else if (value != null && value.getClass().isArray()) {
+ } else if (isArray(value)) {
for (int i = 0; i < Array.getLength(value); i++)
l.add(HttpParts.cast(Array.get(value, i)));
} else if (value instanceof Map) {
@@ -2589,7 +2589,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
}
private static boolean isNameValuePairArray(Object o) {
- if (o == null || ! o.getClass().isArray())
+ if (! isArray(o))
return false;
if
(NameValuePair.class.isAssignableFrom(o.getClass().getComponentType()))
return true;
@@ -2597,7 +2597,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
}
private static boolean isHeaderArray(Object o) {
- if (o == null || ! o.getClass().isArray())
+ if (! isArray(o))
return false;
if
(Header.class.isAssignableFrom(o.getClass().getComponentType()))
return true;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/processor/ResponseBeanProcessor.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/processor/ResponseBeanProcessor.java
index a7434132d..6b84360dc 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/processor/ResponseBeanProcessor.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/processor/ResponseBeanProcessor.java
@@ -129,7 +129,7 @@ public final class ResponseBeanProcessor implements
ResponseProcessor {
return Collections.emptyList();
if (o instanceof Map)
return ((Map<?,?>)o).entrySet();
- if (o.getClass().isArray())
+ if (isArray(o))
return alist((Object[])o);
if (o instanceof Collection)
return (Collection<?>)o;
diff --git a/juneau-utest/src/test/java/org/apache/juneau/TestUtils.java
b/juneau-utest/src/test/java/org/apache/juneau/TestUtils.java
index 972a74f2c..ef915a325 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/TestUtils.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/TestUtils.java
@@ -1057,7 +1057,7 @@ public class TestUtils extends Utils2 {
@SuppressWarnings("unchecked")
private static Object getEntry2(Object o, String name) {
if (o instanceof List o2) return isNumeric(name) ?
o2.get(parseInt(name)) : getBeanProp(o, name);
- if (o.getClass().isArray()) return isNumeric(name) ?
Array.get(o, parseInt(name)) : getBeanProp(o, name);
+ if (isArray(o)) return isNumeric(name) ? Array.get(o,
parseInt(name)) : getBeanProp(o, name);
if (o instanceof Map o2) return
opt(o2.get(eq("<<<NULL>>>",name) ? null : name)).orElse(name.equals("class") ?
o.getClass() : null);
if (o instanceof Iterable o2) return isNumeric(name) ?
toList(o2).get(parseInt(name)) : getBeanProp(o, name);
if (o instanceof Iterator o2) return isNumeric(name) ?
toList(o2).get(parseInt(name)) : getBeanProp(o, name);
@@ -1066,7 +1066,7 @@ public class TestUtils extends Utils2 {
}
private static boolean isConvertibleToList(Object o) {
- return o != null && (o instanceof Collection || o instanceof
Iterable || o instanceof Iterator || o instanceof Enumeration ||
o.getClass().isArray());
+ return o != null && (o instanceof Collection || o instanceof
Iterable || o instanceof Iterator || o instanceof Enumeration || isArray(o));
}
@SuppressWarnings("unchecked")
@@ -1076,7 +1076,7 @@ public class TestUtils extends Utils2 {
if (o instanceof Iterable o2) return toList(o2);
if (o instanceof Iterator o2) return toList(o2);
if (o instanceof Enumeration o2) return toList(o2);
- if (o.getClass().isArray()) return arrayToList(o);
+ if (isArray(o)) return arrayToList(o);
throw runtimeException("Could not convert object of type {0} to
a list", o.getClass().getName());
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
index f8dc4fcf4..fd75f400a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
@@ -12,6 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.annotation;
+import static org.apache.juneau.common.internal.Utils.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.*;
@@ -48,7 +49,7 @@ class BeanConfigAnnotation_Test extends SimpleTestBase {
.stream()
.map(TO_STRING)
.collect(Collectors.joining(","));
- if (t.getClass().isArray())
+ if (isArray(t))
return apply(ArrayUtils.toList(t,
Object.class));
if (t instanceof JsonMap)
return ((JsonMap)t).toString();
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotation_Test.java
index a1e01c855..1ae77f1d9 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotation_Test.java
@@ -36,7 +36,7 @@ class HtmlDocConfigAnnotation_Test extends SimpleTestBase {
}
private static final Function<Object,String> TO_STRING = t -> {
- if (t.getClass().isArray())
+ if (isArray(t))
return
HtmlDocConfigAnnotation_Test.TO_STRING.apply(ArrayUtils.toList(t,
Object.class));
if (t instanceof Collection)
return ((Collection<?>)t)
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
index 9d2dee4a5..27a3f2389 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
@@ -41,7 +41,7 @@ class ExecutableInfo_Test extends SimpleTestBase {
return null;
if (t instanceof List)
return
((List<?>)t).stream().map(this).collect(Collectors.joining(","));
- if (t.getClass().isArray())
+ if (isArray(t))
return
StreamSupport.stream(ArrayUtils.toList(t, Object.class).spliterator(),
false).map(this).collect(Collectors.joining(","));
if (t instanceof Annotation)
return "@" +
((Annotation)t).annotationType().getSimpleName() + "()";
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
index 360fce052..d88f3f6cc 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
@@ -59,7 +59,7 @@ class ParamInfoTest extends SimpleTestBase {
return null;
if (t instanceof List)
return
((List<?>)t).stream().map(this).collect(Collectors.joining(","));
- if (t.getClass().isArray())
+ if (isArray(t))
return
StreamSupport.stream(ArrayUtils.toList(t, Object.class).spliterator(),
false).map(this).collect(Collectors.joining(","));
if (t instanceof MethodInfo)
return
((MethodInfo)t).getDeclaringClass().getSimpleName() + '.' +
((MethodInfo)t).getShortName();
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
b/juneau-utest/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
index 42c2f11e3..52706377e 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
@@ -12,6 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.xml;
+import static org.apache.juneau.common.internal.Utils.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.function.*;
@@ -39,7 +40,7 @@ class XmlConfigAnnotationTest extends SimpleTestBase {
private static final Function<Object,String> TO_STRING = t -> {
if (t == null)
return null;
- if (t.getClass().isArray())
+ if (isArray(t))
return
XmlConfigAnnotationTest.TO_STRING.apply(ArrayUtils.toList(t, Object.class));
if (t instanceof AA)
return "AA";