Package org.anchoranalysis.test.image
Class DualComparer
Object
DualComparer
Allows for comparison of objects that exist on different test loaders
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionDualComparer
(TestLoader loader1, TestLoader loader2) Creates a new DualComparer instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
compareTwoBinaryFiles
(String path) Compare two binary-files.boolean
compareTwoCsvFiles
(String path, CSVComparer comparer, PrintStream messageStream) Compare two CSV files using a specified comparer.boolean
compareTwoImages
(String path) Compare two images that have an identical path, but in two different test loaders.boolean
compareTwoImages
(String path1, String path2, boolean ignoreResolutionDifferences) Compare two images with different paths, but in two different test loaders.boolean
Compare two object-mask-collections.boolean
Compare two subdirectories that have an identical path, but in two different test loaders.boolean
compareTwoXmlDocuments
(String path) Compare two XML documents.void
copyFromPath1ToPath2
(String path) Copies a file from its path in the first loader, to its path in the second loader.The first loader.The second loader.
-
Constructor Details
-
DualComparer
Creates a new DualComparer instance.- Parameters:
loader1
- the first TestLoaderloader2
- the second TestLoader
-
-
Method Details
-
compareTwoImages
Compare two images that have an identical path, but in two different test loaders.- Parameters:
path
- relative-path (compared to root of both loaders) of files to compare.- Returns:
- true when the images are equal (every pixel is identical, and data-types are the same).
- Throws:
FileNotFoundException
- if one or both of the files cannot be found.
-
compareTwoImages
public boolean compareTwoImages(String path1, String path2, boolean ignoreResolutionDifferences) throws FileNotFoundException Compare two images with different paths, but in two different test loaders.- Parameters:
path1
- relative-path (compared to root of first loader) of first image.path2
- relative-path (compared to root of second loader) of second image.ignoreResolutionDifferences
- if true any differences in image-resolution are not considered.- Returns:
- true when the images are equal (every pixel is identical, and data-types are the same), false otherwise.
- Throws:
FileNotFoundException
- if one or both of the files cannot be found.
-
compareTwoXmlDocuments
Compare two XML documents. They are compared by their DOM trees, but they need to be identical for equality.- Parameters:
path
- relative-path (compared to root of both loaders) of files to compare- Returns:
- true when the xml-documents are equal, false otherwise.
-
compareTwoCsvFiles
public boolean compareTwoCsvFiles(String path, CSVComparer comparer, PrintStream messageStream) throws CSVReaderException Compare two CSV files using a specified comparer.- Parameters:
path
- relative-path (compared to root of both loaders) of files to compare.comparer
- the CSVComparer to use for comparing the CSV files.messageStream
- if non-equal, additional explanation messages are printed here.- Returns:
- true when the csv-files are identical according to the comparer, false otherwise.
- Throws:
CSVReaderException
- if something goes wrong with csv I/O or a csv file is rejected.
-
compareTwoObjectCollections
Compare two object-mask-collections.- Parameters:
path
- relative-path (compared to root of both loaders) of files to compare.- Returns:
- true if both paths return object-collections that are voxelwise identical.
- Throws:
IOException
- if something goes wrong with I/O.
-
compareTwoBinaryFiles
Compare two binary-files.- Parameters:
path
- relative-path (compared to root of both loaders) of files to compare.- Returns:
- true if both paths have binary-files that are bytewise identical.
- Throws:
IOException
- if something goes wrong with I/O.
-
compareTwoSubdirectories
Compare two subdirectories that have an identical path, but in two different test loaders.- Parameters:
path
- relative-path (compared to root of both loaders) of subdirectories to compare.- Returns:
- true when the subdirectories are equal (contain the same files and directories), false otherwise.
-
copyFromPath1ToPath2
Copies a file from its path in the first loader, to its path in the second loader.Any existing file is replaced.
- Parameters:
path
- relative-path (compared to root of both loaders) of files to copy.- Throws:
IOException
- if copying fails.
-
getLoader1
The first loader. -
getLoader2
The second loader.
-