From b5856fd110d84278b2a9d97a2776488890169927 Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Sat, 15 Oct 2022 11:55:34 +0200 Subject: [PATCH] Revert "Update test to pass on JDK 19." This reverts commit 081f2efea22d2f73fa991e198803b07279f29df6. --- .../color/KCMSSanitizerStrategyTest.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/KCMSSanitizerStrategyTest.java b/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/KCMSSanitizerStrategyTest.java index 0d6b956d..3cf80a29 100644 --- a/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/KCMSSanitizerStrategyTest.java +++ b/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/KCMSSanitizerStrategyTest.java @@ -32,40 +32,46 @@ package com.twelvemonkeys.imageio.color; import org.junit.Test; -import java.awt.color.*; +import java.awt.color.ColorSpace; +import java.awt.color.ICC_ColorSpace; +import java.awt.color.ICC_Profile; import java.io.IOException; import java.util.Arrays; import static org.junit.Assert.assertArrayEquals; +import static org.mockito.Mockito.*; public class KCMSSanitizerStrategyTest { private static final byte[] XYZ = new byte[] {'X', 'Y', 'Z', ' '}; @Test(expected = IllegalArgumentException.class) - public void testFixProfileNullProfile() { + public void testFixProfileNullProfile() throws Exception { new KCMSSanitizerStrategy().fixProfile(null); } @Test - public void testFixProfile() { + public void testFixProfile() throws Exception { new KCMSSanitizerStrategy().fixProfile(((ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB)).getProfile()); } @Test - public void testFixProfileUpdateHeader() throws IOException { - ICC_Profile profile = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/adobe_rgb_1998.icc")); - - // Mangle the profile slightly... - byte[] header = profile.getData(ICC_Profile.icSigHead); - header[ICC_Profile.icHdrRenderingIntent + 3] = 42; + public void testFixProfileUpdateHeader() throws Exception { + byte[] header = new byte[128]; + header[ICC_Profile.icHdrRenderingIntent + 3] = 1; + ICC_Profile profile = mock(ICC_Profile.class); + when(profile.getData(ICC_Profile.icSigHead)).thenReturn(header); + // Can't test that the values are actually changed, as the LCMS-backed implementation + // of ICC_Profile does not change based on this invocation. new KCMSSanitizerStrategy().fixProfile(profile); - assertArrayEquals(new byte[] {0, 0, 0, ICC_Profile.icPerceptual}, Arrays.copyOfRange(profile.getData(ICC_Profile.icSigHead), ICC_Profile.icHdrRenderingIntent, ICC_Profile.icHdrRenderingIntent + 4)); + // Verify that the method was invoked + verify(profile).setData(eq(ICC_Profile.icSigHead), any(byte[].class)); } @Test public void testFixProfileCorbisRGB() throws IOException { + // TODO: Consider re-writing this using mocks, to avoid dependencies on the CMS implementation ICC_Profile corbisRGB = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/Corbis RGB.icc")); new KCMSSanitizerStrategy().fixProfile(corbisRGB);