[java-metadata-aggregator] branch master updated: MDA-219 - Remove Resource.exists check in initialization
Ian Young
ian at iay.org.uk
Thu May 21 09:57:27 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=c69f1c301949320c120ad98b6c571234c055b1dd
The following commit(s) were added to refs/heads/master by this push:
new c69f1c3 MDA-219 - Remove Resource.exists check in initialization
c69f1c3 is described below
commit c69f1c301949320c120ad98b6c571234c055b1dd
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu May 21 10:57:23 2020 +0100
MDA-219 - Remove Resource.exists check in initialization
https://issues.shibboleth.net/jira/browse/MDA-219
---
.../metadata/dom/DOMResourceSourceStage.java | 7 +--
.../metadata/dom/DOMResourceSourceStageTest.java | 50 ++++++++++++++++++----
2 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java
index b8aa204..c9b2506 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java
@@ -196,11 +196,6 @@ public class DOMResourceSourceStage extends AbstractStage<Element> {
throw new ComponentInitializationException("Unable to initialize " + getId()
+ ", either a DomResource must be specified");
}
-
- if (!domResource.exists()) {
- throw new ComponentInitializationException("Unable to initialize " + getId() + ", DOM resource "
- + domResource.getDescription() + " does not exist");
- }
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMResourceSourceStageTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMResourceSourceStageTest.java
index 2737b0e..c4fdef7 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMResourceSourceStageTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMResourceSourceStageTest.java
@@ -31,12 +31,16 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
+import net.shibboleth.metadata.BaseTest;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.StageProcessingException;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.xml.BasicParserPool;
-public class DOMResourceSourceStageTest {
+public class DOMResourceSourceStageTest extends BaseTest {
+
+ DOMResourceSourceStageTest() {
+ super(DOMResourceSourceStage.class);
+ }
BasicParserPool parserPool;
@@ -85,18 +89,24 @@ public class DOMResourceSourceStageTest {
}
@Test public void testFailedFetch() throws Exception {
- Resource mdResource = new UrlResource("http://kslkjf.com/lkjlk3.dlw");
+ final var collection = new ArrayList<Item<Element>>();
+ final var mdResource = new UrlResource("http://kslkjf.com/lkjlk3.dlw");
- DOMResourceSourceStage source = new DOMResourceSourceStage();
+ final var source = new DOMResourceSourceStage();
source.setId("test");
source.setDOMResource(mdResource);
source.setParserPool(parserPool);
+ source.initialize();
try {
- source.initialize();
+ source.execute(collection);
Assert.fail();
- } catch (ComponentInitializationException e) {
- // expected this
+ } catch (final StageProcessingException e) {
+ 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");
}
}
@@ -127,4 +137,28 @@ public class DOMResourceSourceStageTest {
Assert.assertNotNull(metadataCollection);
Assert.assertEquals(metadataCollection.size(), 0);
}
-}
\ No newline at end of file
+
+ @Test
+ public void mda219() throws Exception {
+ final var stage = new DOMResourceSourceStage();
+ final var resource = getClasspathResource("does-not-exist.xml");
+ final var collection = new ArrayList<Item<Element>>();
+ stage.setId("test");
+ stage.setParserPool(parserPool);
+ stage.setDOMResource(resource);
+ // Pre-MDA-219, this will throw an exception
+ stage.initialize();
+
+ // Post-MDA-219, we expect a wrapped IOException when we execute the stage.
+ try {
+ stage.execute(collection);
+ Assert.fail("expected exception");
+ } catch (final StageProcessingException e) {
+ 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