sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1736920 - /sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
Date Mon, 28 Mar 2016 19:53:36 GMT
Author: desruisseaux
Date: Mon Mar 28 19:53:35 2016
New Revision: 1736920

URL: http://svn.apache.org/viewvc?rev=1736920&view=rev
Log:
If a test resource is not found in the package of the sublcass, search up in the hierarchy
of classes.
The intend is to allow diffent module to reuse an existing test in another package. 

Modified:
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java?rev=1736920&r1=1736919&r2=1736920&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] Mon Mar 28 19:53:35 2016
@@ -161,15 +161,22 @@ public abstract strictfp class XMLTestCa
 
     /**
      * Returns the URL to the XML file of the given name.
-     * The file shall be in the same package than the final subclass of {@code this}.
+     * The file shall be in the same package than a subclass of {@code this}.
+     * This method begins the search in the package of {@link #getClass()}.
+     * If the resource is not found in that package, then this method searches in the parent
classes.
+     * The intend is to allow some test classes to be overridden in different modules.
      *
      * @param  filename The name of the XML file.
      * @return The URL to the given XML file.
      */
     private URL getResource(final String filename) {
-        final URL resource = getClass().getResource(filename);
-        assertNotNull(filename, resource);
-        return resource;
+        Class<?> c = getClass();
+        do {
+            final URL resource = c.getResource(filename);
+            if (resource != null) return resource;
+            c = c.getSuperclass();
+        } while (!c.equals(XMLTestCase.class));
+        throw new AssertionError("Test resource not found: " + filename);
     }
 
     /**



Mime
View raw message