Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public String getPrefix(final String namespaceUri) {

@Override
public Iterator<String> getPrefixes(final String namespaceUri) {
return Collections.<String>emptyList().iterator();
return Collections.emptyIterator();
}
};
xpath.setNamespaceContext(context);
Expand Down
Loading