harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r953244 - in /harmony/enhanced/java/trunk/classlib/modules/imageio/src: main/java/javax/imageio/spi/ServiceRegistry.java test/java/javax/imageio/spi/ test/java/javax/imageio/spi/ServiceRegistryTest.java
Date Thu, 10 Jun 2010 08:27:03 GMT
Author: aaf
Date: Thu Jun 10 08:27:03 2010
New Revision: 953244

URL: http://svn.apache.org/viewvc?rev=953244&view=rev
Log:
Committed Lang Yang's patch for HARMONY-6506. Fixed the return value for
registerServiceProvider(java.lang.Object, java.lang.Class).

Added:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
Modified:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java?rev=953244&r1=953243&r2=953244&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
Thu Jun 10 08:27:03 2010
@@ -209,7 +209,7 @@ public class ServiceRegistry {
         Map<Class<?>, Object> providers = new HashMap<Class<?>, Object>();
 
         boolean addProvider(Object provider) {
-            return providers.put(provider.getClass(), provider) != null;
+            return providers.put(provider.getClass(), provider) == null;
         }
 
         Iterator<Class<?>> getProviderClasses() {

Added: harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java?rev=953244&view=auto
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
(added)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
Thu Jun 10 08:27:03 2010
@@ -0,0 +1,51 @@
+package javax.imageio.spi;
+
+import java.util.Arrays;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import javax.imageio.ImageReader;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ImageWriterSpi;
+
+public class ServiceRegistryTest extends TestCase {
+    
+    public void testRegistryServiceProvider() throws Exception {
+        Class[] CATEGORIES = new Class[] {
+                ImageWriterSpi.class, ImageReaderSpi.class
+        };
+        
+        ServiceRegistry registry = new ServiceRegistry(Arrays.<Class<?>> asList(CATEGORIES).iterator());
+        
+        SampleImageReaderSpi spiA = new SampleImageReaderSpi();  
+        SampleImageReaderSpi spiB = new SampleImageReaderSpi();
+        
+        assertTrue("registerServiceProvider() returns incorrect value for the empty registry",
+            registry.registerServiceProvider(spiA, CATEGORIES[1]));
+        assertFalse("registerServiceProvider() returns incorrect value if a provider of the
same class was previously registered",
+            registry.registerServiceProvider(spiB, CATEGORIES[1]));
+    }
+}
+
+class SampleImageReaderSpi extends ImageReaderSpi {
+    SampleImageReaderSpi() {
+        super("sample vendor", "1.0", new String[] { "sample" },
+            null, null, SampleImageReaderSpi.class.getName(),
+            STANDARD_INPUT_TYPE, null, false, null, null,
+            null, null, false, null, null, null, null);
+    }
+
+    public boolean canDecodeInput(Object source) {
+        return false;
+    }
+
+    public ImageReader createReaderInstance(Object extension) {
+        return null;
+    }
+
+    public String getDescription(Locale locale) {
+        return null;
+    }
+}
+



Mime
View raw message