OpenJDK even in Java 8 (update 222) doesn't include these codecs. Oracle JDK has it in Java 8, but not in subsequent Java releases.master
| @@ -23,47 +23,48 @@ | |||||
| <target name="setUp"> | <target name="setUp"> | ||||
| <mkdir dir="${output}"/> | <mkdir dir="${output}"/> | ||||
| <property name="src.dir" location="${basedir}/src"/> | <property name="src.dir" location="${basedir}/src"/> | ||||
| <available classname="com.sun.image.codec.jpeg.JPEGCodec" property="jpeg.codec.available"/> | |||||
| </target> | </target> | ||||
| <target name="main" depends="testSimpleScale"> | <target name="main" depends="testSimpleScale"> | ||||
| </target> | </target> | ||||
| <!-- this should produce a single file in the dest dir --> | <!-- this should produce a single file in the dest dir --> | ||||
| <target name="testSimpleScale" depends="setUp"> | |||||
| <target name="testSimpleScale" depends="setUp" if="jpeg.codec.available"> | |||||
| <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="no" failonerror="no"> | <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="no" failonerror="no"> | ||||
| <scale width="300" proportions="width"/> | <scale width="300" proportions="width"/> | ||||
| </image> | </image> | ||||
| </target> | </target> | ||||
| <!-- this should put some text in the log --> | <!-- this should put some text in the log --> | ||||
| <target name="testEchoToLog" depends="setUp"> | |||||
| <target name="testEchoToLog" depends="setUp" if="jpeg.codec.available"> | |||||
| <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="no" failonerror="no"> | <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="no" failonerror="no"> | ||||
| <scale width="300" proportions="width"/> | <scale width="300" proportions="width"/> | ||||
| </image> | </image> | ||||
| </target> | </target> | ||||
| <!-- this should produce a single file in the dest dir --> | <!-- this should produce a single file in the dest dir --> | ||||
| <target name="testFailOnError" depends="setUp"> | |||||
| <target name="testFailOnError" depends="setUp" if="jpeg.codec.available"> | |||||
| <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="no" failonerror="yes"> | <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="no" failonerror="yes"> | ||||
| <scale width="300" proportions="width"/> | <scale width="300" proportions="width"/> | ||||
| </image> | </image> | ||||
| </target> | </target> | ||||
| <!-- this should produce a single file in the dest dir, overwriting any existing file --> | <!-- this should produce a single file in the dest dir, overwriting any existing file --> | ||||
| <target name="testOverwriteTrue" depends="setUp"> | |||||
| <target name="testOverwriteTrue" depends="setUp" if="jpeg.codec.available"> | |||||
| <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="true" failonerror="no"> | <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="true" failonerror="no"> | ||||
| <scale width="300" proportions="width"/> | <scale width="300" proportions="width"/> | ||||
| </image> | </image> | ||||
| </target> | </target> | ||||
| <!-- this should not overwrite the existing file --> | <!-- this should not overwrite the existing file --> | ||||
| <target name="testOverwriteFalse" depends="setUp"> | |||||
| <target name="testOverwriteFalse" depends="setUp" if="jpeg.codec.available"> | |||||
| <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="false" failonerror="no"> | <image includes="*.jpg" srcdir="${src.dir}" destdir="${output}" overwrite="false" failonerror="no"> | ||||
| <scale width="300" proportions="width"/> | <scale width="300" proportions="width"/> | ||||
| </image> | </image> | ||||
| </target> | </target> | ||||
| <target name="testSimpleScaleWithMapper" depends="setUp"> | |||||
| <target name="testSimpleScaleWithMapper" depends="setUp" if="jpeg.codec.available"> | |||||
| <image includes="*.jpg" srcdir="${src.dir}" | <image includes="*.jpg" srcdir="${src.dir}" | ||||
| destdir="${output}" overwrite="no" failonerror="no"> | destdir="${output}" overwrite="no" failonerror="no"> | ||||
| <scale width="300" proportions="width"/> | <scale width="300" proportions="width"/> | ||||
| @@ -34,6 +34,7 @@ import static org.junit.Assert.assertEquals; | |||||
| import static org.junit.Assert.assertThat; | import static org.junit.Assert.assertThat; | ||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assume.assumeFalse; | import static org.junit.Assume.assumeFalse; | ||||
| import static org.junit.Assume.assumeNotNull; | |||||
| import static org.junit.Assume.assumeTrue; | import static org.junit.Assume.assumeTrue; | ||||
| /** | /** | ||||
| @@ -63,14 +64,17 @@ public class ImageTest { | |||||
| @Test | @Test | ||||
| public void testEchoToLog() { | public void testEchoToLog() { | ||||
| buildRule.executeTarget("testEchoToLog"); | buildRule.executeTarget("testEchoToLog"); | ||||
| assumeNotNull("JPEG codec is unavailable in classpath", | |||||
| buildRule.getProject().getProperty("jpeg.codec.available")); | |||||
| assertThat(buildRule.getLog(), containsString("Processing File")); | assertThat(buildRule.getLog(), containsString("Processing File")); | ||||
| } | } | ||||
| @Test | @Test | ||||
| public void testSimpleScale() { | public void testSimpleScale() { | ||||
| buildRule.executeTarget("testSimpleScale"); | buildRule.executeTarget("testSimpleScale"); | ||||
| assumeNotNull("JPEG codec is unavailable in classpath", | |||||
| buildRule.getProject().getProperty("jpeg.codec.available")); | |||||
| assertThat(buildRule.getLog(), containsString("Processing File")); | assertThat(buildRule.getLog(), containsString("Processing File")); | ||||
| File f = new File(buildRule.getOutputDir(), LARGEIMAGE); | File f = new File(buildRule.getOutputDir(), LARGEIMAGE); | ||||
| assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); | assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); | ||||
| } | } | ||||
| @@ -78,6 +82,8 @@ public class ImageTest { | |||||
| @Test | @Test | ||||
| public void testOverwriteTrue() { | public void testOverwriteTrue() { | ||||
| buildRule.executeTarget("testSimpleScale"); | buildRule.executeTarget("testSimpleScale"); | ||||
| assumeNotNull("JPEG codec is unavailable in classpath", | |||||
| buildRule.getProject().getProperty("jpeg.codec.available")); | |||||
| assertThat(buildRule.getLog(), containsString("Processing File")); | assertThat(buildRule.getLog(), containsString("Processing File")); | ||||
| File f = new File(buildRule.getOutputDir(), LARGEIMAGE); | File f = new File(buildRule.getOutputDir(), LARGEIMAGE); | ||||
| assumeTrue("Could not change file modification date", | assumeTrue("Could not change file modification date", | ||||
| @@ -93,6 +99,8 @@ public class ImageTest { | |||||
| @Test | @Test | ||||
| public void testOverwriteFalse() { | public void testOverwriteFalse() { | ||||
| buildRule.executeTarget("testSimpleScale"); | buildRule.executeTarget("testSimpleScale"); | ||||
| assumeNotNull("JPEG codec is unavailable in classpath", | |||||
| buildRule.getProject().getProperty("jpeg.codec.available")); | |||||
| assertThat(buildRule.getLog(), containsString("Processing File")); | assertThat(buildRule.getLog(), containsString("Processing File")); | ||||
| File f = new File(buildRule.getOutputDir(), LARGEIMAGE); | File f = new File(buildRule.getOutputDir(), LARGEIMAGE); | ||||
| long lastModified = f.lastModified(); | long lastModified = f.lastModified(); | ||||
| @@ -106,6 +114,8 @@ public class ImageTest { | |||||
| @Test | @Test | ||||
| public void testSimpleScaleWithMapper() { | public void testSimpleScaleWithMapper() { | ||||
| buildRule.executeTarget("testSimpleScaleWithMapper"); | buildRule.executeTarget("testSimpleScaleWithMapper"); | ||||
| assumeNotNull("JPEG codec is unavailable in classpath", | |||||
| buildRule.getProject().getProperty("jpeg.codec.available")); | |||||
| assertThat(buildRule.getLog(), containsString("Processing File")); | assertThat(buildRule.getLog(), containsString("Processing File")); | ||||
| File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE); | File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE); | ||||
| assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); | assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); | ||||