You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2010/09/02 09:55:21 UTC

svn commit: r991838 - in /xmlgraphics/commons/trunk: src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java

Author: jeremias
Date: Thu Sep  2 07:55:21 2010
New Revision: 991838

URL: http://svn.apache.org/viewvc?rev=991838&view=rev
Log:
ImageWriterRegistry:
Change default order to use negative numbers so the default register() method already overrides the default implementations when using the zero priority.
Added test case for the ImageWriterRegistry.

Added:
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java   (with props)
Modified:
    xmlgraphics/commons/trunk/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties

Modified: xmlgraphics/commons/trunk/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties?rev=991838&r1=991837&r2=991838&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties (original)
+++ xmlgraphics/commons/trunk/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties Thu Sep  2 07:55:21 2010
@@ -1,2 +1,2 @@
-org.apache.xmlgraphics.image.writer.internal=1000
-org.apache.xmlgraphics.image.writer.imageio=2000
\ No newline at end of file
+org.apache.xmlgraphics.image.writer.internal=-2000
+org.apache.xmlgraphics.image.writer.imageio=-1000
\ No newline at end of file

Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java?rev=991838&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java Thu Sep  2 07:55:21 2010
@@ -0,0 +1,76 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.xmlgraphics.image.writer.imageio.ImageIOPNGImageWriter;
+
+/**
+ * Tests the {@link ImageWriterRegistry}.
+ */
+public class ImageWriterRegistryTest extends TestCase {
+
+    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/ImageWriterRegistryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistryTest.java
------------------------------------------------------------------------------
    svn:keywords = Id



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