[java-metadata-aggregator COMMIT] in /trunk/aggregator-pipeline/src/test: java/net/shibboleth/metadata/dom/XMLSchemaV...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Nov 29 12:17:29 EST 2013
Author: iay
Date: Fri Nov 29 12:17:29 2013
New Revision: 303
URL: http://svn.shibboleth.net/view/java-metadata-aggregator?rev=303&view=rev
Log:
MDA-82: refactor unit test data by class
This one's a first bite at the cherry because as Rod noticed this class is still using Shibboleth resources, not Spring ones.
Added:
trunk/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/XMLSchemaValidationStage-invalid.xml
- copied unchanged from r296, trunk/aggregator-pipeline/src/test/resources/data/xmlSchemaValidationStageInvalidInput.xml
trunk/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/XMLSchemaValidationStage-schema.xsd
- copied unchanged from r296, trunk/aggregator-pipeline/src/test/resources/data/xmlSchemaValidationStage.xsd
trunk/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/XMLSchemaValidationStage-valid.xml
- copied unchanged from r296, trunk/aggregator-pipeline/src/test/resources/data/xmlSchemaValidationStageValidInput.xml
Modified:
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XMLSchemaValidationStageTest.java
trunk/aggregator-pipeline/src/test/resources/data/xmlSchemaValidationStage.xsd
trunk/aggregator-pipeline/src/test/resources/data/xmlSchemaValidationStageInvalidInput.xml
trunk/aggregator-pipeline/src/test/resources/data/xmlSchemaValidationStageValidInput.xml
Modified: trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XMLSchemaValidationStageTest.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XMLSchemaValidationStageTest.java?rev=303&r1=302&r2=303&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XMLSchemaValidationStageTest.java (original)
+++ trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XMLSchemaValidationStageTest.java Fri Nov 29 12:17:29 2013
@@ -26,28 +26,33 @@
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.resource.FilesystemResource;
import net.shibboleth.utilities.java.support.resource.Resource;
-import net.shibboleth.utilities.java.support.xml.BasicParserPool;
import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class XMLSchemaValidationStageTest {
+public class XMLSchemaValidationStageTest extends BaseDOMTest {
+
+ @BeforeClass
+ private void init() {
+ setTestingClass(XMLSchemaValidationStage.class);
+ }
@Test
public void testValidXml() throws Exception {
XMLSchemaValidationStage stage = buildStage();
- Collection<Item<Element>> mdCol = buildMetdataCollection("/data/xmlSchemaValidationStageValidInput.xml");
+ Collection<Item<Element>> mdCol = buildMetdataCollection("valid.xml");
stage.execute(mdCol);
Assert.assertEquals(mdCol.size(), 1);
+ Assert.assertFalse(mdCol.iterator().next().getItemMetadata().containsKey(ErrorStatus.class));
}
@Test
public void testInvalidXml() throws Exception {
XMLSchemaValidationStage stage = buildStage();
- Collection<Item<Element>> mdCol = buildMetdataCollection("/data/xmlSchemaValidationStageInvalidInput.xml");
+ Collection<Item<Element>> mdCol = buildMetdataCollection("invalid.xml");
stage.execute(mdCol);
Assert.assertEquals(mdCol.size(), 1);
Assert.assertTrue(mdCol.iterator().next().getItemMetadata().containsKey(ErrorStatus.class));
@@ -55,7 +60,7 @@
protected XMLSchemaValidationStage buildStage() throws Exception {
String schemaFile =
- new File(XMLSchemaValidationStageTest.class.getResource("/data/xmlSchemaValidationStage.xsd").toURI())
+ new File(getClasspathResource("schema.xsd").getURI())
.getAbsolutePath();
final List<Resource> schemaResources = new ArrayList<>();
schemaResources.add(new FilesystemResource(schemaFile));
@@ -69,13 +74,9 @@
}
protected Collection<Item<Element>> buildMetdataCollection(String xmlPath) throws Exception {
- BasicParserPool parserPool = new BasicParserPool();
- parserPool.initialize();
- Document doc = parserPool.parse(XMLSchemaValidationStageTest.class.getResourceAsStream(xmlPath));
-
+ final Element element = readXmlData(xmlPath);
final List<Item<Element>> mdCol = new ArrayList<>();
- mdCol.add(new DOMElementItem(doc.getDocumentElement()));
-
+ mdCol.add(new DOMElementItem(element));
return mdCol;
}
}
More information about the commits
mailing list