harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r396540 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/ test/java/tests/api/java/io/
Date Mon, 24 Apr 2006 13:13:15 GMT
Author: mloenko
Date: Mon Apr 24 06:12:58 2006
New Revision: 396540

URL: http://svn.apache.org/viewcvs?rev=396540&view=rev
Log:
fixes for HARMONY-387:
luni.io: Harmony should throw exceptions in a way similar to RI's one

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ByteArrayOutputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayWriter.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedWriter.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedReaderTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedWriterTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ByteArrayOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ByteArrayOutputStream.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ByteArrayOutputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ByteArrayOutputStream.java
Mon Apr 24 06:12:58 2006
@@ -202,7 +202,7 @@
 				System.arraycopy(buffer, offset, buf, this.count, len);
 				this.count += len;
 			} else
-				throw new ArrayIndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
+				throw new IndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
 						.getString("K002f")); //$NON-NLS-1$
 		} else
 			throw new NullPointerException(org.apache.harmony.luni.util.Msg

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayWriter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayWriter.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayWriter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayWriter.java
Mon Apr 24 06:12:58 2006
@@ -165,7 +165,7 @@
 				this.count += len;
 			}
 		} else
-			throw new ArrayIndexOutOfBoundsException();
+			throw new IndexOutOfBoundsException();
 	}
 
 	/**
@@ -196,6 +196,10 @@
 	 *            the number of characters to retrieve and write.
 	 */
 	public void write(String str, int offset, int len) {
+        if (str == null) {
+            throw new NullPointerException(org.apache.harmony.luni.util.Msg
+                    .getString("K0347")); //$NON-NLS-1$
+        }
 		// avoid int overflow
 		if (0 <= offset && offset <= str.length() && 0 <= len
 				&& len <= str.length() - offset) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
Mon Apr 24 06:12:58 2006
@@ -99,7 +99,7 @@
 			for (int i = offset; i < offset + count; i++)
 				write(buffer[i]);
 		} else
-			throw new ArrayIndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
+			throw new IndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
 					.getString("K002f")); //$NON-NLS-1$
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
Mon Apr 24 06:12:58 2006
@@ -280,7 +280,7 @@
 		if (bytes == null) {
 			throw new NullPointerException();
 		}
-		throw new ArrayIndexOutOfBoundsException();
+		throw new IndexOutOfBoundsException();
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java
Mon Apr 24 06:12:58 2006
@@ -250,7 +250,7 @@
 				throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0078")); //$NON-NLS-1$
 			}
 		}
-		throw new ArrayIndexOutOfBoundsException();
+		throw new IndexOutOfBoundsException();
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedWriter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedWriter.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedWriter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedWriter.java
Mon Apr 24 06:12:58 2006
@@ -138,6 +138,10 @@
 	 *             If any of the arguments are out of bounds.
 	 */
 	public void write(char buffer[], int offset, int count) throws IOException {
+        if (buffer == null) {
+            throw new NullPointerException(org.apache.harmony.luni.util.Msg
+                    .getString("K0047")); //$NON-NLS-1$
+        }
 		// avoid int overflow
 		if (0 <= offset && offset <= buffer.length && 0 <= count
 				&& count <= buffer.length - offset) {
@@ -152,8 +156,9 @@
 					throw new IOException(org.apache.harmony.luni.util.Msg
 							.getString("K0078")); //$NON-NLS-1$
 			}
-		} else
-			throw new ArrayIndexOutOfBoundsException();
+		} else {
+			throw new IndexOutOfBoundsException();
+		}
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
Mon Apr 24 06:12:58 2006
@@ -120,7 +120,7 @@
 				this.buf.append(cbuf, offset, count);
 			}
 		} else {
-			throw new ArrayIndexOutOfBoundsException();
+			throw new IndexOutOfBoundsException();
 		}
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java
Mon Apr 24 06:12:58 2006
@@ -15,6 +15,8 @@
 
 package tests.api.java.io;
 
