[java-metadata-aggregator COMMIT] in /trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata: BaseTest.java ...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Nov 29 10:49:53 EST 2013
Author: iay
Date: Fri Nov 29 10:49:52 2013
New Revision: 301
URL: http://svn.shibboleth.net/view/java-metadata-aggregator?rev=301&view=rev
Log:
MDA-82 unit test refactoring: pull in the refactoring done in ukf-mda
This will allow non-DOM tests to use class-relative resources.
Added:
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/BaseTest.java (with props)
Modified:
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDOMTest.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=301&r1=300&r2=301&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 Fri Nov 29 10:49:52 2013
@@ -20,6 +20,7 @@
import java.io.InputStream;
import java.security.Security;
+import net.shibboleth.metadata.BaseTest;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -30,93 +31,16 @@
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
import org.testng.annotations.BeforeClass;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/** A base class for DOM related tests. */
-public abstract class BaseDOMTest {
+public abstract class BaseDOMTest extends BaseTest {
/** Initialized parser pool used to parser data. */
private BasicParserPool parserPool;
- /** Class being tested. */
- private Class<?> testingClass;
-
- /**
- * Base path for class-relative test resource references.
- *
- * Will <em>not<em> end in a '/'.
- */
- private String baseClassPath;
-
- /** Package for the class being tested. */
- private Package testingPackage;
-
- /**
- * Base path for package-relative test resource references.
- *
- * Will always end in a '/'.
- */
- private String basePackagePath;
-
- /**
- * Converts the "."-separated name of a class or package into an
- * absolute path.
- *
- * @param name name to be converted
- * @return path to resources associated with the name
- */
- private String nameToPath(final String name) {
- return "/" + name.replace('.', '/');
- }
-
- /**
- * Sets the class being tested, so that references can be made to testing resources
- * relative to it.
- *
- * @param clazz class being tested
- */
- protected void setTestingClass(final Class<?> clazz) {
- testingClass = clazz;
- baseClassPath = nameToPath(testingClass.getName());
- testingPackage = testingClass.getPackage();
- basePackagePath = nameToPath(testingPackage.getName()) + "/";
- }
-
- /**
- * Makes a resource reference relative to the class being tested.
- *
- * The convention adopted is that the class-relative name is something
- * like "foo.pem", and that this is expanded to "/a/b/c/Bar-foo.pem".
- *
- * @param which class-relative resource name
- * @return absolute resource name
- */
- protected String classRelativeResource(final String which) {
- return baseClassPath + "-" + which;
- }
-
- protected String simpleClassRelativeName(final String which) {
- return testingClass.getSimpleName() + "-" + which;
- }
-
- /**
- * Makes a resource reference relative to the package of the class being tested.
- *
- * The convention adopted is that the package-relative name is something
- * like "foo.pem", and that this is expanded to "/a/b/c/foo.pem".
- *
- * @param which package-relative resource name
- * @return absolute resource name
- */
- protected String packageRelativeResource(final String which) {
- return basePackagePath + which;
- }
-
-
/**
* Setup test class. Creates and initializes the parser pool. Set BouncyCastle as a JCE provider.
*
@@ -139,22 +63,6 @@
*/
public ParserPool getParserPool() {
return parserPool;
- }
-
- /**
- * Helper method to acquire a ClasspathResource based on the given resource path.
- *
- * Uses class-relative resource names if there is a known class under test.
- *
- * @param resourcePath classpath path to the resource
- * @return the data file as a resource
- */
- public Resource getClasspathResource(final String resourcePath) {
- if (testingClass != null) {
[... 8 lines stripped ...]
More information about the commits
mailing list