diff --git a/src/test/java/org/apache/commons/xml/secure/SecureValidatorHandlerTest.java b/src/test/java/org/apache/commons/xml/secure/SecureValidatorHandlerTest.java index 6908de5..14ba989 100644 --- a/src/test/java/org/apache/commons/xml/secure/SecureValidatorHandlerTest.java +++ b/src/test/java/org/apache/commons/xml/secure/SecureValidatorHandlerTest.java @@ -18,6 +18,7 @@ package org.apache.commons.xml.secure; 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; @@ -270,7 +271,8 @@ void constructorInstallsFloorOnDelegate() throws Exception { final SecureValidatorHandler handler = new SecureValidatorHandler(delegate); // The constructor must install the ignore-all floor on the delegate assertNotNull(delegate.getResourceResolver(), "delegate resource resolver must be set to the floor"); - assertTrue(delegate.getResourceResolver() instanceof FallbackIgnoreLSResourceResolver, "delegate resolver must be a FallbackIgnoreLSResourceResolver"); + assertInstanceOf(FallbackIgnoreLSResourceResolver.class, delegate.getResourceResolver(), + "delegate resolver must be a FallbackIgnoreLSResourceResolver"); // getResourceResolver on the wrapper returns the floor's delegate, which is null initially assertNull(handler.getResourceResolver()); } diff --git a/src/test/java/org/apache/commons/xml/secure/SecureXMLInputFactoryTest.java b/src/test/java/org/apache/commons/xml/secure/SecureXMLInputFactoryTest.java index ea6703b..cd45394 100644 --- a/src/test/java/org/apache/commons/xml/secure/SecureXMLInputFactoryTest.java +++ b/src/test/java/org/apache/commons/xml/secure/SecureXMLInputFactoryTest.java @@ -19,6 +19,7 @@ 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; @@ -454,7 +455,8 @@ void setPropertyWrapsCallerWhenHookIsNotAFloor() { for (final Object foreign : new Object[] { null, (XMLResolver) (publicID, systemID, baseURI, namespace) -> "foreign" }) { fake.setProperty(XMLInputFactory.RESOLVER, foreign); secure.setProperty(XMLInputFactory.RESOLVER, caller); - assertTrue(fake.resolverHook instanceof FallbackIgnoreXMLResolver, "a caller resolver must land behind a floor"); + assertInstanceOf(FallbackIgnoreXMLResolver.class, fake.resolverHook, + "a caller resolver must land behind a floor"); assertSame(caller, ((FallbackIgnoreXMLResolver) fake.resolverHook).getDelegate(), "the floor must delegate to the caller's resolver"); assertSame(caller, secure.getXMLResolver(), "getXMLResolver must report the caller's resolver unwrapped"); } @@ -509,7 +511,8 @@ void setXMLResolverRoutesCallerBehindInstalledFloor() { secure.setXMLResolver(caller); // The hook keeps a floor with the caller behind it; whether that is the floor already there or a fresh one is the subject of // settingAResolverInstallsAFreshFloorInsteadOfMutatingTheInstalledOne. - assertTrue(fake.resolverHook instanceof FallbackIgnoreXMLResolver, "a caller resolver must land behind a floor, not replace it on the delegate's hook"); + assertInstanceOf(FallbackIgnoreXMLResolver.class, fake.resolverHook, + "a caller resolver must land behind a floor, not replace it on the delegate's hook"); assertSame(caller, ((FallbackIgnoreXMLResolver) fake.resolverHook).getDelegate(), "the caller's resolver must be the floor's delegate"); assertSame(caller, secure.getXMLResolver(), "getXMLResolver must report the caller's resolver unwrapped"); assertSame(caller, secure.getProperty(XMLInputFactory.RESOLVER), "getProperty must report the caller's resolver unwrapped"); @@ -645,7 +648,8 @@ void wrapperInstallsFloorOnDelegateHook() { assertNotNull(secure); assertTrue(fake.calls.contains(RecordingXMLInputFactory.call("setXMLResolver", fake.resolverHook)), "the floor must be installed through the delegate's setXMLResolver"); - assertTrue(fake.resolverHook instanceof FallbackIgnoreXMLResolver, "the constructor must install the ignore-all floor on the delegate's resolver hook"); + assertInstanceOf(FallbackIgnoreXMLResolver.class, fake.resolverHook, + "the constructor must install the ignore-all floor on the delegate's resolver hook"); assertNull(((FallbackIgnoreXMLResolver) fake.resolverHook).getDelegate(), "the installed floor must have no caller delegate"); } } diff --git a/src/test/java/org/apache/commons/xml/secure/SecureXPathTest.java b/src/test/java/org/apache/commons/xml/secure/SecureXPathTest.java index a73a420..a5ee68b 100644 --- a/src/test/java/org/apache/commons/xml/secure/SecureXPathTest.java +++ b/src/test/java/org/apache/commons/xml/secure/SecureXPathTest.java @@ -61,7 +61,7 @@ public String getPrefix(final String namespaceUri) { @Override public Iterator getPrefixes(final String namespaceUri) { - return Collections.emptyList().iterator(); + return Collections.emptyIterator(); } }; xpath.setNamespaceContext(context);