+import java.io.ByteArrayOutputStream;
+
 /**
  * Automated Test Suite for class java.io.ByteArrayOutputStream
  * 
@@ -204,6 +206,22 @@
 				new String(result, 0, result.length).equals(fileString
 						.substring(0, 100)));
 	}
+
+    /**
+     * @tests java.io.ByteArrayOutputStream#write(byte[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_write$BII_2() {
+        ByteArrayOutputStream obj = new ByteArrayOutputStream();
+        try {
+            obj.write(new byte [] {(byte)0x00}, -1, 0);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
 
 	/**
 	 * @tests java.io.ByteArrayOutputStream#writeTo(java.io.OutputStream)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java
Mon Apr 24 06:12:58 2006
@@ -135,6 +135,22 @@
 		}
 	}
 
+    /**
+     * @tests java.io.CharArrayWriter#write(char[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_write$CII_2() {
+        CharArrayWriter obj = new CharArrayWriter();
+        try {
+            obj.write(new char []{'0'}, 0, -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
+
 	/**
 	 * @tests java.io.CharArrayWriter#write(int)
 	 */
@@ -166,6 +182,19 @@
 			fail("Exception during write test : " + e.getMessage());
 		}
 	}
+
+    /**
+     * @tests java.io.CharArrayWriter#write(java.lang.String, int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_writeLjava_lang_StringII_2() throws StringIndexOutOfBoundsException
{
+        CharArrayWriter obj = new CharArrayWriter();
+        try {
+            obj.write((String) null, -1, 0);
+            fail("NullPointerException expected");
+        } catch (NullPointerException t) {
+        }
+    }
 
 	/**
 	 * @tests java.io.CharArrayWriter#writeTo(java.io.Writer)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
Mon Apr 24 06:12:58 2006
@@ -235,7 +235,55 @@
 		}
 	}
 
-	/**
+    /**
+     * @tests java.io.PipedInputStream#read(byte[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_read$BII_2() throws IOException {
+        PipedInputStream obj = new PipedInputStream();
+        try {
+            obj.read(new byte[0], 0, -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedInputStream#read(byte[], int, int)
+     */
+    public void test_read$BII_3() {
+        PipedInputStream obj = new PipedInputStream();
+        try {
+            obj.read(new byte[0], -1, 0);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        } catch (IOException t) {
+            fail("Unexpected IOException: " + t.getMessage());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedInputStream#read(byte[], int, int)
+     */
+    public void test_read$BII_4() {
+        PipedInputStream obj = new PipedInputStream();
+        try {
+            obj.read(new byte[0], -1, -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        } catch (IOException t) {
+            fail("Unexpected IOException: " + t.getMessage());
+        }
+    }
+
+    /**
 	 * @tests java.io.PipedInputStream#receive(int)
 	 */
 	public void test_receive() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java
Mon Apr 24 06:12:58 2006
@@ -167,6 +167,24 @@
 		}
 	}
 
+    /**
+     * @tests java.io.PipedOutputStream#write(byte[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_write$BII_2() throws IOException {
+        PipedInputStream pis = new PipedInputStream();
+        PipedOutputStream pos = null;
+        try{
+            pos = new PipedOutputStream(pis);
+            pos.write(new byte[0], -1, -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
+
 	/**
 	 * @tests java.io.PipedOutputStream#write(int)
 	 */

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedReaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedReaderTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedReaderTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedReaderTest.java
Mon Apr 24 06:12:58 2006
@@ -15,6 +15,7 @@
 
 package tests.api.java.io;
 
+import java.io.IOException;
 import java.io.PipedReader;
 import java.io.PipedWriter;
 
@@ -177,7 +178,61 @@
 		fail("Failed to throw exception reading from closed reader");
 	}
 
-	/**
+    /**
+     * @tests java.io.PipedReader#read(char[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_read$CII_2() throws IOException{
+        PipedWriter pw = new PipedWriter();
+        PipedReader obj = null;
+        try {
+            obj = new PipedReader(pw);
+            obj.read(new char[0], (int) 0, (int) -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedReader#read(char[], int, int)
+     */
+    public void test_read$CII_3() {
+        PipedWriter pw = new PipedWriter();
+        PipedReader obj = null;
+        try {
+            obj = new PipedReader(pw);
+            obj.read(new char[0], (int) -1, (int) 0);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        } catch (IOException e) {
+            fail("Unexpected IOException: " + e.getMessage());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedReader#read(char[], int, int)
+     */
+    public void test_read$CII_4() {
+        PipedWriter pw = new PipedWriter();
+        PipedReader obj = null;
+        try {
+            obj = new PipedReader(pw);
+            obj.read(new char[0], (int) -1, (int) -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        } catch (IOException e) {
+            fail("Unexpected IOException: " + e.getMessage());
+        }
+    }
+
+    /**
 	 * @tests java.io.PipedReader#ready()
 	 */
 	public void test_ready() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedWriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedWriterTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedWriterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/PipedWriterTest.java
Mon Apr 24 06:12:58 2006
@@ -184,7 +184,97 @@
 				.equals(new String(reader.buf)));
 	}
 
-	/**
+    /**
+     * @tests java.io.PipedWriter#write(char[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_write$CII_2() throws IOException {
+        PipedReader pr = new PipedReader();
+        PipedWriter obj = null;
+        try {
+            obj = new java.io.PipedWriter(pr);
+            obj.write(new char[0], (int) 0, (int) -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedWriter#write(char[], int, int)
+     */
+    public void test_write$CII_3() {
+        PipedReader pr = new PipedReader();
+        PipedWriter obj = null;
+        try {
+            obj = new java.io.PipedWriter(pr);
+            obj.write(new char[0], (int) -1, (int) 0);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        } catch (IOException e) {
+            fail("Unexpected IOException: " + e.getMessage());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedWriter#write(char[], int, int)
+     */
+    public void test_write$CII_4() {
+        PipedReader pr = new PipedReader();
+        PipedWriter obj = null;
+        try {
+            obj = new java.io.PipedWriter(pr);
+            obj.write(new char[0], (int) -1, (int) -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        } catch (IOException e) {
+            fail("Unexpected IOException: " + e.getMessage());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedWriter#write(char[], int, int)
+     */
+    public void test_write$CII_5() {
+        PipedReader pr = new PipedReader();
+        PipedWriter obj = null;
+        try {
+            obj = new PipedWriter(pr);
+            obj.write((char[]) null, (int) -1, (int) 0);
+            fail("NullPointerException expected");
+        } catch (IndexOutOfBoundsException t) {
+            fail("NullPointerException expected");
+        } catch (NullPointerException t) {
+        } catch (IOException e) {
+            fail("Unexpected IOException: " + e.getMessage());
+        }
+    }
+
+    /**
+     * @tests java.io.PipedWriter#write(char[], int, int)
+     */
+    public void test_write$CII_6() {
+        PipedReader pr = new PipedReader();
+        PipedWriter obj = null;
+        try {
+            obj = new PipedWriter(pr);
+            obj.write((char[]) null, (int) -1, (int) -1);
+            fail("NullPointerException expected");
+        } catch (IndexOutOfBoundsException t) {
+            fail("NullPointerException expected");
+        } catch (NullPointerException t) {
+        } catch (IOException e) {
+            fail("Unexpected IOException: " + e.getMessage());
+        }
+    }
+
+    /**
 	 * @tests java.io.PipedWriter#write(int)
 	 */
 	public void test_writeI() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java?rev=396540&r1=396539&r2=396540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java
Mon Apr 24 06:12:58 2006
@@ -87,6 +87,53 @@
 				"This is a test string"));
 	}
 
+    /**
+     * @tests java.io.StringWriter#write(char[], int, int)
+     * Regression for HARMONY-387
+     */
+    public void test_write$CII_2() {
+        StringWriter obj = null;
+        try {
+            obj = new StringWriter();
+            obj.write(new char[0], (int) 0, (int) -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+            assertEquals(
+                    "IndexOutOfBoundsException rather than a subclass expected",
+                    IndexOutOfBoundsException.class, t.getClass());
+        }
+    }
+
+    /**
+     * @tests java.io.StringWriter#write(char[], int, int)
+     */
+    public void test_write$CII_3() {
+        StringWriter obj = null;
+        try {
+            obj = new StringWriter();
+            obj.write(new char[0], (int) -1, (int) 0);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        }
+    }
+
+    /**
+     * @tests java.io.StringWriter#write(char[], int, int)
+     */
+    public void test_write$CII_4() {
+        StringWriter obj = null;
+        try {
+            obj = new StringWriter();
+            obj.write(new char[0], (int) -1, (int) -1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException t) {
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException t) {
+        }
+    }
+
 	/**
 	 * @tests java.io.StringWriter#write(int)
 	 */



Mime
View raw message