xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From me...@apache.org
Subject svn commit: r1365650 [1/2] - in /xmlgraphics/commons/trunk: ./ test/java/org/apache/xmlgraphics/ test/java/org/apache/xmlgraphics/fonts/ test/java/org/apache/xmlgraphics/image/codec/png/ test/java/org/apache/xmlgraphics/image/loader/ test/java/org/apac...
Date Wed, 25 Jul 2012 15:59:32 GMT
Author: mehdi
Date: Wed Jul 25 15:59:30 2012
New Revision: 1365650

URL: http://svn.apache.org/viewvc?rev=1365650&view=rev
Log:
Updated the unit tests to JUnit4

Added:
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/ClasspathResourceTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/DoubleFormatUtilTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/ServiceTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPParserTestCase.java   (with props)
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTestCase.java   (with props)
Removed:
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/ClasspathResourceTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/DoubleFormatUtilTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/ServiceTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/io/Base64Test.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPParserTest.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
Modified:
    xmlgraphics/commons/trunk/build.xml
    xmlgraphics/commons/trunk/status.xml
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/StandardTestSuite.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePipelineTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePreloaderTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageSessionContextTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ObservableStream.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PenaltyTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PipelineFactoryTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/SimpleURIResolverBasedImageSessionContext.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicyTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderImageIOTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFaxTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/mocks/MockImageLoaderFactoryTIFF.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/ImageEncodingHelperTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/PSEscapeTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/dsc/ListenerTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentBoundingBoxTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/dsc/events/DSCValueParserTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/dsc/tools/DSCToolsTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/DateFormatUtilTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/HexUtil.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/UnitConvTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/io/ASCII85InputStreamTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/io/ASCII85OutputStreamTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/io/SubInputStreamTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/CommonURIResolverTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java

Modified: xmlgraphics/commons/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/build.xml?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/build.xml (original)
+++ xmlgraphics/commons/trunk/build.xml Wed Jul 25 15:59:30 2012
@@ -52,6 +52,7 @@
   <property name="build.dir" value="${basedir}/build"/>
   <property name="build.classes.dir" value="${build.dir}/classes"/>
   <property name="build.javadocs.dir" value="${build.dir}/javadocs"/>
+  <property name="build.unit.tests.dir" value="${basedir}/test/java"/>
   
   <property name="dist.bin.dir" value="${basedir}/dist-bin"/>
   <property name="dist.src.dir" value="${basedir}/dist-src"/>
@@ -293,7 +294,7 @@
            debug="${javac.debug}" deprecation="${javac.deprecation}"
            optimize="${javac.optimize}" source="${javac.source}"
            target="${javac.target}" includeAntRuntime="true">
-      <src path="${basedir}/test/java"/>
+      <src path="${build.unit.tests.dir}"/>
       <patternset refid="compile-pattern"/>
       <classpath>
         <path refid="libs-build-classpath"/>
@@ -304,7 +305,7 @@
     </javac>
     <copy todir="${build.dir}/test-classes" includeEmptyDirs="false">
       <fileset dir="${basedir}/test/resources"/>
-      <fileset dir="${basedir}/test/java">
+      <fileset dir="${build.unit.tests.dir}">
         <exclude name="**/*.java"/>
         <exclude name="**/*.html"/>
       </fileset>
@@ -327,7 +328,7 @@
         </fileset>
       </classpath>
       <batchtest fork="${junit.fork}" todir="${build.dir}/test-reports">
-        <fileset dir="${basedir}/test/java">
+        <fileset dir="${build.unit.tests.dir}">
           <include name="**/*Test*.java"/>
           <exclude name="**/*TestSuite.java"/>
           <exclude name="**/image/writer/internal/TIFFImageWriter*.java" if="internal-codecs.eff.disabled"/>

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Wed Jul 25 15:59:30 2012
@@ -42,6 +42,9 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="MH" type="update">
+        Updated the JUnit tests to JUnit v4.
+      </action>
       <action context="Code" dev="MH" type="fix" fixes-bug="53599" due-to="JM and MH collaboration">
         Performance improvement of DirectColorMode bitmap images
       </action>

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/StandardTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/StandardTestSuite.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/StandardTestSuite.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/StandardTestSuite.java Wed Jul 25 15:59:30 2012
@@ -19,48 +19,40 @@
 
 package org.apache.xmlgraphics;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
 
-import org.apache.xmlgraphics.image.codec.png.PNGEncoderTest;
+import org.apache.xmlgraphics.image.codec.png.PNGEncoderTestCase;
 import org.apache.xmlgraphics.ps.ImageEncodingHelperTestCase;
 import org.apache.xmlgraphics.ps.PSEscapeTestCase;
 import org.apache.xmlgraphics.ps.dsc.ListenerTestCase;
 import org.apache.xmlgraphics.ps.dsc.events.DSCValueParserTestCase;
 import org.apache.xmlgraphics.ps.dsc.tools.DSCToolsTestCase;
-import org.apache.xmlgraphics.util.ClasspathResourceTest;
-import org.apache.xmlgraphics.util.ServiceTest;
+import org.apache.xmlgraphics.util.ClasspathResourceTestCase;
+import org.apache.xmlgraphics.util.ServiceTestCase;
 import org.apache.xmlgraphics.util.UnitConvTestCase;
 import org.apache.xmlgraphics.util.io.ASCII85InputStreamTestCase;
 import org.apache.xmlgraphics.util.io.ASCII85OutputStreamTestCase;
-import org.apache.xmlgraphics.util.io.Base64Test;
+import org.apache.xmlgraphics.util.io.Base64TestCase;
 
 /**
  * Test suite for basic functionality of XML Graphics Commons.
  */
