Skip to content
Snippets Groups Projects
Commit 9dfd5bc4 authored by tpylak's avatar tpylak
Browse files

minor: test method to print available readers

SVN: 21088
parent 9fdf5367
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,10 @@ import java.util.Map; ...@@ -25,6 +25,10 @@ import java.util.Map;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import ch.systemsx.cisd.common.shared.basic.utils.StringUtils; import ch.systemsx.cisd.common.shared.basic.utils.StringUtils;
import ch.systemsx.cisd.imagereaders.bioformats.BioFormatsReaderLibrary;
import ch.systemsx.cisd.imagereaders.ij.ImageJReaderLibrary;
import ch.systemsx.cisd.imagereaders.imageio.ImageIOReaderLibrary;
import ch.systemsx.cisd.imagereaders.jai.JAIReaderLibrary;
/** /**
* A class that facilitates unit testing with JDK 1.5. * A class that facilitates unit testing with JDK 1.5.
...@@ -36,13 +40,14 @@ public class ImageReadersTestHelper ...@@ -36,13 +40,14 @@ public class ImageReadersTestHelper
private static final String SERVICES_FILE_TEMPLATE = private static final String SERVICES_FILE_TEMPLATE =
"./resource/manifest/%s/META-INF/services/" + IImageReaderLibrary.class.getName(); "./resource/manifest/%s/META-INF/services/" + IImageReaderLibrary.class.getName();
// NOTE : we *cannot* put real classes/instances here, because we do not know if all // NOTE : we *cannot* put real classes/instances here, because we do not know if all
// libraries jar files will be on the classpath. // libraries jar files will be on the classpath.
private static final Map<String/* library name */, String /* library classname */> librariesByName = private static final Map<String/* library name */, String /* library classname */> librariesByName =
new HashMap<String, String>(); new HashMap<String, String>();
static { static
{
librariesByName.put(ImageReaderConstants.IMAGEIO_LIBRARY, librariesByName.put(ImageReaderConstants.IMAGEIO_LIBRARY,
"ch.systemsx.cisd.imagereaders.imageio.ImageIOReaderLibrary"); "ch.systemsx.cisd.imagereaders.imageio.ImageIOReaderLibrary");
librariesByName.put(ImageReaderConstants.IMAGEJ_LIBRARY, librariesByName.put(ImageReaderConstants.IMAGEJ_LIBRARY,
...@@ -82,7 +87,7 @@ public class ImageReadersTestHelper ...@@ -82,7 +87,7 @@ public class ImageReadersTestHelper
ImageReaderFactory.setLibraries(libs); ImageReaderFactory.setLibraries(libs);
} }
private static IImageReaderLibrary getLibraryFromMap(String library) throws Exception private static IImageReaderLibrary getLibraryFromMap(String library) throws Exception
{ {
String libClassName = librariesByName.get(library); String libClassName = librariesByName.get(library);
...@@ -92,7 +97,7 @@ public class ImageReadersTestHelper ...@@ -92,7 +97,7 @@ public class ImageReadersTestHelper
} }
return (IImageReaderLibrary) Class.forName(libClassName).newInstance(); return (IImageReaderLibrary) Class.forName(libClassName).newInstance();
} }
private static IImageReaderLibrary getLibraryFromManifest(String library) throws Exception private static IImageReaderLibrary getLibraryFromManifest(String library) throws Exception
{ {
String libClassName = readLibraryClassName(library); String libClassName = readLibraryClassName(library);
...@@ -113,8 +118,8 @@ public class ImageReadersTestHelper ...@@ -113,8 +118,8 @@ public class ImageReadersTestHelper
if (StringUtils.isBlank(fileContent)) if (StringUtils.isBlank(fileContent))
{ {
String error = String error =
String.format("Cannot read class name for library '%s' from '%s'", library, String.format("Cannot read class name for library '%s' from '%s'", library,
servicesFileName); servicesFileName);
throw new IllegalArgumentException(error); throw new IllegalArgumentException(error);
} }
...@@ -123,4 +128,17 @@ public class ImageReadersTestHelper ...@@ -123,4 +128,17 @@ public class ImageReadersTestHelper
return className; return className;
} }
public static void main(String[] args)
{
printReaders(new ImageJReaderLibrary());
printReaders(new ImageIOReaderLibrary());
printReaders(new JAIReaderLibrary());
printReaders(new BioFormatsReaderLibrary());
}
private static void printReaders(IImageReaderLibrary library)
{
System.out.println(library.getName() + ": " + library.getReaderNames());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment