mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-10-03 23:53:15 -04:00
JDK 20 compliance
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user