Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
9dfd5bc4
Commit
9dfd5bc4
authored
13 years ago
by
tpylak
Browse files
Options
Downloads
Patches
Plain Diff
minor: test method to print available readers
SVN: 21088
parent
9fdf5367
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
image_readers/sourceTest/java/ch/systemsx/cisd/imagereaders/ImageReadersTestHelper.java
+25
-7
25 additions, 7 deletions
...ch/systemsx/cisd/imagereaders/ImageReadersTestHelper.java
with
25 additions
and
7 deletions
image_readers/sourceTest/java/ch/systemsx/cisd/imagereaders/ImageReadersTestHelper.java
+
25
−
7
View file @
9dfd5bc4
...
@@ -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
());
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment