harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r953447 - in /harmony/enhanced/java/trunk/classlib/modules/imageio/src: main/java/javax/imageio/spi/ImageReaderSpi.java main/java/javax/imageio/spi/ImageWriterSpi.java test/java/javax/imageio/spi/ImageReaderSpiTest.java
Date Thu, 10 Jun 2010 20:36:26 GMT
Author: aaf
Date: Thu Jun 10 20:36:26 2010
New Revision: 953447

URL: http://svn.apache.org/viewvc?rev=953447&view=rev
Log:
Committed Lang's patch for HARMONY-6509: implementation of ImageReaderSpi.isOwnReader() and
ImageWriterSpi.isOwnWriter().

Added:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java
Modified:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java?rev=953447&r1=953446&r2=953447&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
Thu Jun 10 20:36:26 2010
@@ -78,9 +78,12 @@ public abstract class ImageReaderSpi ext
 
     public abstract ImageReader createReaderInstance(Object extension) throws IOException;
 
-    public boolean isOwnReader(ImageReader reader) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public boolean isOwnReader(ImageReader reader) {
+        if (reader == null) {
+            throw new IllegalArgumentException(Messages.getString("imageio.97"));
+        }
+        
+        return reader.getClass().getName().equals(pluginClassName);
     }
 
     public String[] getImageWriterSpiNames() {

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java?rev=953447&r1=953446&r2=953447&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java
Thu Jun 10 20:36:26 2010
@@ -90,9 +90,12 @@ public abstract class ImageWriterSpi ext
 
     public abstract ImageWriter createWriterInstance(Object extension) throws IOException;
 
-    public boolean isOwnWriter(ImageWriter writer) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public boolean isOwnWriter(ImageWriter writer) {
+        if (writer == null) {
+            throw new IllegalArgumentException(Messages.getString("imageio.96"));
+        }
+        
+        return writer.getClass().getName().equals(pluginClassName);
     }
 
     public String[] getImageReaderSpiNames() {

Added: harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java?rev=953447&view=auto
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java
(added)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java
Thu Jun 10 20:36:26 2010
@@ -0,0 +1,41 @@
+package javax.imageio.spi;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+
+import junit.framework.TestCase;
+
+public class ImageReaderSpiTest extends TestCase {
+    
+    private void testIsOwnReader(String format1, String format2) throws Exception {
+        ImageReader reader1 = ImageIO.getImageReadersByFormatName(format1).next();
+        ImageReaderSpi readerSpi1 = reader1.getOriginatingProvider();
+
+        ImageReader reader2 = ImageIO.getImageReadersByFormatName(format2).next();
+        ImageReaderSpi readerSpi2 = reader2.getOriginatingProvider();
+
+        assertTrue(readerSpi1.isOwnReader(reader1));
+        assertTrue(readerSpi2.isOwnReader(reader2));
+        assertFalse(readerSpi1.isOwnReader(reader2));
+        assertFalse(readerSpi2.isOwnReader(reader1));
+        
+        try {
+            readerSpi1.isOwnReader(null);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException expected){
+            // Ok
+        }
+    }
+    
+    public void testJpegOwnReader() throws Exception {
+        testIsOwnReader("jpeg", "gif");
+    }
+
+    public void testGifOwnReader() throws Exception {
+        testIsOwnReader("gif", "png");
+    }
+    
+    public void testPngOwnReader() throws Exception {
+        testIsOwnReader("png", "jpeg");
+    }
+}



Mime
View raw message