Adam Lally wrote:
They are used not only in uimaj-core but also in other projects like
uimaj-cpe.  So I think these need to be in a separate project that can
be a dependency of both.

If they are added to uimaj-core/src/main/java, they will end up in
uima-core.jar, which I don't think we want.  If they are added to
uimaj-core/src/test/java, then uimaj-core's unit tests will work but
uimaj-cpe's will not (uimaj-cpe can't refer to test case code inside
uimaj-core).

However, it's worth considering if we need these classes at all.  As
noted in http://issues.apache.org/jira/browse/UIMA-45 the
TestPropertyReader.getJUnitBasePath() method is currently hacked up to
allow locating resource files in the classpath.  It might be better to
scrap this and update all the unit tests to do ClassLoader lookups
themselves.
I see, but I think we still need some helper classes for for the current tests. I also think when using the class loader to find resources this should be externalized to a helper class so that the tests could easy access the resources. Another sample is the file compare helper class or the JUnit exception printer stuff that is used in some of the tests. So my suggestion is to keep the uimaj-test-util project but fix and redesign some of the methods to use class loading to find resources. For example replace the JUnitExtension.getFile() method with the code below to load the resources using the class loader.

public static File getFile(String aRelativeFilePath) {
URL url = JUnitExtension.class.getClassLoader().getResource(aRelativeFilePath);
   File file = null;
   if(url != null) {
     file = new File(url.getFile());
   }
   return file;
 }

Rewrite all other tests that currently do not use this way to use it. So the only open item are tests that just creates temp files using the JUnitBasePath. For these we can use the Java temp file mechanism and specify a working directory where the file should be created. The working directory could be a parent directory form on of the loaded
file resources already used in the test.

To create my sandbox test helper classes I will use another project called uimaj-component-test-util. This project will depend on uimaj-core.

-- Michael


Reply via email to