BATIK-1203: ImageTagRegistry forgets to reinitialize cache
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/batik/trunk@1867375 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/batik-awt-util/src/main/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java b/batik-awt-util/src/main/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
index f4b1306..d288dfa 100644
--- a/batik-awt-util/src/main/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
+++ b/batik-awt-util/src/main/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
@@ -276,8 +276,7 @@
RegistryEntry re = (RegistryEntry)li.next();
if (re.getPriority() > priority) {
li.previous();
- li.add(newRE);
- return;
+ break; // Insertion point found.
}
}
li.add(newRE);
diff --git a/batik-test-old/src/test/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistryTest.java b/batik-test-old/src/test/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistryTest.java
new file mode 100644
index 0000000..e0753f6
--- /dev/null
+++ b/batik-test-old/src/test/java/org/apache/batik/ext/awt/image/spi/ImageTagRegistryTest.java
@@ -0,0 +1,43 @@
+/*
+
+ 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.
+
+ */
+package org.apache.batik.ext.awt.image.spi;
+
+import org.apache.batik.test.AbstractTest;
+
+public class ImageTagRegistryTest extends AbstractTest {
+ @Override
+ public boolean runImplBasic() throws Exception {
+ ImageTagRegistry ir = new ImageTagRegistry();
+ // Add a new registry entry with a HIGHER priority first
+ ir.register(new AbstractRegistryEntry("Unit test", 100, "working", "application/working") {
+ });
+ // Ensure the first one is present:
+ assertTrue(ir.getRegisteredMimeTypes().contains("application/working"));
+ // Ensure the second is NOT YET present:
+ assertTrue(!ir.getRegisteredMimeTypes().contains("application/missing"));
+ // Add a new registry entry with a LOW priority later
+ ir.register(new AbstractRegistryEntry("Unit test", 1, "missing", "application/missing") {
+ });
+ // This one still works - this is expected:
+ assertTrue(ir.getRegisteredMimeTypes().contains("application/working"));
+ // The second was not added because of BATIK-1203.
+ assertTrue(ir.getRegisteredMimeTypes().contains("application/missing"));
+ return true;
+ }
+}
diff --git a/test-resources/org/apache/batik/ext/awt/image/spi/unitTesting.xml b/test-resources/org/apache/batik/ext/awt/image/spi/unitTesting.xml
new file mode 100644
index 0000000..817ae5c
--- /dev/null
+++ b/test-resources/org/apache/batik/ext/awt/image/spi/unitTesting.xml
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+
+<!-- ========================================================================= -->
+<!-- @version $Id$ -->
+<!-- ========================================================================= -->
+<testSuite id="ext.awt.image.codec.unitTesting" name="org.apache.batik.ext.awt.image.spi package - Unit Testing">
+ <!-- ========================================================================== -->
+ <!-- Validates that ImageTagRegistry is operating as expected -->
+ <!-- ========================================================================== -->
+ <test id="ImageTagRegistryTest" class="org.apache.batik.ext.awt.image.spi.ImageTagRegistryTest" />
+</testSuite>
diff --git a/test-resources/org/apache/batik/test/regard.xml b/test-resources/org/apache/batik/test/regard.xml
index 3b067b6..4bf1c0d 100644
--- a/test-resources/org/apache/batik/test/regard.xml
+++ b/test-resources/org/apache/batik/test/regard.xml
@@ -56,6 +56,7 @@
<testSuite href="file:test-resources/org/apache/batik/apps/rasterizer/unitTesting.xml" />
<testSuite href="file:test-resources/org/apache/batik/test/unitTesting.xml" />
<testSuite href="file:test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml" />
+ <testSuite href="file:test-resources/org/apache/batik/ext/awt/image/spi/unitTesting.xml" />
<testSuite href="file:test-resources/org/apache/batik/ext/awt/geom/unitTesting.xml" />
<testSuite href="file:test-resources/org/apache/batik/util/unitTesting.xml" />
<testSuite href="file:test-resources/org/apache/batik/bridge/unitTesting.xml" />