harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r399244 - in /incubator/harmony/enhanced/classlib/trunk/modules: beans/src/test/java/tests/api/java/beans/EventHandlerTest.java luni/src/main/java/java/io/FileInputStream.java luni/src/test/java/tests/api/java/io/FileInputStreamTest.java
Date Wed, 03 May 2006 10:41:18 GMT
Author: mloenko
Date: Wed May  3 03:41:13 2006
New Revision: 399244

URL: http://svn.apache.org/viewcvs?rev=399244&view=rev
Log:
fixes for HARMONY-434
java.io.FileInputStream.read(byte[] b,int off,int len) does not throw IndexOutOfBoundsException

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/EventHandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileInputStreamTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/EventHandlerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/EventHandlerTest.java?rev=399244&r1=399243&r2=399244&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/EventHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/EventHandlerTest.java
Wed May  3 03:41:13 2006
@@ -789,15 +789,15 @@
 	}
 
     /**
-     * @tests java.beans.EventHandler#create(Class<T> listenerInterface, Object
-     *        target, String action))
+     * @tests java.beans.EventHandler#create(java.lang.Class<T>,
+     *        java.lang.Object, java.lang.String))
      */
-	public void testEventHandlerCreate() {
-        //Regression for HARMONY-429
-		((FredListener) EventHandler.create(FredListener.class,
-				new Untitled1(), "i", "i"))
-				.fireFredEvent(new FredEvent("bean2"));
-	}
+    public void testEventHandlerCreate() {
+        // Regression for HARMONY-429
+        ((FredListener) EventHandler.create(FredListener.class,
+                new Untitled1(), "i", "i"))
+                .fireFredEvent(new FredEvent("bean2"));
+    }
 
     public interface FredListener extends EventListener {
 		public void fireFredEvent(FredEvent event);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java?rev=399244&r1=399243&r2=399244&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
Wed May  3 03:41:13 2006
@@ -245,7 +245,12 @@
 	 *             occurs.
 	 */
 	public int read(byte[] buffer, int offset, int count) throws IOException {
-		openCheck();
+        if (count < 0 || offset < 0 || offset > buffer.length
+                || count > buffer.length - offset) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        openCheck();
         synchronized (repositioningLock) {
             return (int) fileSystem.read(fd.descriptor, buffer, offset, count);
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileInputStreamTest.java?rev=399244&r1=399243&r2=399244&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileInputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileInputStreamTest.java
Wed May  3 03:41:13 2006
@@ -210,10 +210,44 @@
 		}
 	}
 
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int))
+     */
+    public void test_regressionNNN() throws IOException {
+        // Regression for HARMONY-434
+        FileInputStream fis = new java.io.FileInputStream(fileName);
+
+        try {
+            fis.read(new byte[1], -1, 1);
+            fail("IndexOutOfBoundsException must be thrown if off <0");
+        } catch (IndexOutOfBoundsException e) {}
+
+        try {
+            fis.read(new byte[1], 0, -1);
+            fail("IndexOutOfBoundsException must be thrown if len <0");
+        } catch (IndexOutOfBoundsException e) {}
+
+        try {
+            fis.read(new byte[1], 0, 5);
+            fail("IndexOutOfBoundsException must be thrown if off+len > b.lengh");
+        } catch (IndexOutOfBoundsException e) {}
+
+        try {
+            fis.read(new byte[10], Integer.MAX_VALUE, 5);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {}
+
+        try {
+            fis.read(new byte[10], 5, Integer.MAX_VALUE);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {}
+        fis.close();
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection. This method
+     * is called before a test is executed.
+     */
 	protected void setUp() {
 		try {
 			fileName = System.getProperty("user.dir");



Mime
View raw message