I'm trying to migrate from Solr 4.6 to Solr 4.10, but after replacing the
4.6 jars with the 4.10 jars all my unit tests have failed with the
following Runtime Exception:

Resource was found on classpath, but cannot be resolved to a normal file
(maybe it is part of a JAR file): solr/collection1

When comparing the 4.6 SolrTestCaseJ4.java to the 4.10 SolrTestCaseJ4.java
I have found that:

1. Both define a TEST_HOME() method that calls a getFile() method with the
hard-coded String "solr/collection1" as input:
    public static String TEST_HOME() {
       return getFile("solr/collection1").getParent();
    }

2. In Solr 4.6, the test framework implements the above getFile() method by
initializing a File with "solr/collection1" as its path:
    public static File getFile(String name) {
      ...
      File file = new File(name);
      ...
    }

3. In Solr 4.10, on the contrary, the test framework first corrupts the
"solr/collection1" path and then tries unsuccessfully to initialize a new
File with the corrupt path (Of course, I'm the one who's doing something
wrong here, not the test framework. I'm just describing the chain of events
that's leading to the Runtime Exception):
    public static File getFile(String name) {
      final URL url =
Thread.currentThread().getContextClassLoader().getResource(name);
      ...
      return new File(url.toURI);
      ...
    }
The above setting of the local variable URL url results in the following
illegal path as the value of url:

jar:file:/C:/solr-4.10.3/solr-4.10.3/dist/solr-uima-4.10.3.jar!/solr/collection1

Trying to initialize a new File with such a path results in an Illegal
Argument Exception saying the URI is not hierarchical, which in turn leads
to the throwing of the "resource cannot be resolved to a normal file"
Runtime Exception.

Why does the test framework in Solr 4.10 generate that odd URL? How can I
force it to set the URL properly so it can execute my tests without
encountering the Runtime Exception?

Reply via email to