Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout jp24u repository
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Install GraphicsMagick and Kakadu
run: sudo apt install graphicsmagick

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build jp24u with Maven
run: mvn -B -U clean install
29 changes: 20 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
<maven.compiler.target>11</maven.compiler.target>
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<junit.platform.version>1.9.1</junit.platform.version>
<metadata-extractor.version>2.18.0</metadata-extractor.version>
<commons-io.version>2.5</commons-io.version>
<info.picocli.version>4.6.1</info.picocli.version>
<log4j-to-slf4j.version>2.17.1</log4j-to-slf4j.version>
<slf4j-api.version>2.0.3</slf4j-api.version>
<slf4j-simple.version>2.0.3</slf4j-simple.version>
<maven-shade-plugin.version>3.2.1</maven-shade-plugin.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
</properties>

<dependencies>
Expand All @@ -31,32 +41,32 @@
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.18.0</version>
<version>${metadata-extractor.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.6.1</version>
<version>${info.picocli.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.17.1</version>
<version>${log4j-to-slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.3</version>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.3</version>
<version>${slf4j-simple.version}</version>
</dependency>
</dependencies>
<build>
Expand All @@ -65,6 +75,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -93,12 +104,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>9</source>
<target>9</target>
Expand All @@ -107,7 +118,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,41 @@ public void setup() throws Exception {
service = new ColorFieldsService();
}

// if all the tests stop passing, you probably just need to update the FILE_MODIFIED_DATE and FileModifiedDate
// FILE_MODIFIED_DATE and FileModifiedDate tend to change when rerunning tests,
// so I avoided giving them actual values
@Test
public void testColorFields() throws Exception {
String testFile = "src/test/resources/E101_F8_0112.tif";

Map<String, String> testFields = new LinkedHashMap<>();
testFields.put(ColorFieldsService.IMAGE_FILE_NAME, "src/test/resources/E101_F8_0112.tif");
testFields.put(ColorFieldsService.FILE_SIZE, "57001526 bytes");
testFields.put(ColorFieldsService.FILE_MODIFIED_DATE, "Thu May 18 17:00:05 -04:00 2023");
testFields.put(ColorFieldsService.DATE_TIME_ORIGINAL, "2021:08:30 19:56:48");
testFields.put(ColorFieldsService.DATE_TIME_DIGITIZED, "2021:08:30 19:56:48");
testFields.put(ColorFieldsService.ICC_PROFILE_NAME, "Adobe RGB (1998)");
testFields.put(ColorFieldsService.COLOR_SPACE, "RGB");
testFields.put(ColorFieldsService.INTEROP_INDEX, "Unknown (R03)");
testFields.put(ColorFieldsService.PHOTOMETRIC_INTERPRETATION, "RGB");

Map<String, String> fields = service.colorFields(testFile);
assertEquals(testFields, fields);

assertTrue(fields.containsValue(testFile));
assertTrue(fields.containsValue("57001526 bytes"));
assertTrue(fields.containsKey(ColorFieldsService.FILE_MODIFIED_DATE));
assertTrue(fields.containsValue("2021:08:30 19:56:48"));
assertTrue(fields.containsValue("2021:08:30 19:56:48"));
assertTrue(fields.containsValue("Adobe RGB (1998)"));
assertTrue(fields.containsValue("RGB"));
assertTrue(fields.containsValue("Unknown (R03)"));
assertTrue(fields.containsValue("RGB"));
}

@Test
public void testMissingColorFields() throws Exception {
String testFile = "src/test/resources/P0024_0066.tif";

// PhotometricInterpretation is never missing
Map<String,String> testFields = new LinkedHashMap<>();
testFields.put(ColorFieldsService.IMAGE_FILE_NAME, testFile);
testFields.put(ColorFieldsService.FILE_SIZE, "40736840 bytes");
testFields.put(ColorFieldsService.FILE_MODIFIED_DATE, "Thu May 18 17:00:05 -04:00 2023");
testFields.put(ColorFieldsService.DATE_TIME_ORIGINAL, null);
testFields.put(ColorFieldsService.DATE_TIME_DIGITIZED, "2013:06:25 14:51:58");
testFields.put(ColorFieldsService.ICC_PROFILE_NAME, null);
testFields.put(ColorFieldsService.COLOR_SPACE, null);
testFields.put(ColorFieldsService.INTEROP_INDEX, null);
testFields.put(ColorFieldsService.PHOTOMETRIC_INTERPRETATION, "BlackIsZero");

Map<String, String> fields = service.colorFields(testFile);
assertEquals(testFields, fields);

assertTrue(fields.containsValue(testFile));
assertTrue(fields.containsValue("40736840 bytes"));
assertTrue(fields.containsKey(ColorFieldsService.FILE_MODIFIED_DATE));
assertTrue(fields.containsValue(null));
assertTrue(fields.containsValue("2013:06:25 14:51:58"));
assertTrue(fields.containsValue(null));
assertTrue(fields.containsValue(null));
assertTrue(fields.containsValue(null));
assertTrue(fields.containsValue("BlackIsZero"));
}

@Test
Expand All @@ -78,13 +75,13 @@ public void testAllFields() throws Exception {
String testFile = "src/test/resources/P0024_0066.tif";

service.listFields(testFile);
String testOutput = "ImageFileName:src/test/resources/P0024_0066.tif\tFileSize:40736840 bytes\t" +
"FileModifiedDate:Thu May 18 17:00:05 -04:00 2023\tDateTimeOriginal:null\t" +
assertTrue(outputStreamCaptor.toString().contains("ImageFileName:src/test/resources/P0024_0066.tif\t" +
"FileSize:40736840 bytes\t"));
assertTrue(outputStreamCaptor.toString().contains("DateTimeOriginal:null\t" +
"DateTimeDigitized:2013:06:25 14:51:58\tICCProfileName:null\tColorSpace:null\t" +
"InteropIndex:null\tPhotometricInterpretation:BlackIsZero\tMagickIdentify:\"Dimensions: 5300x3841;" +
"Channels: gray;Bit-depth: 16;Alpha channel: False;Color Space: Gray;Profiles: 8bim,xmp;" +
"ICC Profile: ;ICM Profile: ;\"\t\n";
assertTrue(outputStreamCaptor.toString().contains(testOutput));
"ICC Profile: ;ICM Profile: ;\"\t\n"));
}

@Test
Expand All @@ -93,16 +90,18 @@ public void testListOfImportFiles() throws Exception {

service.fileListAllFields(testFile);
assertTrue(outputStreamCaptor.toString().contains("ImageFileName:src/test/resources/E101_F8_0112.tif\t" +
"FileSize:57001526 bytes\tFileModifiedDate:Thu May 18 17:00:05 -04:00 2023\t" +
"FileSize:57001526 bytes\t"));
assertTrue(outputStreamCaptor.toString().contains(
"DateTimeOriginal:2021:08:30 19:56:48\tDateTimeDigitized:2021:08:30 19:56:48\t" +
"ICCProfileName:Adobe RGB (1998)\tColorSpace:RGB\tInteropIndex:Unknown (R03)\t" +
"PhotometricInterpretation:RGB\tMagickIdentify:\"Dimensions: 2600x3650;Channels: srgb;" +
"Bit-depth: 16;Alpha channel: False;Color Space: sRGB;Profiles: icc,xmp;" +
"ICC Profile: Adobe RGB (1998);ICM Profile: ;Dimensions: 114x160;Channels: srgb;Bit-depth: 8;" +
"Alpha channel: False;Color Space: sRGB;Profiles: ;ICC Profile: ;ICM Profile: ;\"\t\n"));
assertTrue(outputStreamCaptor.toString().contains("ImageFileName:src/test/resources/P0024_0066.tif\t" +
"FileSize:40736840 bytes\tFileModifiedDate:Thu May 18 17:00:05 -04:00 2023\t" +
"DateTimeOriginal:null\tDateTimeDigitized:2013:06:25 14:51:58\t" +
"FileSize:40736840 bytes\t"));
assertTrue(outputStreamCaptor.toString().contains("DateTimeOriginal:null\t" +
"DateTimeDigitized:2013:06:25 14:51:58\t" +
"ICCProfileName:null\tColorSpace:null\tInteropIndex:null\tPhotometricInterpretation:BlackIsZero\t" +
"MagickIdentify:\"Dimensions: 5300x3841;Channels: gray;Bit-depth: 16;" +
"Alpha channel: False;Color Space: Gray;Profiles: 8bim,xmp;ICC Profile: ;ICM Profile: ;\"\t\n"));
Expand All @@ -119,7 +118,8 @@ public void testListOfImportFilesWithNonexistentFileFail() throws Exception {

service.fileListAllFields(testFile);
assertTrue(outputStreamCaptor.toString().contains("ImageFileName:src/test/resources/E101_F8_0112.tif\t" +
"FileSize:57001526 bytes\tFileModifiedDate:Thu May 18 17:00:05 -04:00 2023\t" +
"FileSize:57001526 bytes\t"));
assertTrue(outputStreamCaptor.toString().contains(
"DateTimeOriginal:2021:08:30 19:56:48\tDateTimeDigitized:2021:08:30 19:56:48\t" +
"ICCProfileName:Adobe RGB (1998)\tColorSpace:RGB\tInteropIndex:Unknown (R03)\t" +
"PhotometricInterpretation:RGB\tMagickIdentify:\"Dimensions: 2600x3650;Channels: srgb;" +
Expand All @@ -128,7 +128,8 @@ public void testListOfImportFilesWithNonexistentFileFail() throws Exception {
"Alpha channel: False;Color Space: sRGB;Profiles: ;ICC Profile: ;ICM Profile: ;\"\t\n"));
assertTrue(outputStreamCaptor.toString().contains("src/test/resources/test.tif does not exist."));
assertTrue(outputStreamCaptor.toString().contains("ImageFileName:src/test/resources/P0024_0066.tif\t" +
"FileSize:40736840 bytes\tFileModifiedDate:Thu May 18 17:00:05 -04:00 2023\t" +
"FileSize:40736840 bytes\t"));
assertTrue(outputStreamCaptor.toString().contains(
"DateTimeOriginal:null\tDateTimeDigitized:2013:06:25 14:51:58\t" +
"ICCProfileName:null\tColorSpace:null\tInteropIndex:null\tPhotometricInterpretation:BlackIsZero\t" +
"MagickIdentify:\"Dimensions: 5300x3841;Channels: gray;Bit-depth: 16;" +
Expand Down