[java-metadata-aggregator COMMIT] in /trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom: BaseDOMTes...

noreply at shibboleth.net noreply at shibboleth.net
Sun Oct 13 16:08:59 EDT 2013


Author: iay
Date: Sun Oct 13 16:08:59 2013
New Revision: 274

URL: http://svn.shibboleth.net/view/java-metadata-aggregator?rev=274&view=rev
Log:
MDA-82: refactor unit test data by class
Make this is a bit simpler by pulling up creation of a ClasspathResource named relative to the class under test.

Modified:
    trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDOMTest.java
    trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLValidationStageTest.java

Modified: trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDOMTest.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDOMTest.java?rev=274&r1=273&r2=274&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDOMTest.java (original)
+++ trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDOMTest.java Sun Oct 13 16:08:59 2013
@@ -114,6 +114,18 @@
     }
     
     /**
+     * Return a {@link ClasspathResource} named relative to the currently tested class.
+     * 
+     * @param relativeName local name of the resource
+     * @return resolved {@link ClasspathResource} with the given name
+     */
+    protected Resource classRelativeClasspathResource(final String relativeName) {
+        // ClasspathResource needs a path that does *not* start with a '/'
+        return new ClasspathResource(classRelativeResource(relativeName).substring(1));
+    }
+
+    
+    /**
      * Setup test class. Creates and initializes the parser pool. Set BouncyCastle as a JCE provider.
      * 
      * @throws ComponentInitializationException thrown if there is a problem initializing the parser pool

Modified: trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLValidationStageTest.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLValidationStageTest.java?rev=274&r1=273&r2=274&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLValidationStageTest.java (original)
+++ trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/XSLValidationStageTest.java Sun Oct 13 16:08:59 2013
@@ -25,7 +25,6 @@
 import net.shibboleth.metadata.InfoStatus;
 import net.shibboleth.metadata.ItemMetadata;
 import net.shibboleth.metadata.WarningStatus;
-import net.shibboleth.utilities.java.support.resource.ClasspathResource;
 import net.shibboleth.utilities.java.support.resource.Resource;
 import net.shibboleth.utilities.java.support.xml.XMLParserException;
 
@@ -64,8 +63,7 @@
         final List<DOMElementItem> mdCol = new ArrayList<>();
         mdCol.add(makeInput());
 
-        final Resource transform =
-                new ClasspathResource(classRelativeResource("validator.xsl").substring(1));
+        final Resource transform = classRelativeClasspathResource("validator.xsl");
 
         final XSLValidationStage stage = new XSLValidationStage();
         stage.setId("test");
@@ -113,8 +111,7 @@
         final List<DOMElementItem> mdCol = new ArrayList<>();
         mdCol.add(makeInput());
 
-        final Resource transform =
-                new ClasspathResource(classRelativeResource("mda45.xsl").substring(1));
+        final Resource transform = classRelativeClasspathResource("mda45.xsl");
 
         final XSLValidationStage stage = new XSLValidationStage();
         stage.setId("test");



More information about the commits mailing list