mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 20:15:28 -04:00
JDK 20 compliance
(cherry picked from commit 41460bd32aefc5fe4f283b0bec5687ff65995430)
This commit is contained in:
parent
c5cb54e3e5
commit
a78faf2b31
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
java: [ 8, 11, 17, 18 ]
|
||||
java: [ 8, 11, 17, 20 ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
checks: write
|
||||
|
@ -904,7 +904,7 @@ public final class StringUtil {
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
// Wrap in RuntimeException
|
||||
throw new IllegalArgumentException(pe.getMessage());
|
||||
throw new IllegalArgumentException(pe.getMessage() + " at pos " + pe.getErrorOffset());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,8 +593,8 @@ public class StringUtilTest {
|
||||
cal.clear();
|
||||
cal.set(Calendar.HOUR, 1);
|
||||
cal.set(Calendar.MINUTE, 2);
|
||||
date = StringUtil.toDate("1:02 am",
|
||||
DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US));
|
||||
format = new SimpleDateFormat("HH:mm");
|
||||
date = StringUtil.toDate("1:02", format);
|
||||
assertNotNull(date);
|
||||
assertEquals(cal.getTime(), date);
|
||||
}
|
||||
|
@ -36,9 +36,11 @@ import java.awt.color.ColorSpace;
|
||||
import java.awt.color.ICC_ColorSpace;
|
||||
import java.awt.color.ICC_Profile;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class KCMSSanitizerStrategyTest {
|
||||
@ -56,6 +58,8 @@ public class KCMSSanitizerStrategyTest {
|
||||
|
||||
@Test
|
||||
public void testFixProfileUpdateHeader() throws Exception {
|
||||
assumeICC_ProfileNotSealed(); // Ignores test for JDK 19+
|
||||
|
||||
byte[] header = new byte[128];
|
||||
header[ICC_Profile.icHdrRenderingIntent + 3] = 1;
|
||||
ICC_Profile profile = mock(ICC_Profile.class);
|
||||
@ -69,6 +73,17 @@ public class KCMSSanitizerStrategyTest {
|
||||
verify(profile).setData(eq(ICC_Profile.icSigHead), any(byte[].class));
|
||||
}
|
||||
|
||||
static void assumeICC_ProfileNotSealed() {
|
||||
try {
|
||||
Method isSealed = Class.class.getMethod("isSealed");
|
||||
Boolean result = (Boolean) isSealed.invoke(ICC_Profile.class);
|
||||
assumeFalse("Can't mock ICC_Profile, class is sealed (as of JDK 19).", result);
|
||||
}
|
||||
catch (ReflectiveOperationException ignore) {
|
||||
// We can't have sealed classes if we don't have the isSealed method...
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixProfileCorbisRGB() throws IOException {
|
||||
// TODO: Consider re-writing this using mocks, to avoid dependencies on the CMS implementation
|
||||
|
@ -34,6 +34,7 @@ import org.junit.Test;
|
||||
|
||||
import java.awt.color.ICC_Profile;
|
||||
|
||||
import static com.twelvemonkeys.imageio.color.KCMSSanitizerStrategyTest.assumeICC_ProfileNotSealed;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
@ -46,6 +47,8 @@ public class LCMSSanitizerStrategyTest {
|
||||
|
||||
@Test
|
||||
public void testFixProfile() throws Exception {
|
||||
assumeICC_ProfileNotSealed(); // Ignores test for JDK 19+
|
||||
|
||||
ICC_Profile profile = mock(ICC_Profile.class);
|
||||
new LCMSSanitizerStrategy().fixProfile(profile);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user