harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r480933 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ test/java/org/apache/harmony/beans/tests/java/beans/ test/resources/org/ test/resources/org/apache/ test/resources/org/apache/harmony/ test/resources/org...
Date Thu, 30 Nov 2006 14:15:02 GMT
Author: ayza
Date: Thu Nov 30 06:15:01 2006
New Revision: 480933

URL: http://svn.apache.org/viewvc?view=rev&rev=480933
Log:
fix for HARMONY-2241 ([classlib][beans] loadImage method of SimpleBeanInfo doesn't load image)

Added:
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java?view=diff&rev=480933&r1=480932&r2=480933
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
Thu Nov 30 06:15:01 2006
@@ -19,54 +19,20 @@
 
 import java.awt.Image;
 import java.awt.Toolkit;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.net.URL;
 
 public class SimpleBeanInfo implements BeanInfo {
 
-    public SimpleBeanInfo() {
-    }
+    public SimpleBeanInfo() {}
 
     public Image loadImage(String resourceName) {
-        byte[] result = null;
-        InputStream is = FileInputStream.class
-                .getResourceAsStream(resourceName);
-
-        if (is != null) {
-            ArrayList<Byte> byteArrayList = new ArrayList<Byte>();
-
-            byte b;
-            try {
-                while ((b = (byte) is.read()) != -1) {
-                    byteArrayList.add(new Byte(b));
-                }
-
-                result = new byte[byteArrayList.size()];
-
-                Iterator<Byte> i = byteArrayList.iterator();
-                int idx = 0;
-                while (i.hasNext()) {
-                    result[idx++] = i.next().byteValue();
-                }
-
-            } catch (IOException ioe) {
-                byteArrayList.clear();
-                System.out.println(ioe.getClass() + ": " + ioe.getMessage()); //$NON-NLS-1$
-            } finally {
-                try {
-                    is.close();
-                } catch (IOException ioe) {
-                    System.out.println(ioe.getClass() + ": " //$NON-NLS-1$
-                            + ioe.getMessage());
-                }
-            }
-
-            return Toolkit.getDefaultToolkit().createImage(result);
+        URL file = getClass().getResource(resourceName);
+        
+        if (file != null) {
+            return Toolkit.getDefaultToolkit().createImage(file);
+        } else {
+            return null;
         }
-        return null;
     }
 
     public PropertyDescriptor[] getPropertyDescriptors() {

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java?view=diff&rev=480933&r1=480932&r2=480933
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
Thu Nov 30 06:15:01 2006
@@ -88,5 +88,12 @@
         image = info.loadImage("/gif/test.gif");
         assertNotNull(image);
         assertTrue(image instanceof Image);
+
+        // regression for HARMONY-2241
+        info = new SimpleBeanInfo() {};
+        image = info.loadImage("testB.jpg");
+        assertNotNull(image);
+        assertTrue(image instanceof Image);
     }
+
 }

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg?view=auto&rev=480933
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message