+@RunWith(Suite.class)
+@SuiteClasses({
+        Base64TestCase.class,
+        ASCII85InputStreamTestCase.class,
+        ASCII85OutputStreamTestCase.class,
+        PNGEncoderTestCase.class,
+        ServiceTestCase.class,
+        ClasspathResourceTestCase.class,
+        PSEscapeTestCase.class,
+        ImageEncodingHelperTestCase.class,
+        DSCValueParserTestCase.class,
+        DSCToolsTestCase.class,
+        ListenerTestCase.class,
+        UnitConvTestCase.class
+})
 public class StandardTestSuite {
-
-    /**
-     * Builds the test suite
-     * @return the test suite
-     */
-    public static Test suite() {
-        TestSuite suite = new TestSuite(
-            "Basic functionality test suite for XML Graphics Commons");
-        //$JUnit-BEGIN$
-        suite.addTest(new TestSuite(Base64Test.class));
-        suite.addTest(new TestSuite(ASCII85InputStreamTestCase.class));
-        suite.addTest(new TestSuite(ASCII85OutputStreamTestCase.class));
-        suite.addTest(new TestSuite(PNGEncoderTest.class));
-        suite.addTest(new TestSuite(ServiceTest.class));
-        suite.addTest(new TestSuite(ClasspathResourceTest.class));
-        suite.addTest(new TestSuite(PSEscapeTestCase.class));
-        suite.addTest(new TestSuite(ImageEncodingHelperTestCase.class));
-        suite.addTest(new TestSuite(DSCValueParserTestCase.class));
-        suite.addTest(new TestSuite(DSCToolsTestCase.class));
-        suite.addTest(new TestSuite(ListenerTestCase.class));
-        suite.addTest(new TestSuite(UnitConvTestCase.class));
-        //$JUnit-END$
-        return suite;
-    }
 }

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.fonts;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Tests for the Glyphs class.
+ */
+public class GlyphsTestCase {
+
+    @Test
+    public void testGetUnicodeSequenceForGlyphName() throws Exception {
+        String glyph;
+        String unicodes;
+
+        glyph = "Omega";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(1, unicodes.length());
+        assertEquals("Must contain 2126 - OHM SIGN",
+                unicodes.charAt(0), '\u2126');
+
+        glyph = "Omegagreek";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(1, unicodes.length());
+        assertEquals("Must contain 03A9 - GREEK CAPITAL LETTER OMEGA",
+                unicodes.charAt(0), '\u03A9');
+
+        glyph = "A";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(1, unicodes.length());
+        assertEquals("Must contain 0041 - LATIN CAPITAL LETTER A",
+                unicodes.charAt(0), '\u0041');
+
+        glyph = "rehyehaleflamarabic";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(4, unicodes.length());
+        assertEquals("Expected 0631 - ARABIC LETTER REH at position 0",
+                unicodes.charAt(0), '\u0631');
+        assertEquals("Expected FEF3 - ARABIC LETTER YEH INITAL FORM at position 1",
+                unicodes.charAt(1), '\uFEF3');
+        assertEquals("Expected FE8E - ARABIC LETTER ALEF FINAL FORM at position 2",
+                unicodes.charAt(2), '\uFE8E');
+        assertEquals("Expected 0644 - ARABIC LETTER LAM at position 3",
+                unicodes.charAt(3), '\u0644');
+
+        glyph = "Lcommaaccent_uni20AC0308_u20AC";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(4, unicodes.length());
+        assertEquals("Must contain 013B",
+                unicodes.charAt(0), '\u013B');
+        assertEquals("Must contain 20AC",
+                unicodes.charAt(1), '\u20AC');
+        assertEquals("Must contain 0308",
+                unicodes.charAt(2), '\u0308');
+        assertEquals("Must contain 20AC",
+                unicodes.charAt(3), '\u20AC');
+
+        glyph = "blah";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertNull(unicodes);
+    }
+
+    @Test
+    public void testGetCharNameAlternativesFor() throws Exception {
+        String[] alts = Glyphs.getCharNameAlternativesFor("Omega");
+        assertEquals(1, alts.length);
+        assertEquals("Omegagreek", alts[0]);
+
+        alts = Glyphs.getCharNameAlternativesFor("nbspace");
+        assertEquals(2, alts.length);
+        assertEquals("space", alts[0]);
+        assertEquals("nonbreakingspace", alts[1]);
+
+        alts = Glyphs.getCharNameAlternativesFor("A");
+        assertNull(alts);
+    }
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.codec.png;
+
+import java.io.InputStream;
+
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.xmlgraphics.image.codec.util.MemoryCacheSeekableStream;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+
+/**
+ * Checks for the presence of message resources for the internal codecs.
+ */
+public class CodecResourcesTestCase {
+
+    @Test
+    public void testResources() throws Exception {
+
+        InputStream in = new java.io.FileInputStream("test/images/barcode.eps");
+        SeekableStream seekStream = new MemoryCacheSeekableStream(in);
+        try {
+            new PNGImage(seekStream, null);
+            fail("Exception expected");
+        } catch (RuntimeException re) {
+            String msg = re.getMessage();
+            if ("PNGImageDecoder0".equals(msg)) {
+                re.printStackTrace();
+                fail("Message resource don't seem to be present! Message is: " + msg);
+            } else if (msg.toLowerCase().indexOf("magic") < 0) {
+                fail("Message not as expected! Message is: " + msg);
+            }
+        } finally {
+            IOUtils.closeQuietly(seekStream);
+            IOUtils.closeQuietly(in);
+        }
+    }
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/CodecResourcesTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.codec.png;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+/**
+ * This test validates the PNGEncoder operation. It creates a
+ * BufferedImage, then encodes it with the PNGEncoder, then
+ * decodes it and compares the decoded image with the original one.
+ *
+ * @version $Id$
+ */
+public class PNGEncoderTestCase {
+
+    @Test
+    public void testPNGEncoding() throws Exception {
+        // Create a BufferedImage to be encoded
+        BufferedImage image = new BufferedImage(100, 75, BufferedImage.TYPE_INT_ARGB);
+        Graphics2D ig = image.createGraphics();
+        ig.scale(.5, .5);
+        ig.setPaint(new Color(128, 0, 0));
+        ig.fillRect(0, 0, 100, 50);
+        ig.setPaint(Color.orange);
+        ig.fillRect(100, 0, 100, 50);
+        ig.setPaint(Color.yellow);
+        ig.fillRect(0, 50, 100, 50);
+        ig.setPaint(Color.red);
+        ig.fillRect(100, 50, 100, 50);
+        ig.setPaint(new Color(255, 127, 127));
+        ig.fillRect(0, 100, 100, 50);
+        ig.setPaint(Color.black);
+        ig.draw(new Rectangle2D.Double(0.5, 0.5, 199, 149));
+        ig.dispose();
+
+        image = image.getSubimage(50, 0, 50, 25);
+
+        // Create an output stream where the PNG data
+        // will be stored.
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        OutputStream os = buildOutputStream(bos);
+        try {
+            // Now, try to encode image
+            PNGEncodeParam params =
+                PNGEncodeParam.getDefaultEncodeParam(image);
+            PNGImageEncoder pngImageEncoder = new PNGImageEncoder(os, params);
+
+            pngImageEncoder.encode(image);
+        } finally {
+            os.close();
+        }
+
+        // Now, try to decode image
+        InputStream is = buildInputStream(bos);
+
+        PNGImageDecoder pngImageDecoder
+            = new PNGImageDecoder(is, new PNGDecodeParam());
+
+        RenderedImage decodedRenderedImage = null;
+        decodedRenderedImage = pngImageDecoder.decodeAsRenderedImage(0);
+
+        BufferedImage decodedImage = null;
+        if (decodedRenderedImage instanceof BufferedImage) {
+            decodedImage = (BufferedImage) decodedRenderedImage;
+        } else {
+            decodedImage = new BufferedImage(decodedRenderedImage.getWidth(),
+                                             decodedRenderedImage.getHeight(),
+                                             BufferedImage.TYPE_INT_ARGB);
+            ig = decodedImage.createGraphics();
+            ig.drawRenderedImage(decodedRenderedImage,
+                                 new AffineTransform());
+            ig.dispose();
+        }
+
+        // Compare images
+        if (!checkIdentical(image, decodedImage)) {
+            fail("Decoded image does not match the original");
+        }
+    }
+
+    /**
+     * Template method for building the PNG output stream. This gives a
+     * chance to sub-classes (e.g., Base64PNGEncoderTest) to add an
+     * additional encoding.
+     */
+    public OutputStream buildOutputStream(ByteArrayOutputStream bos) {
+        return bos;
+    }
+
+    /**
+     * Template method for building the PNG input stream. This gives a
+     * chance to sub-classes (e.g., Base64PNGEncoderTest) to add an
+     * additional decoding.
+     */
+    public InputStream buildInputStream(ByteArrayOutputStream bos) {
+        return new ByteArrayInputStream(bos.toByteArray());
+    }
+
+    /**
+     * Compares the data for the two images
+     */
+    public static boolean checkIdentical(BufferedImage imgA,
+                                         BufferedImage imgB) {
+        boolean identical = true;
+        if (imgA.getWidth() == imgB.getWidth()
+                && imgA.getHeight() == imgB.getHeight()) {
+            int w = imgA.getWidth();
+            int h = imgA.getHeight();
+            for (int i = 0; i < h; i++) {
+                for (int j = 0; j < w; j++) {
+                    if (imgA.getRGB(j, i) != imgB.getRGB(j, i)) {
+                        identical = false;
+                        break;
+                    }
+                }
+                if (!identical) {
+                    break;
+                }
+            }
+        }
+
+        return identical;
+    }
+
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/codec/png/PNGEncoderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,19 +19,19 @@
 
 package org.apache.xmlgraphics.image.loader;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 /**
  * Tests for error behaviour with corrupt images.
  */
-public class CorruptImagesTestCase extends TestCase {
+public class CorruptImagesTestCase {
 
     private MockImageContext imageContext = MockImageContext.getInstance();
 
-    public CorruptImagesTestCase(String name) {
-        super(name);
-    }
-
+    @Test
     public void testCorruptPNG() throws Exception {
         String uri = "corrupt-image.png";
 

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,17 +19,24 @@
 
 package org.apache.xmlgraphics.image.loader;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
  * Tests for image flavors.
  */
-public class ImageFlavorTestCase extends TestCase {
+public class ImageFlavorTestCase {
 
+    @Test
     public void testBasicFlavors() throws Exception {
-        ImageFlavor f1, f2;
+        ImageFlavor f1;
+        ImageFlavor f2;
 
         f1 = ImageFlavor.RAW_JPEG;
         f2 = ImageFlavor.RAW_PNG;
@@ -46,8 +53,10 @@ public class ImageFlavorTestCase extends
         assertNull(f1.getNamespace());
     }
 
+    @Test
     public void testRefinedFlavors() throws Exception {
-        ImageFlavor f1, f2;
+        ImageFlavor f1;
+        ImageFlavor f2;
 
         f1 = ImageFlavor.RENDERED_IMAGE;
         f2 = ImageFlavor.BUFFERED_IMAGE;

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java Wed Jul 25 15:59:30 2012
@@ -31,7 +31,11 @@ import javax.imageio.stream.ImageInputSt
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import org.apache.commons.io.IOUtils;
 
@@ -46,18 +50,15 @@ import org.apache.xmlgraphics.image.load
 /**
  * Tests for bundled ImageLoader implementations.
  */
-public class ImageLoaderTestCase extends TestCase {
+public class ImageLoaderTestCase {
 
     private MockImageContext imageContext = MockImageContext.getInstance();
 
-    public ImageLoaderTestCase(String name) {
-        super(name);
-    }
-
     private MyImageSessionContext createImageSessionContext() {
         return new MyImageSessionContext(imageContext);
     }
 
+    @Test
     public void testPNG() throws Exception {
         String uri = "asf-logo.png";
 
@@ -70,7 +71,7 @@ public class ImageLoaderTestCase extends
         Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, sessionContext);
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
-        ImageRendered imgRed = (ImageRendered)img;
+        ImageRendered imgRed = (ImageRendered) img;
         assertNotNull(imgRed.getRenderedImage());
         assertEquals(169, imgRed.getRenderedImage().getWidth());
         assertEquals(51, imgRed.getRenderedImage().getHeight());
@@ -81,6 +82,7 @@ public class ImageLoaderTestCase extends
         sessionContext.checkAllStreamsClosed();
     }
 
+    @Test
     public void testGIF() throws Exception {
         String uri = "bgimg72dpi.gif";
 
@@ -93,7 +95,7 @@ public class ImageLoaderTestCase extends
         Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, sessionContext);
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
-        ImageRendered imgRed = (ImageRendered)img;
+        ImageRendered imgRed = (ImageRendered) img;
         assertNotNull(imgRed.getRenderedImage());
         assertEquals(192, imgRed.getRenderedImage().getWidth());
         assertEquals(192, imgRed.getRenderedImage().getHeight());
@@ -104,6 +106,7 @@ public class ImageLoaderTestCase extends
         sessionContext.checkAllStreamsClosed();
     }
 
+    @Test
     public void testEPSASCII() throws Exception {
         String uri = "barcode.eps";
 
@@ -116,7 +119,7 @@ public class ImageLoaderTestCase extends
         Image img = manager.getImage(info, ImageFlavor.RAW_EPS, sessionContext);
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RAW_EPS, img.getFlavor());
-        ImageRawStream imgEPS = (ImageRawStream)img;
+        ImageRawStream imgEPS = (ImageRawStream) img;
         InputStream in = imgEPS.createInputStream();
         try {
             assertNotNull(in);
@@ -133,6 +136,7 @@ public class ImageLoaderTestCase extends
         sessionContext.checkAllStreamsClosed();
     }
 
+    @Test
     public void testEPSBinary() throws Exception {
         String uri = "img-with-tiff-preview.eps";
 
@@ -145,7 +149,7 @@ public class ImageLoaderTestCase extends
         Image img = manager.getImage(info, ImageFlavor.RAW_EPS, sessionContext);
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RAW_EPS, img.getFlavor());
-        ImageRawStream imgEPS = (ImageRawStream)img;
+        ImageRawStream imgEPS = (ImageRawStream) img;
         InputStream in = imgEPS.createInputStream();
         try {
             assertNotNull(in);
@@ -162,19 +166,20 @@ public class ImageLoaderTestCase extends
         sessionContext.checkAllStreamsClosed();
     }
 
+    @Test
     public void testICCProfiles() throws Exception {
         MyImageSessionContext sessionContext = createImageSessionContext();
-        List/* <ICC_Profile> */profiles = new ArrayList();
+        List<ICC_Profile> profiles = new ArrayList<ICC_Profile>();
 
         runReaders(profiles, sessionContext, "iccTest.png", "image/png",
                 ImageFlavor.RAW_PNG);
         runReaders(profiles, sessionContext, "iccTest.jpg", "image/jpeg",
                 ImageFlavor.RAW_JPEG);
 
-        ICC_Profile first = (ICC_Profile) profiles.get(0);
+        ICC_Profile first = profiles.get(0);
         byte[] firstData = first.getData();
         for (int i = 1; i < profiles.size(); i++) {
-            ICC_Profile icc = (ICC_Profile) profiles.get(i);
+            ICC_Profile icc = profiles.get(i);
             byte[] data = icc.getData();
             assertEquals("Embedded ICC Profiles are not the same size!",
                     firstData.length, data.length);
@@ -184,10 +189,10 @@ public class ImageLoaderTestCase extends
             }
         }
     }
-    
-    private void runReaders(List profiles, ImageSessionContext isc, String uri,
+
+    private void runReaders(List<ICC_Profile> profiles, ImageSessionContext isc, String uri,
             String mime, ImageFlavor rawFlavor) throws Exception {
-        ImageLoaderFactory ilfs[] = ImageImplRegistry.getDefaultInstance()
+        ImageLoaderFactory[] ilfs = ImageImplRegistry.getDefaultInstance()
                 .getImageLoaderFactories(mime);
         if (ilfs != null) {
             for (int i = 0; i < ilfs.length; i++) {
@@ -222,6 +227,7 @@ public class ImageLoaderTestCase extends
         }
     }
 
+    @Test
     public void testBrokenIccPng() throws Exception {
         String uri = "corrupt-icc.png";
 
@@ -234,7 +240,7 @@ public class ImageLoaderTestCase extends
         Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, sessionContext);
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
-        ImageRendered imgRed = (ImageRendered)img;
+        ImageRendered imgRed = (ImageRendered) img;
         assertNotNull(imgRed.getRenderedImage());
         assertEquals(400, imgRed.getRenderedImage().getWidth());
         assertEquals(300, imgRed.getRenderedImage().getHeight());
@@ -253,7 +259,7 @@ public class ImageLoaderTestCase extends
         public Source newSource(String uri) {
             Source src = super.newSource(uri);
             if (src instanceof ImageSource) {
-                ImageSource is = (ImageSource)src;
+                ImageSource is = (ImageSource) src;
                 ImageInputStream in = is.getImageInputStream();
                 //in = new ObservableImageInputStream(in, is.getSystemId());
                 in = ObservableStream.Factory.observe(in, is.getSystemId());
@@ -267,7 +273,7 @@ public class ImageLoaderTestCase extends
         protected Source resolveURI(String uri) {
             Source src = super.resolveURI(uri);
             if (src instanceof StreamSource) {
-                StreamSource ss = (StreamSource)src;
+                StreamSource ss = (StreamSource) src;
                 if (ss.getInputStream() != null) {
                     InputStream in = new ObservableInputStream(
                             ss.getInputStream(), ss.getSystemId());
@@ -281,7 +287,7 @@ public class ImageLoaderTestCase extends
         public void checkAllStreamsClosed() {
             Iterator iter = streams.iterator();
             while (iter.hasNext()) {
-                ObservableStream stream = (ObservableStream)iter.next();
+                ObservableStream stream = (ObservableStream) iter.next();
                 iter.remove();
                 if (!stream.isClosed()) {
                     fail(stream.getClass().getName() + " is NOT closed: " + stream.getSystemID());

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePipelineTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePipelineTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePipelineTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePipelineTestCase.java Wed Jul 25 15:59:30 2012
@@ -21,7 +21,12 @@ package org.apache.xmlgraphics.image.loa
 
 import java.awt.Dimension;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.xmlgraphics.image.loader.impl.ImageConverterBuffered2Rendered;
 import org.apache.xmlgraphics.image.loader.impl.ImageConverterG2D2Bitmap;
@@ -37,14 +42,11 @@ import org.apache.xmlgraphics.util.MimeC
 /**
  * Tests for the image pipeline functionality.
  */
-public class ImagePipelineTestCase extends TestCase {
+public class ImagePipelineTestCase {
 
     private MockImageContext imageContext = MockImageContext.getInstance();
 
-    public ImagePipelineTestCase(String name) {
-        super(name);
-    }
-
+    @Test
     public void testPipelineWithLoader() throws Exception {
         String uri = "bgimg72dpi.gif";
 
@@ -68,6 +70,7 @@ public class ImagePipelineTestCase exten
         assertEquals(MimeConstants.MIME_PNG, img.getFlavor().getMimeType());
     }
 
+    @Test
     public void testPipelineWithoutLoader() throws Exception {
 
         ImageSessionContext sessionContext = imageContext.newSessionContext();
@@ -107,6 +110,7 @@ public class ImagePipelineTestCase exten
         return g2dImage;
     }
 
+    @Test
     public void testPipelineFromURIThroughManager() throws Exception {
         String uri = "asf-logo.png";
 
@@ -126,6 +130,7 @@ public class ImagePipelineTestCase exten
         assertTrue(img instanceof ImageRawStream);
     }
 
+    @Test
     public void testPipelineWithoutURIThroughManager() throws Exception {
         ImageManager manager = imageContext.getImageManager();
 

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePreloaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePreloaderTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePreloaderTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImagePreloaderTestCase.java Wed Jul 25 15:59:30 2012
@@ -28,24 +28,24 @@ import javax.xml.transform.TransformerEx
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.sax.SAXSource;
 
-import junit.framework.TestCase;
-
+import org.junit.Test;
 import org.xml.sax.InputSource;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
 import org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory;
 import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
  * Tests for bundled Imagepreloader implementations.
  */
-public class ImagePreloaderTestCase extends TestCase {
+public class ImagePreloaderTestCase {
 
     private MockImageContext imageContext = MockImageContext.getInstance();
 
-    public ImagePreloaderTestCase(String name) {
-        super(name);
-    }
-
+    @Test
     public void testImageLoaderFactory() throws Exception {
         ImageManager manager = imageContext.getImageManager();
         ImageInfo info = new ImageInfo(null, MimeConstants.MIME_PNG);
@@ -54,19 +54,21 @@ public class ImagePreloaderTestCase exte
         assertNotNull(ilf);
     }
 
+    @Test
     public void testFileNotFound() throws Exception {
         String uri = "doesnotexistanywhere.png";
 
         ImageSessionContext sessionContext = imageContext.newSessionContext();
         ImageManager manager = imageContext.getImageManager();
         try {
-            ImageInfo info = manager.preloadImage(uri, sessionContext);
+            manager.preloadImage(uri, sessionContext);
             fail("Expected a FileNotFoundException!");
         } catch (FileNotFoundException e) {
             //expected!
         }
     }
 
+    @Test
     public void testPNG() throws Exception {
         String uri = "asf-logo.png";
 
@@ -84,6 +86,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(38245, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testPNGNoResolution() throws Exception {
         String uri = "no-resolution.png";
         //This file contains a pHYs chunk but the resolution is set to zero.
@@ -104,6 +107,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(24000, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testTIFF() throws Exception {
         String uri = "tiff_group4.tif";
 
@@ -121,6 +125,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(66706, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testTIFFNoResolution() throws Exception {
         String uri = "no-resolution.tif";
 
@@ -138,6 +143,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(24000, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testGIF() throws Exception {
         String uri = "bgimg72dpi.gif";
 
@@ -155,6 +161,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(192000, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testEMF() throws Exception {
         String uri = "img.emf";
 
@@ -172,6 +179,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(56665, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testJPEG1() throws Exception {
         String uri = "bgimg300dpi.jpg";
 
@@ -189,6 +197,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(46080, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testJPEG2() throws Exception {
         String uri = "cmyk.jpg";
 
@@ -206,6 +215,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(35000, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testJPEG3() throws Exception {
         String uri = "cmyk-pxcm.jpg"; //Contains resolution as pixels per centimeter
 
@@ -223,6 +233,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(35433, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testBMP() throws Exception {
         String uri = "bgimg300dpi.bmp";
 
@@ -240,6 +251,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(46092, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testBMPNoResolution() throws Exception {
         String uri = "no-resolution.bmp";
 
@@ -257,6 +269,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(50000, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testEPSAscii() throws Exception {
         String uri = "barcode.eps";
 
@@ -274,6 +287,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(42525, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testEPSBinary() throws Exception {
         String uri = "img-with-tiff-preview.eps";
 
@@ -291,6 +305,7 @@ public class ImagePreloaderTestCase exte
         assertEquals(17000, info.getSize().getHeightMpt());
     }
 
+    @Test
     public void testSAXSourceWithSystemID() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -306,6 +321,7 @@ public class ImagePreloaderTestCase exte
         checkImageFound("img:asf-logo.png", resolver);
     }
 
+    @Test
     public void testSAXSourceWithInputStream() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageSessionContextTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageSessionContextTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageSessionContextTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageSessionContextTestCase.java Wed Jul 25 15:59:30 2012
@@ -34,24 +34,24 @@ import javax.xml.transform.dom.DOMSource
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
 
-import junit.framework.TestCase;
-
+import org.junit.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import org.apache.xmlgraphics.image.loader.util.ImageUtil;
 
 /**
  * Tests for AbstractImageSessionContext.
  */
-public class ImageSessionContextTestCase extends TestCase {
+public class ImageSessionContextTestCase {
 
     private MockImageContext imageContext = MockImageContext.getInstance();
 
-    public ImageSessionContextTestCase(String name) {
-        super(name);
-    }
-
+    @Test
     public void testStreamSourceWithSystemID() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -69,6 +69,7 @@ public class ImageSessionContextTestCase
         assertTrue(imgSrc.isFastSource()); //Access through local file system
     }
 
+    @Test
     public void testStreamSourceWithInputStream() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -92,6 +93,7 @@ public class ImageSessionContextTestCase
         assertTrue(!imgSrc.isFastSource());
     }
 
+    @Test
     public void testStreamSourceWithFile() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -110,6 +112,7 @@ public class ImageSessionContextTestCase
         assertTrue(imgSrc.isFastSource()); //Accessed through the local file system
     }
 
+    @Test
     public void testStreamSourceWithInputStreamAndSystemID() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -135,6 +138,7 @@ public class ImageSessionContextTestCase
                                            //being passed through by the URIResolver)
     }
 
+    @Test
     public void testStreamSourceWithReader() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -157,7 +161,7 @@ public class ImageSessionContextTestCase
         Source src = resolve(uri, resolver);
         assertNotNull("Source must not be null", src);
         assertTrue("Source must be an ImageSource", src instanceof ImageSource);
-        ImageSource imgSrc = (ImageSource)src;
+        ImageSource imgSrc = (ImageSource) src;
         assertTrue(ImageUtil.hasImageInputStream(imgSrc));
         return imgSrc;
     }
@@ -169,6 +173,7 @@ public class ImageSessionContextTestCase
         return src;
     }
 
+    @Test
     public void testSAXSourceWithSystemID() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -187,6 +192,7 @@ public class ImageSessionContextTestCase
         assertTrue(imgSrc.isFastSource());
     }
 
+    @Test
     public void testSAXSourceWithInputStream() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -210,6 +216,7 @@ public class ImageSessionContextTestCase
         checkImageInputStreamAvailable(uri, resolver);
     }
 
+    @Test
     public void testSAXSourceWithReader() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -232,6 +239,7 @@ public class ImageSessionContextTestCase
 
     private static final String SOME_XML = "<root><child id='1'>Hello World!</child></root>";
 
+    @Test
     public void testSAXSourceWithXMLReader() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -248,11 +256,12 @@ public class ImageSessionContextTestCase
 
         Source src = resolve(uri, resolver);
         assertTrue(src instanceof SAXSource); //Source remains unchanged
-        SAXSource saxSrc = (SAXSource)src;
+        SAXSource saxSrc = (SAXSource) src;
         assertNotNull(saxSrc.getXMLReader());
         assertNotNull(saxSrc.getInputSource());
     }
 
+    @Test
     public void testDOMSource() throws Exception {
         URIResolver resolver = new URIResolver() {
             public Source resolve(String href, String base) throws TransformerException {
@@ -276,7 +285,7 @@ public class ImageSessionContextTestCase
 
         Source src = resolve(uri, resolver);
         assertTrue(src instanceof DOMSource); //Source remains unchanged
-        DOMSource domSrc = (DOMSource)src;
+        DOMSource domSrc = (DOMSource) src;
         assertNotNull(domSrc.getNode());
     }
 

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,19 +19,24 @@
 
 package org.apache.xmlgraphics.image.loader;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 import org.apache.xmlgraphics.image.loader.util.ImageUtil;
 
 /**
  * Tests for the ImageUtil class.
  */
-public class ImageUtilTestCase extends TestCase {
+public class ImageUtilTestCase {
 
     /**
      * Tests {@link ImageUtil.needPageIndexFromURI(String)}.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testNeedPageIndex() throws Exception {
         int pageIndex;
 
@@ -66,6 +71,7 @@ public class ImageUtilTestCase extends T
      * Tests {@link ImageUtil.getPageIndexFromURI(String)}.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testGetPageIndex() throws Exception {
         Integer pageIndex;
 

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ObservableStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ObservableStream.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ObservableStream.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ObservableStream.java Wed Jul 25 15:59:30 2012
@@ -49,7 +49,7 @@ public interface ObservableStream {
     public static class Factory {
 
         public static ImageInputStream observe(ImageInputStream iin, String systemID) {
-            return (ImageInputStream)Proxy.newProxyInstance(
+            return (ImageInputStream) Proxy.newProxyInstance(
                     Factory.class.getClassLoader(),
                     new Class[] {ImageInputStream.class, ObservableStream.class},
                     new ObservingImageInputStreamInvocationHandler(iin, systemID));

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PenaltyTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PenaltyTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PenaltyTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PenaltyTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,19 +19,23 @@
 
 package org.apache.xmlgraphics.image.loader;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.xmlgraphics.image.loader.util.Penalty;
 
 /**
  * Tests for the {@link Penalty}.
  */
-public class PenaltyTestCase extends TestCase {
+public class PenaltyTestCase {
 
     /**
      * Tests for penalty handling.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testTruncatePenalty() throws Exception {
         assertEquals(0, Penalty.truncate(0));
         long penalty = Integer.MAX_VALUE;
@@ -41,7 +45,7 @@ public class PenaltyTestCase extends Tes
         penalty++;
         assertEquals(Integer.MAX_VALUE, Penalty.truncate(penalty));
         //For comparison, normal casting does this
-        assertEquals(Integer.MIN_VALUE, (int)penalty);
+        assertEquals(Integer.MIN_VALUE, (int) penalty);
 
         //Now on the other end of the spectrum...
         penalty = Integer.MIN_VALUE;
@@ -51,13 +55,14 @@ public class PenaltyTestCase extends Tes
         penalty -= 500;
         assertEquals(Integer.MIN_VALUE, Penalty.truncate(penalty));
         //For comparison, normal casting does this
-        assertEquals(Integer.MAX_VALUE - 499, (int)penalty);
+        assertEquals(Integer.MAX_VALUE - 499, (int) penalty);
     }
 
     /**
      * Tests for the {@link Penalty} class.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testPenalty() throws Exception {
         Penalty p1 = Penalty.toPenalty(100);
         assertEquals(100, p1.getValue());

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PipelineFactoryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PipelineFactoryTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PipelineFactoryTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PipelineFactoryTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,7 +19,11 @@
 
 package org.apache.xmlgraphics.image.loader;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import org.apache.xmlgraphics.image.codec.tiff.TIFFImage;
 import org.apache.xmlgraphics.image.loader.impl.ImageLoaderRawCCITTFax;
@@ -32,12 +36,13 @@ import org.apache.xmlgraphics.image.load
 /**
  * Tests the pipeline factory.
  */
-public class PipelineFactoryTestCase extends TestCase {
+public class PipelineFactoryTestCase {
 
     /**
      * Tests the pipeline factory by checking to load a TIFF image.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testPipelineFactoryPlain() throws Exception {
         MockImageContext imageContext = MockImageContext.newSafeInstance();
         ImageManager manager = imageContext.getImageManager();
@@ -96,6 +101,7 @@ public class PipelineFactoryTestCase ext
      * Similar test as above but here we take raw CCITT loading into consideration, too.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testPipelineFactoryImageInfoDependency() throws Exception {
         MockImageContext imageContext = MockImageContext.newSafeInstance();
         ImageManager manager = imageContext.getImageManager();
@@ -149,6 +155,7 @@ public class PipelineFactoryTestCase ext
      * Similar test as above but now we're playing with additional penalties in the registry.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testPipelineFactoryAdditionalPenalty() throws Exception {
         MockImageContext imageContext = MockImageContext.newSafeInstance();
         ImageManager manager = imageContext.getImageManager();

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/SimpleURIResolverBasedImageSessionContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/SimpleURIResolverBasedImageSessionContext.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/SimpleURIResolverBasedImageSessionContext.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/SimpleURIResolverBasedImageSessionContext.java Wed Jul 25 15:59:30 2012
@@ -56,5 +56,4 @@ public class SimpleURIResolverBasedImage
             return null;
         }
     }
-
-}
\ No newline at end of file
+}

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicyTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicyTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicyTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicyTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,17 +19,22 @@
 
 package org.apache.xmlgraphics.image.loader.cache;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 
 /**
  * Tests {@link DefaultExpirationPolicy}.
  */
-public class DefaultExpirationPolicyTestCase extends TestCase {
+public class DefaultExpirationPolicyTestCase {
 
     /**
      * Never expire.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testNeverExpire() throws Exception {
         ExpirationPolicy policy;
         policy = new DefaultExpirationPolicy(DefaultExpirationPolicy.EXPIRATION_NEVER);
@@ -46,6 +51,7 @@ public class DefaultExpirationPolicyTest
      * Normal expiration
      * @throws Exception if an error occurs
      */
+    @Test
     public void testNormalExpiration() throws Exception {
         ExpirationPolicy policy;
         policy = new DefaultExpirationPolicy(2);

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java Wed Jul 25 15:59:30 2012
@@ -21,7 +21,14 @@ package org.apache.xmlgraphics.image.loa
 
 import java.io.FileNotFoundException;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.ImageInfo;
@@ -33,7 +40,7 @@ import org.apache.xmlgraphics.image.load
 /**
  * Tests for bundled ImageLoader implementations.
  */
-public class ImageCacheTestCase extends TestCase {
+public class ImageCacheTestCase {
 
     private static final boolean DEBUG = false;
 
@@ -44,9 +51,8 @@ public class ImageCacheTestCase extends 
                 ? new ImageCacheLoggingStatistics(true) : new ImageCacheStatistics(true));
 
     /** {@inheritDoc} */
-    protected void setUp() throws Exception {
-        super.setUp();
-
+    @Before
+    public void setUp() throws Exception {
         manager.getCache().clearCache();
         statistics.reset();
         manager.getCache().setCacheListener(statistics);
@@ -56,6 +62,7 @@ public class ImageCacheTestCase extends 
      * Tests the ImageInfo cache.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testImageInfoCache() throws Exception {
         String invalid1 = "invalid1.jpg";
         String invalid2 = "invalid2.jpg";
@@ -63,7 +70,8 @@ public class ImageCacheTestCase extends 
         String valid2 = "big-image.png";
 
 
-        ImageInfo info1, info2;
+        ImageInfo info1;
+        ImageInfo info2;
         info1 = manager.getImageInfo(valid1, sessionContext);
         assertNotNull(info1);
         assertEquals(valid1, info1.getOriginalURI());
@@ -113,6 +121,7 @@ public class ImageCacheTestCase extends 
         statistics.reset();
     }
 
+    @Test
     public void testInvalidURIExpiration() throws Exception {
         MockTimeStampProvider provider = new MockTimeStampProvider();
         ImageCache cache = new ImageCache(provider, new DefaultExpirationPolicy(2));
@@ -155,18 +164,19 @@ public class ImageCacheTestCase extends 
      * Tests the image cache reusing a cacheable Image created by the ImageLoader.
      * @throws Exception if an error occurs
      */
+    @Test
     public void testImageCache1() throws Exception {
         String valid1 = "bgimg72dpi.gif";
 
         ImageInfo info = manager.getImageInfo(valid1, sessionContext);
         assertNotNull(info);
 
-        ImageBuffered img1 = (ImageBuffered)manager.getImage(
+        ImageBuffered img1 = (ImageBuffered) manager.getImage(
                 info, ImageFlavor.BUFFERED_IMAGE, sessionContext);
         assertNotNull(img1);
         assertNotNull(img1.getBufferedImage());
 
-        ImageBuffered img2 = (ImageBuffered)manager.getImage(
+        ImageBuffered img2 = (ImageBuffered) manager.getImage(
                 info, ImageFlavor.BUFFERED_IMAGE, sessionContext);
         //ImageBuffered does not have to be the same instance but we want at least the
         //BufferedImage to be reused.
@@ -177,11 +187,12 @@ public class ImageCacheTestCase extends 
         assertEquals(1, statistics.getImageCacheMisses());
     }
 
-    
+
     /**
      * Test to check if doInvalidURIHouseKeeping() throws a
      * ConcurrentModificationException.
      */
+    @Test
     public void testImageCacheHouseKeeping() {
         ImageCache imageCache = new ImageCache(new TimeStampProvider(),
                 new DefaultExpirationPolicy(1));

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderImageIOTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderImageIOTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderImageIOTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderImageIOTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,14 +19,13 @@
 
 package org.apache.xmlgraphics.image.loader.impl;
 
-import static org.junit.Assert.assertTrue;
-
 import java.net.URL;
 
-import junit.framework.Assert;
-
 import org.junit.Test;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageContext;
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
@@ -50,7 +49,7 @@ public class ImageLoaderImageIOTestCase 
     @Test
     public void testGrayPNGWithCMYKProfile() throws Exception {
         URL imageURL = getClass().getResource("gray-vs-cmyk-profile.png");
-        Assert.assertNotNull(imageURL);
+        assertNotNull(imageURL);
         String uri = imageURL.toURI().toASCIIString();
 
         ImageLoaderImageIO loader = new ImageLoaderImageIO(ImageFlavor.RENDERED_IMAGE);

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFaxTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFaxTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFaxTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFaxTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,7 +19,9 @@
 
 package org.apache.xmlgraphics.image.loader.impl;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 import org.apache.xmlgraphics.image.loader.ImageContext;
 import org.apache.xmlgraphics.image.loader.ImageInfo;
@@ -30,11 +32,12 @@ import org.apache.xmlgraphics.image.load
 import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
- * Test case for {@link ImageLoaderRawCCITTFax}. 
+ * Test case for {@link ImageLoaderRawCCITTFax}.
  */
-public class ImageLoaderRawCCITTFaxTestCase extends TestCase {
+public class ImageLoaderRawCCITTFaxTestCase {
     private ImageLoaderRawCCITTFax sut;
 
+    @Test
     public void testLoadImage() throws Exception {
         ImageContext context = MockImageContext.newSafeInstance();
         ImageSessionContext session = new MockImageSessionContext(context);

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/mocks/MockImageLoaderFactoryTIFF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/mocks/MockImageLoaderFactoryTIFF.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/mocks/MockImageLoaderFactoryTIFF.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/mocks/MockImageLoaderFactoryTIFF.java Wed Jul 25 15:59:30 2012
@@ -22,7 +22,7 @@ package org.apache.xmlgraphics.image.loa
 import java.io.IOException;
 import java.util.Map;
 
-import junit.framework.Assert;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageException;
@@ -57,7 +57,7 @@ public class MockImageLoaderFactoryTIFF 
                 break;
             }
         }
-        Assert.assertTrue(found);
+        assertTrue(found);
     }
 
     /** {@inheritDoc} */

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.xmlgraphics.image.writer.imageio.ImageIOPNGImageWriter;
+
+/**
+ * Tests the {@link ImageWriterRegistry}.
+ */
+public class ImageWriterRegistryTestCase {
+
+    @Test
+    public void testRegistry() throws Exception {
+        ImageWriterRegistry registry = new ImageWriterRegistry();
+
+        ImageWriter writer;
+        writer = registry.getWriterFor("image/something");
+        assertNull(writer);
+
+        writer = registry.getWriterFor("image/png");
+        assertTrue(writer instanceof ImageIOPNGImageWriter);
+
+        registry.register(new DummyPNGWriter());
+
+        ImageWriter dummy = registry.getWriterFor("image/png");
+        assertEquals(DummyPNGWriter.class, dummy.getClass());
+
+        registry.register(new OtherPNGWriter(), 50);
+
+        dummy = registry.getWriterFor("image/png");
+        assertEquals(OtherPNGWriter.class, dummy.getClass());
+    }
+
+    private static class DummyPNGWriter extends AbstractImageWriter {
+
+        public String getMIMEType() {
+            return "image/png";
+        }
+
+        public void writeImage(RenderedImage image, OutputStream out) throws IOException {
+            //nop
+        }
+
+        public void writeImage(RenderedImage image, OutputStream out, ImageWriterParams params)
+                throws IOException {
+            //nop
+        }
+    }
+
+    private static class OtherPNGWriter extends DummyPNGWriter {
+    }
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color;
+
+import java.awt.Color;
+import java.awt.color.ColorSpace;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ColorConverterTestCase {
+
+    @Test
+    public void testToGray() throws Exception {
+        ColorConverter converter = GrayScaleColorConverter.getInstance();
+        Color rgb = new Color(255, 184, 0);
+        Color gray = converter.convert(rgb);
+
+        ColorSpaceOrigin origin = ColorSpaces.getColorSpaceOrigin(gray.getColorSpace());
+        assertEquals("#CMYK", origin.getProfileName());
+        assertNull(origin.getProfileURI());
+        assertEquals(ColorSpace.TYPE_CMYK, gray.getColorSpace().getType());
+        float[] comps = gray.getColorComponents(null);
+        assertEquals(4, comps.length);
+        assertEquals(0.0f, comps[0], 0.1f);
+        assertEquals(0.0f, comps[1], 0.1f);
+        assertEquals(0.0f, comps[2], 0.1f);
+        assertEquals(0.273f, comps[3], 0.01f);
+        assertEquals(0xFFB9B9B9, gray.getRGB());
+    }
+
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorConverterTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color;
+
+import java.awt.Color;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests the {@link ColorWithAlternatives} class.
+ */
+public class ColorWithAlternativesTestCase {
+
+    @Test
+    public void testEquals() throws Exception {
+        Color col1 = new ColorWithAlternatives(255, 204, 0, null);
+        Color col2 = new Color(255, 204, 0);
+
+        assertEquals(col1, col2);
+        assertEquals(col2, col1);
+
+        CIELabColorSpace lab = ColorSpaces.getCIELabColorSpaceD50();
+        Color postgelbLab = lab.toColor(83.25f, 16.45f, 96.89f, 1.0f);
+        col1 = new ColorWithAlternatives(255, 204, 0, new Color[] {postgelbLab});
+
+        //java.awt.Color tests on the sRGB value only
+        assertEquals(col1, col2);
+        assertEquals(col2, col1);
+    }
+
+    @Test
+    public void testSameColor() throws Exception {
+        Color col1 = new ColorWithAlternatives(255, 204, 0, null);
+        Color col2 = new Color(255, 204, 0);
+
+        //No alternatives. Only sRGB counts.
+        assertTrue(ColorUtil.isSameColor(col1, col2));
+
+        CIELabColorSpace lab = ColorSpaces.getCIELabColorSpaceD50();
+        Color postgelbLab = lab.toColor(83.25f, 16.45f, 96.89f, 1.0f);
+        col1 = new ColorWithAlternatives(255, 204, 0, new Color[] {postgelbLab});
+
+        //Same sRGB value but one color with alternatives:
+        assertFalse(ColorUtil.isSameColor(col1, col2));
+
+        //Once the spotcolor naked and once as part of a color with alternatives
+        assertFalse(ColorUtil.isSameColor(postgelbLab, col1));
+
+        //sRGB values is calculated from Lab color and doesn't exactly match the selected fallback
+        assertFalse(postgelbLab.equals(col1));
+    }
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternativesTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTestCase.java?rev=1365650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTestCase.java Wed Jul 25 15:59:30 2012
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color.profile;
+
+import java.awt.color.ICC_Profile;
+import java.io.InputStream;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
+import org.apache.xmlgraphics.java2d.color.RenderingIntent;
+
+/**
+ * Tests the {@link NamedColorProfileParser}.
+ */
+public class NamedColorProfileParserTestCase {
+
+    private static final String NCP_EXAMPLE_FILE = "ncp-example.icc";
+
+    @Test
+    public void testParser() throws Exception {
+        InputStream in = getClass().getResourceAsStream(NCP_EXAMPLE_FILE);
+        assertNotNull(NCP_EXAMPLE_FILE + " is missing!", in);
+        ICC_Profile iccProfile;
+        try {
+            iccProfile = ICC_Profile.getInstance(in);
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+        NamedColorProfileParser parser = new NamedColorProfileParser();
+        NamedColorProfile ncp = parser.parseProfile(iccProfile);
+        assertEquals("Named Color Profile Example", ncp.getProfileName());
+        assertEquals("The Apache Software Foundation", ncp.getCopyright());
+        assertEquals(RenderingIntent.PERCEPTUAL, ncp.getRenderingIntent());
+        NamedColorSpace[] namedColors = ncp.getNamedColors();
+        assertEquals(2, namedColors.length);
+        NamedColorSpace ncs;
+        ncs = namedColors[0];
+        assertEquals("Postgelb", ncs.getColorName());
+        float[] xyz = ncs.getXYZ();
+        assertEquals(0.6763079f, xyz[0], 0.01f);
+        assertEquals(0.6263507f, xyz[1], 0.01f);
+        assertEquals(0.04217565f, xyz[2], 0.01f);
+
+        ncs = namedColors[1];
+        assertEquals("MyRed", ncs.getColorName());
+    }
+}

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParserTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java Wed Jul 25 15:59:30 2012
@@ -26,21 +26,21 @@ import java.io.IOException;
 import org.junit.Before;
 import org.junit.Test;
 
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSState;
-
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSState;
+
 public class PSGraphics2DTestCase {
 
     private PSGenerator gen;
     private PSGraphics2D gfx2d;
-    private final AffineTransform TRANSFORM = new AffineTransform(1, 0, 0, -1, 0, 792);
+    private final AffineTransform transform = new AffineTransform(1, 0, 0, -1, 0, 792);
 
     @Before
     public void setup() {
@@ -53,13 +53,13 @@ public class PSGraphics2DTestCase {
     private void createGraphics2D() {
         gfx2d = new PSGraphics2D(false, gen);
         gfx2d.setGraphicContext(new GraphicContext());
-        gfx2d.setTransform(TRANSFORM);
+        gfx2d.setTransform(transform);
     }
 
     @Test
     public void draw() throws IOException {
-        assertEquals(gfx2d.getTransform(), TRANSFORM);
+        assertEquals(gfx2d.getTransform(), transform);
         gfx2d.draw(new Rectangle(10, 10, 100, 100));
-        verify(gen, times(1)).concatMatrix(TRANSFORM);
+        verify(gen, times(1)).concatMatrix(transform);
     }
 }

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/ImageEncodingHelperTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/ImageEncodingHelperTestCase.java?rev=1365650&r1=1365649&r2=1365650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/ImageEncodingHelperTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/ImageEncodingHelperTestCase.java Wed Jul 25 15:59:30 2012
@@ -19,11 +19,6 @@
 
 package org.apache.xmlgraphics.ps;
 
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.geom.Rectangle2D;
@@ -31,17 +26,22 @@ import java.awt.image.BufferedImage;
 import java.awt.image.DataBuffer;
 import java.awt.image.DirectColorModel;
 import java.awt.image.WritableRaster;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Arrays;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.junit.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
-public class ImageEncodingHelperTestCase extends TestCase {
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+
+public class ImageEncodingHelperTestCase {
 
     private BufferedImage prepareImage(BufferedImage image) {
         Graphics2D ig = image.createGraphics();
@@ -68,6 +68,7 @@ public class ImageEncodingHelperTestCase
      * same.
      * @throws IOException if an I/O error occurs.
      */
+    @Test
     public void testEncodeRenderedImageWithDirectColorModelAsRGB() throws IOException {
         BufferedImage image = new BufferedImage(100, 75, BufferedImage.TYPE_INT_ARGB);
         image = prepareImage(image);
@@ -83,11 +84,13 @@ public class ImageEncodingHelperTestCase
     }
 
     /**
-     * Tests a BGR versus RBG image. Debugging shows the BGR follows the optimizeWriteTo() (which is intended).
-     * The bytes are compared with the RBG image, which happens to follow the writeRGBTo().
-     * 
+     * Tests a BGR versus RBG image. Debugging shows the BGR follows the optimizeWriteTo() (which
+     * is intended). The bytes are compared with the RBG image, which happens to follow the
+     * writeRGBTo().
+     *
      * @throws IOException
      */
+    @Test
     public void testRGBAndBGRImages() throws IOException {
         BufferedImage imageBGR = new BufferedImage(100, 75, BufferedImage.TYPE_3BYTE_BGR);
         imageBGR = prepareImage(imageBGR);
@@ -109,12 +112,12 @@ public class ImageEncodingHelperTestCase
     /**
      * Tests encodeRenderedImageWithDirectColorModeAsRGB(). Uses mocking to test the method
      * implementation.
-     * @throws FileNotFoundException if expected file was not found.
      * @throws IOException if an I/O error occurs.
      */
+    @Test
     public void testMockedEncodeRenderedImageWithDirectColorModelAsRGB() throws IOException {
         BufferedImage image = mock(BufferedImage.class);
-        final int[] templateMasks = new int[] { 0x00ff0000 /*R*/, 0x0000ff00 /*G*/,
+        final int[] templateMasks = new int[] {0x00ff0000 /*R*/, 0x0000ff00 /*G*/,
                                                     0x000000ff /*B*/, 0xff000000 /*A*/};
         DirectColorModel dcm = new DirectColorModel(255, templateMasks[0], templateMasks[1],
                 templateMasks[2], templateMasks[3]);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message