[java-metadata-aggregator] branch master updated: MDA-219 - Remove two redundant Resource.exists checks
Ian Young
ian at iay.org.uk
Thu May 21 09:36:44 UTC 2020
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=9b9632ca65633f03eeddd52b6ec91991c3a0d86c
The following commit(s) were added to refs/heads/master by this push:
new 9b9632c MDA-219 - Remove two redundant Resource.exists checks
9b9632c is described below
commit 9b9632ca65633f03eeddd52b6ec91991c3a0d86c
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu May 21 10:36:01 2020 +0100
MDA-219 - Remove two redundant Resource.exists checks
https://issues.shibboleth.net/jira/browse/MDA-219
---
.../metadata/dom/AbstractXSLProcessingStage.java | 5 -----
.../x509/X509RSAOpenSSLBlacklistValidator.java | 5 -----
.../metadata/dom/XSLTtransformationStageTest.java | 23 +++++++++++++++++++++-
.../x509/X509RSAOpenSSLBlacklistValidatorTest.java | 21 ++++++++++++++++++++
4 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
index 9b09dd8..4adadcd 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
@@ -253,11 +253,6 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
}
try {
- if (!xslResource.exists()) {
- throw new ComponentInitializationException("Unable to initialize " + getId() + ", XslResource "
- + xslResource.getDescription() + " does not exist");
- }
-
final TransformerFactory tfactory = TransformerFactory.newInstance();
for (final Entry<String, Object> attribute : transformAttributes.entrySet()) {
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java
index 6ed6580..82d6b83 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java
@@ -193,11 +193,6 @@ public class X509RSAOpenSSLBlacklistValidator extends AbstractX509Validator {
+ ", blacklistResource must not be null");
}
- if (!blacklistResource.exists()) {
- throw new ComponentInitializationException("Unable to initialize " + getId() + ", blacklistResource "
- + blacklistResource.getDescription() + " does not exist");
- }
-
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(blacklistResource.getInputStream()))) {
while (true) {
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLTtransformationStageTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLTtransformationStageTest.java
index 9c86fcc..bf18847 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLTtransformationStageTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLTtransformationStageTest.java
@@ -36,6 +36,7 @@ import net.shibboleth.metadata.InfoStatus;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemMetadata;
import net.shibboleth.metadata.WarningStatus;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.xml.XMLParserException;
import org.springframework.core.io.Resource;
@@ -297,4 +298,24 @@ public class XSLTtransformationStageTest extends BaseDOMTest {
final Element expected = readXMLData("output2.xml");
assertXMLIdentical(expected, result.unwrap());
}
-}
\ No newline at end of file
+
+ @Test
+ public void mda219() throws Exception {
+ final var resource = getClasspathResource("does-not-exist.txt");
+ final var stage = new XSLTransformationStage();
+ stage.setId("test");
+ stage.setXSLResource(resource);
+ try {
+ stage.initialize();
+ Assert.fail("expected exception");
+ } catch (final ComponentInitializationException e) {
+ // After MDA-219, we expect to see a cause which is an IOException.
+ final var cause = e.getCause();
+ // System.out.println("Message: " + e.getMessage());
+ // System.out.println("Cause: " + cause);
+ Assert.assertNotNull(cause, "exception had no cause");
+ Assert.assertTrue(cause instanceof IOException, "cause should have been an IOException");
+ }
+ }
+
+}
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidatorTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidatorTest.java
index 2a07ddf..e118c38 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidatorTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidatorTest.java
@@ -18,6 +18,7 @@
package net.shibboleth.metadata.validate.x509;
+import java.io.IOException;
import java.security.cert.X509Certificate;
import org.testng.Assert;
@@ -26,6 +27,7 @@ import org.testng.annotations.Test;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.MockItem;
import net.shibboleth.metadata.validate.Validator;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
public class X509RSAOpenSSLBlacklistValidatorTest extends BaseX509ValidatorTest {
@@ -159,4 +161,23 @@ public class X509RSAOpenSSLBlacklistValidatorTest extends BaseX509ValidatorTest
// do not initialize
Assert.assertNull(val.getId(), "unset ID should be null");
}
+
+ @Test
+ public void mda219() throws Exception {
+ final var val = new X509RSAOpenSSLBlacklistValidator();
+ final var resource = getClasspathResource("does-not-exist.txt");
+ val.setId("test");
+ val.setBlacklistResource(resource);
+ try {
+ val.initialize();
+ Assert.fail("expected exception");
+ } catch (final ComponentInitializationException e) {
+ // After MDA-219, we expect to see a cause which is an IOException.
+ final var cause = e.getCause();
+ // System.out.println("Message: " + e.getMessage());
+ // System.out.println("Cause: " + cause);
+ Assert.assertNotNull(cause, "exception had no cause");
+ Assert.assertTrue(cause instanceof IOException, "cause should have been an IOException");
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list