You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/15 12:47:39 UTC

svn commit: r386058 [5/49] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/archive/make/common/ modules/archive/src/test/java/tests/ modules/archive/src/test/java/tests/api/ modules/archive/src/test/java/tests/api/java/ modules/archive/s...

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,356 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import tests.support.Support_StringReader;
+
+public class BufferedReaderTest extends junit.framework.TestCase {
+
+	BufferedReader br;
+
+	String testString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\nTest_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\nTest_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\nTest_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\nTest_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\nTest_java_lang_ClassLoader\nTest_java_lang_Clas
 sNotFoundException\nTest_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_Ob
 ject\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_Socket
 Exception\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\nTest_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\nTest_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\nTest_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
+
+	/**
+	 * @tests java.io.BufferedReader#BufferedReader(java.io.Reader)
+	 */
+	public void test_ConstructorLjava_io_Reader() {
+		// Test for method java.io.BufferedReader(java.io.Reader)
+		assertTrue("Used in tests", true);
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#BufferedReader(java.io.Reader, int)
+	 */
+	public void test_ConstructorLjava_io_ReaderI() {
+		// Test for method java.io.BufferedReader(java.io.Reader, int)
+		assertTrue("Used in tests", true);
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.BufferedReader.close()
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			br.close();
+			br.read();
+			fail("Read on closed stream");
+		} catch (IOException x) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during close test " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#mark(int)
+	 */
+	public void test_markI() {
+		// Test for method void java.io.BufferedReader.mark(int)
+		char[] buf = null;
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			br.skip(500);
+			br.mark(1000);
+			br.skip(250);
+			br.reset();
+			buf = new char[testString.length()];
+			br.read(buf, 0, 500);
+			assertTrue("Failed to set mark properly", testString.substring(500,
+					1000).equals(new String(buf, 0, 500)));
+		} catch (java.io.IOException e) {
+			fail("Exception during mark test");
+		}
+		try {
+			br = new BufferedReader(new Support_StringReader(testString), 800);
+			br.skip(500);
+			br.mark(250);
+			br.read(buf, 0, 1000);
+			br.reset();
+			fail("Failed to invalidate mark properly");
+		} catch (IOException x) {
+		}
+
+		char[] chars = new char[256];
+		for (int i = 0; i < 256; i++)
+			chars[i] = (char) i;
+		Reader in = new BufferedReader(new Support_StringReader(new String(
+				chars)), 12);
+		try {
+			in.skip(6);
+			in.mark(14);
+			in.read(new char[14], 0, 14);
+			in.reset();
+			assertTrue("Wrong chars", in.read() == (char) 6
+					&& in.read() == (char) 7);
+		} catch (IOException e) {
+			fail("Exception during mark test 2:" + e);
+		}
+
+		in = new BufferedReader(new Support_StringReader(new String(chars)), 12);
+		try {
+			in.skip(6);
+			in.mark(8);
+			in.skip(7);
+			in.reset();
+			assertTrue("Wrong chars 2", in.read() == (char) 6
+					&& in.read() == (char) 7);
+		} catch (IOException e) {
+			fail("Exception during mark test 3:" + e);
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#markSupported()
+	 */
+	public void test_markSupported() {
+		// Test for method boolean java.io.BufferedReader.markSupported()
+		br = new BufferedReader(new Support_StringReader(testString));
+		assertTrue("markSupported returned false", br.markSupported());
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#read()
+	 */
+	public void test_read() {
+		// Test for method int java.io.BufferedReader.read()
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			int r = br.read();
+			assertTrue("Char read improperly", testString.charAt(0) == r);
+			br = new BufferedReader(new Support_StringReader(new String(
+					new char[] { '\u8765' })));
+			assertTrue("Wrong double byte character", br.read() == '\u8765');
+		} catch (java.io.IOException e) {
+			fail("Exception during read test");
+		}
+
+		char[] chars = new char[256];
+		for (int i = 0; i < 256; i++)
+			chars[i] = (char) i;
+		Reader in = new BufferedReader(new Support_StringReader(new String(
+				chars)), 12);
+		try {
+			assertTrue("Wrong initial char", in.read() == 0); // Fill the
+			// buffer
+			char[] buf = new char[14];
+			in.read(buf, 0, 14); // Read greater than the buffer
+			assertTrue("Wrong block read data", new String(buf)
+					.equals(new String(chars, 1, 14)));
+			assertTrue("Wrong chars", in.read() == 15); // Check next byte
+		} catch (IOException e) {
+			fail("Exception during read test 2:" + e);
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#read(char[], int, int)
+	 */
+	public void test_read$CII() {
+		char[] ca = new char[2];
+		BufferedReader toRet = new BufferedReader(new InputStreamReader(
+				new ByteArrayInputStream(new byte[0])));
+		try {
+			toRet.close();
+		} catch (IOException e) {
+			fail("unexpected 1: " + e);
+		}
+
+		/* Closed reader should throw IOException reading zero bytes */
+		try {
+			toRet.read(ca, 0, 0);
+			fail("Reading zero bytes on a closed reader should not work");
+		} catch (IOException e) {
+			// expected
+		}
+
+		/*
+		 * Closed reader should throw IOException in preference to index out of
+		 * bounds
+		 */
+		try {
+			// Read should throw IOException before
+			// ArrayIndexOutOfBoundException
+			toRet.read(ca, 1, 5);
+			fail("IOException should have been thrown");
+		} catch (IOException e) {
+			// expected
+		}
+
+		// Test to ensure that a drained stream returns 0 at EOF
+		toRet = new BufferedReader(new InputStreamReader(
+				new ByteArrayInputStream(new byte[2])));
+		try {
+			assertEquals("Emptying the reader should return two bytes", 2,
+					toRet.read(ca, 0, 2));
+			assertEquals("EOF on a reader should be -1", -1, toRet.read(ca, 0,
+					2));
+			assertEquals("Reading zero bytes at EOF should work", 0, toRet
+					.read(ca, 0, 0));
+		} catch (IOException ex) {
+			fail("Unexpected IOException : " + ex.getLocalizedMessage());
+		}
+
+		// Test for method int java.io.BufferedReader.read(char [], int, int)
+		try {
+			char[] buf = new char[testString.length()];
+			br = new BufferedReader(new Support_StringReader(testString));
+			br.read(buf, 50, 500);
+			assertTrue("Chars read improperly", new String(buf, 50, 500)
+					.equals(testString.substring(0, 500)));
+		} catch (java.io.IOException e) {
+			fail("Exception during read test");
+		}
+
+		BufferedReader bufin = new BufferedReader(new Reader() {
+			int size = 2, pos = 0;
+
+			char[] contents = new char[size];
+
+			public int read() throws IOException {
+				if (pos >= size)
+					throw new IOException("Read past end of data");
+				return contents[pos++];
+			}
+
+			public int read(char[] buf, int off, int len) throws IOException {
+				if (pos >= size)
+					throw new IOException("Read past end of data");
+				int toRead = len;
+				if (toRead > (size - pos))
+					toRead = size - pos;
+				System.arraycopy(contents, pos, buf, off, toRead);
+				pos += toRead;
+				return toRead;
+			}
+
+			public boolean ready() throws IOException {
+				return size - pos > 0;
+			}
+
+			public void close() throws IOException {
+			}
+		});
+		try {
+			bufin.read();
+			int result = bufin.read(new char[2], 0, 2);
+			assertTrue("Incorrect result: " + result, result == 1);
+		} catch (IOException e) {
+			fail("Unexpected: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#readLine()
+	 */
+	public void test_readLine() {
+		// Test for method java.lang.String java.io.BufferedReader.readLine()
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			String r = br.readLine();
+			assertTrue("readLine returned incorrect string", r
+					.equals("Test_All_Tests"));
+		} catch (java.io.IOException e) {
+			fail("Exception during readLine test");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#ready()
+	 */
+	public void test_ready() {
+		// Test for method boolean java.io.BufferedReader.ready()
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			assertTrue("ready returned false", br.ready());
+		} catch (java.io.IOException e) {
+			fail("Exception during ready test" + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.BufferedReader.reset()
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			br.skip(500);
+			br.mark(900);
+			br.skip(500);
+			br.reset();
+			char[] buf = new char[testString.length()];
+			br.read(buf, 0, 500);
+			assertTrue("Failed to reset properly", testString.substring(500,
+					1000).equals(new String(buf, 0, 500)));
+		} catch (java.io.IOException e) {
+			fail("Exception during reset test");
+		}
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			br.skip(500);
+			br.reset();
+			fail("Reset succeeded on unmarked stream");
+		} catch (IOException x) {
+			return;
+
+		}
+
+	}
+
+	/**
+	 * @tests java.io.BufferedReader#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.io.BufferedReader.skip(long)
+		try {
+			br = new BufferedReader(new Support_StringReader(testString));
+			br.skip(500);
+			char[] buf = new char[testString.length()];
+			br.read(buf, 0, 500);
+			assertTrue("Failed to set skip properly", testString.substring(500,
+					1000).equals(new String(buf, 0, 500)));
+		} catch (java.io.IOException e) {
+			fail("Exception during skip test");
+		}
+
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		try {
+			br.close();
+		} catch (Exception e) {
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,165 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+
+import tests.support.Support_StringWriter;
+
+public class BufferedWriterTest extends junit.framework.TestCase {
+
+	BufferedWriter bw;
+
+	Support_StringWriter sw;
+
+	public String testString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\nTest_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\nTest_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\nTest_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\nTest_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\nTest_java_lang_ClassLoader\nTest_java_la
 ng_ClassNotFoundException\nTest_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_
 lang_Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net
 _SocketException\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\nTest_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\nTest_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\nTest_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
+
+	/**
+	 * @tests java.io.BufferedWriter#BufferedWriter(java.io.Writer)
+	 */
+	public void test_ConstructorLjava_io_Writer() {
+		// Test for method java.io.BufferedWriter(java.io.Writer)
+
+		sw = new Support_StringWriter();
+		bw = new BufferedWriter(sw);
+		sw.write("Hi");
+		assertTrue("Constructor failed", sw.toString().equals("Hi"));
+
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#BufferedWriter(java.io.Writer, int)
+	 */
+	public void test_ConstructorLjava_io_WriterI() {
+		// Test for method java.io.BufferedWriter(java.io.Writer, int)
+		assertTrue("Used in tests", true);
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.BufferedWriter.close()
+		try {
+			bw.close();
+			bw.write(testString);
+		} catch (IOException e) {
+		}
+		assertTrue("Write after close", !sw.toString().equals(testString));
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#flush()
+	 */
+	public void test_flush() {
+		// Test for method void java.io.BufferedWriter.flush()
+		try {
+			bw.write("This should not cause a flush");
+			assertTrue("Bytes written without flush", sw.toString().equals(""));
+			bw.flush();
+			assertTrue("Bytes not flushed", sw.toString().equals(
+					"This should not cause a flush"));
+		} catch (Exception e) {
+			fail("Exception during flush test");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#newLine()
+	 */
+	public void test_newLine() {
+		// Test for method void java.io.BufferedWriter.newLine()
+		try {
+			String separator = System.getProperty("line.separator");
+			bw.write("Hello");
+			bw.newLine();
+			bw.write("World");
+			bw.flush();
+			assertTrue("Incorrect string written: " + sw.toString(), sw
+					.toString().equals("Hello" + separator + "World"));
+		} catch (Exception e) {
+			fail("Exception during write test");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#write(char[], int, int)
+	 */
+	public void test_write$CII() {
+		// Test for method void java.io.BufferedWriter.write(char [], int, int)
+		try {
+			bw.write(testString, 500, 1000);
+			bw.flush();
+			assertTrue("Incorrect string written", sw.toString().equals(
+					testString.substring(500, 1500)));
+		} catch (Exception e) {
+			fail("Exception during write test");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#write(int)
+	 */
+	public void test_writeI() {
+		// Test for method void java.io.BufferedWriter.write(int)
+		try {
+			bw.write('T');
+			assertTrue("Char written without flush", sw.toString().equals(""));
+			bw.flush();
+			assertTrue("Incorrect char written", sw.toString().equals("T"));
+		} catch (Exception e) {
+			fail("Exception during write test");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedWriter#write(java.lang.String, int, int)
+	 */
+	public void test_writeLjava_lang_StringII() {
+		// Test for method void java.io.BufferedWriter.write(java.lang.String,
+		// int, int)
+		try {
+			bw.write(testString);
+			bw.flush();
+			assertTrue("Incorrect string written", sw.toString().equals(
+					testString));
+		} catch (Exception e) {
+			fail("Exception during write test");
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		sw = new Support_StringWriter();
+		bw = new BufferedWriter(sw, 500);
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+
+		try {
+			bw.close();
+		} catch (Exception e) {
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,218 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+public class ByteArrayInputStreamTest extends junit.framework.TestCase {
+
+	private java.io.InputStream is;
+
+	public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\n";
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#ByteArrayInputStream(byte[])
+	 */
+	public void test_Constructor$B() {
+		// Test for method java.io.ByteArrayInputStream(byte [])
+
+		java.io.InputStream bis = new java.io.ByteArrayInputStream(fileString
+				.getBytes());
+
+		try {
+			assertTrue("Unable to create ByteArrayInputStream",
+					bis.available() == fileString.length());
+		} catch (Exception e) {
+			System.out.println("Exception during Constructor test");
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#ByteArrayInputStream(byte[], int,
+	 *        int)
+	 */
+	public void test_Constructor$BII() {
+		// Test for method java.io.ByteArrayInputStream(byte [], int, int)
+
+		byte[] zz = fileString.getBytes();
+		java.io.InputStream bis = new java.io.ByteArrayInputStream(zz, 0, 100);
+
+		try {
+			assertTrue("Unable to create ByteArrayInputStream",
+					bis.available() == 100);
+		} catch (Exception e) {
+			fail("Exception during Constructor test");
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#available()
+	 */
+	public void test_available() {
+		// Test for method int java.io.ByteArrayInputStream.available()
+		try {
+			assertTrue("Returned incorrect number of available bytes", is
+					.available() == fileString.length());
+		} catch (Exception e) {
+			fail("Exception during available test");
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.ByteArrayInputStream.close()
+		try {
+			is.read();
+		} catch (java.io.IOException e) {
+			fail("Failed reading from input stream");
+		}
+		try {
+			is.close();
+		} catch (java.io.IOException e) {
+			fail("Failed closing input stream");
+		}
+		try {
+			is.read();
+		} catch (Exception e) {
+			fail("Should be able to read from closed stream");
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#mark(int)
+	 */
+	public void test_markI() {
+		// Test for method void java.io.ByteArrayInputStream.mark(int)
+		byte[] buf1 = new byte[100];
+		byte[] buf2 = new byte[100];
+		try {
+			is.skip(3000);
+			is.mark(1000);
+			is.read(buf1, 0, buf1.length);
+			is.reset();
+			is.read(buf2, 0, buf2.length);
+			is.reset();
+			assertTrue("Failed to mark correct position", new String(buf1, 0,
+					buf1.length).equals(new String(buf2, 0, buf2.length)));
+
+		} catch (Exception e) {
+			fail("Exception during mark test");
+		}
+
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#markSupported()
+	 */
+	public void test_markSupported() {
+		// Test for method boolean java.io.ByteArrayInputStream.markSupported()
+		assertTrue("markSupported returned incorrect value", is.markSupported());
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#read()
+	 */
+	public void test_read() {
+		// Test for method int java.io.ByteArrayInputStream.read()
+		try {
+
+			int c = is.read();
+			is.reset();
+			assertTrue("read returned incorrect char", c == fileString
+					.charAt(0));
+		} catch (Exception e) {
+			fail("Exception during read test");
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#read(byte[], int, int)
+	 */
+	public void test_read$BII() {
+		// Test for method int java.io.ByteArrayInputStream.read(byte [], int,
+		// int)
+		byte[] buf1 = new byte[20];
+		try {
+			is.skip(50);
+			is.mark(100);
+			is.read(buf1, 0, buf1.length);
+			assertTrue("Failed to read correct data", new String(buf1, 0,
+					buf1.length).equals(fileString.substring(50, 70)));
+
+		} catch (Exception e) {
+			fail("Exception during read test: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.ByteArrayInputStream.reset()
+		byte[] buf1 = new byte[10];
+		byte[] buf2 = new byte[10];
+		try {
+			is.mark(200);
+			is.read(buf1, 0, 10);
+			is.reset();
+			is.read(buf2, 0, 10);
+			is.reset();
+			assertTrue("Reset failed", new String(buf1, 0, buf1.length)
+					.equals(new String(buf2, 0, buf2.length)));
+		} catch (Exception e) {
+			fail("Exception during reset test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayInputStream#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.io.ByteArrayInputStream.skip(long)
+		byte[] buf1 = new byte[10];
+		try {
+			is.skip(100);
+			is.read(buf1, 0, buf1.length);
+			assertTrue("Failed to skip to correct position", new String(buf1,
+					0, buf1.length).equals(fileString.substring(100, 110)));
+		} catch (Exception e) {
+			fail("Exception during skip test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+
+		is = new java.io.ByteArrayInputStream(fileString.getBytes());
+
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+
+		try {
+			is.close();
+
+		} catch (Exception e) {
+		}
+	}
+}

Added: 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=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,225 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+/**
+ * Automated Test Suite for class java.io.ByteArrayOutputStream
+ * 
+ * @see java.io.ByteArrayOutputStream
+ */
+
+public class ByteArrayOutputStreamTest extends junit.framework.TestCase {
+
+	java.io.ByteArrayOutputStream bos = null;
+
+	public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_ByteArrayOutputStream\nTest_java_io_DataInputStream\n";
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		try {
+			bos.close();
+		} catch (Exception e) {
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#ByteArrayOutputStream(int)
+	 */
+	public void test_ConstructorI() {
+		// Test for method java.io.ByteArrayOutputStream(int)
+		bos = new java.io.ByteArrayOutputStream(100);
+		assertTrue("Failed to create stream", bos.size() == 0);
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#ByteArrayOutputStream()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.ByteArrayOutputStream()
+		bos = new java.io.ByteArrayOutputStream();
+		assertTrue("Failed to create stream", bos.size() == 0);
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.ByteArrayOutputStream.close()
+
+		assertTrue(
+				"close() does nothing for this implementation of OutputSteam",
+				true);
+
+		// The spec seems to say that a closed output stream can't be written
+		// to. We don't throw an exception if attempt is made to write.
+		// Right now our implementation doesn't do anything testable but
+		// should we decide to throw an exception if a closed stream is
+		// written to, the appropriate test is commented out below.
+
+		/***********************************************************************
+		 * java.io.ByteArrayOutputStream bos = new
+		 * java.io.ByteArrayOutputStream(); bos.write (fileString.getBytes(), 0,
+		 * 100); try { bos.close(); } catch (java.io.IOException e) {
+		 * fail("IOException closing stream"); } try { bos.write
+		 * (fileString.getBytes(), 0, 100); bos.toByteArray(); fail("Wrote
+		 * to closed stream"); } catch (Exception e) { }
+		 **********************************************************************/
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.ByteArrayOutputStream.reset()
+		bos = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, 100);
+		bos.reset();
+		assertTrue("reset failed", bos.size() == 0);
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#size()
+	 */
+	public void test_size() {
+		// Test for method int java.io.ByteArrayOutputStream.size()
+		bos = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, 100);
+		assertTrue("size test failed", bos.size() == 100);
+		bos.reset();
+		assertTrue("size test failed", bos.size() == 0);
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#toByteArray()
+	 */
+	public void test_toByteArray() {
+		// Test for method byte [] java.io.ByteArrayOutputStream.toByteArray()
+		byte[] bytes;
+		byte[] sbytes = fileString.getBytes();
+		bos = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, fileString.length());
+		bytes = bos.toByteArray();
+		for (int i = 0; i < fileString.length(); i++)
+			assertTrue("Error in byte array", bytes[i] == sbytes[i]);
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#toString(java.lang.String)
+	 */
+	public void test_toStringLjava_lang_String() {
+		// Test for method java.lang.String
+		// java.io.ByteArrayOutputStream.toString(java.lang.String)
+		java.io.ByteArrayOutputStream bos;
+		bos = new java.io.ByteArrayOutputStream();
+		try {
+			bos.write(fileString.getBytes(), 0, fileString.length());
+			assertTrue("Returned incorrect 8859-1 String", bos.toString(
+					"8859_1").equals(fileString));
+		} catch (java.io.UnsupportedEncodingException e) {
+			fail(
+					"Threw an UnsupportedEncodingException for ISO 8859-1 encoding");
+		}
+		bos = new java.io.ByteArrayOutputStream();
+		try {
+			bos.write(fileString.getBytes(), 0, fileString.length());
+			assertTrue("Returned incorrect 8859-2 String", bos.toString(
+					"8859_2").equals(fileString));
+		} catch (java.io.UnsupportedEncodingException e) {
+			fail(
+					"Threw an UnsupportedEncodingException for 8859-2 encoding");
+		}
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String
+		// java.io.ByteArrayOutputStream.toString()
+		java.io.ByteArrayOutputStream bos = null;
+		bos = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, fileString.length());
+		assertTrue("Returned incorrect String", bos.toString().equals(
+				fileString));
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#toString(int)
+	 */
+	public void test_toStringI() {
+		// Test for method java.lang.String
+		// java.io.ByteArrayOutputStream.toString(int)
+		java.io.ByteArrayOutputStream bos = null;
+		bos = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, fileString.length());
+		assertTrue("Returned incorrect String",
+				bos.toString(5).length() == fileString.length());
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#write(int)
+	 */
+	public void test_writeI() {
+		// Test for method void java.io.ByteArrayOutputStream.write(int)
+		bos = new java.io.ByteArrayOutputStream();
+		bos.write('t');
+		byte[] result = bos.toByteArray();
+		assertTrue("Wrote incorrect bytes",
+				new String(result, 0, result.length).equals("t"));
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#write(byte[], int, int)
+	 */
+	public void test_write$BII() {
+		// Test for method void java.io.ByteArrayOutputStream.write(byte [],
+		// int, int)
+		java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, 100);
+		byte[] result = bos.toByteArray();
+		assertTrue("Wrote incorrect bytes",
+				new String(result, 0, result.length).equals(fileString
+						.substring(0, 100)));
+	}
+
+	/**
+	 * @tests java.io.ByteArrayOutputStream#writeTo(java.io.OutputStream)
+	 */
+	public void test_writeToLjava_io_OutputStream() {
+		// Test for method void
+		// java.io.ByteArrayOutputStream.writeTo(java.io.OutputStream)
+		java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
+		java.io.ByteArrayOutputStream bos2 = new java.io.ByteArrayOutputStream();
+		bos.write(fileString.getBytes(), 0, 100);
+		try {
+			bos.writeTo(bos2);
+		} catch (java.io.IOException e) {
+			fail("Threw IOException during writeTo : " + e.getMessage());
+		}
+		assertTrue("Returned incorrect String", bos2.toString().equals(
+				fileString.substring(0, 100)));
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,215 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.CharArrayReader;
+import java.io.IOException;
+
+public class CharArrayReaderTest extends junit.framework.TestCase {
+
+	char[] hw = { 'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd' };
+
+	CharArrayReader cr;
+
+	/**
+	 * @tests java.io.CharArrayReader#CharArrayReader(char[])
+	 */
+	public void test_Constructor$C() {
+		// Test for method java.io.CharArrayReader(char [])
+
+		try {
+			cr = new CharArrayReader(hw);
+			assertTrue("Failed to create reader", cr.ready());
+		} catch (IOException e) {
+			fail("Exception determining ready state : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#CharArrayReader(char[], int, int)
+	 */
+	public void test_Constructor$CII() {
+		// Test for method java.io.CharArrayReader(char [], int, int)
+		try {
+			cr = new CharArrayReader(hw, 5, 5);
+			assertTrue("Failed to create reader", cr.ready());
+		} catch (IOException e) {
+			fail("Exception determining ready state : " + e.getMessage());
+		}
+		try {
+			int c = cr.read();
+			assertTrue("Created incorrect reader--returned '" + (char) c
+					+ "' intsead of 'W'", c == 'W');
+		} catch (IOException e) {
+			fail("Exception reading from new reader : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.CharArrayReader.close()
+		cr = new CharArrayReader(hw);
+		cr.close();
+		try {
+			cr.read();
+		} catch (IOException e) { // Correct
+			return;
+		}
+		fail("Failed to throw exception on reqad from closed stream");
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#mark(int)
+	 */
+	public void test_markI() {
+		// Test for method void java.io.CharArrayReader.mark(int)
+		try {
+			cr = new CharArrayReader(hw);
+			cr.skip(5L);
+			cr.mark(100);
+			cr.read();
+			cr.reset();
+			assertTrue("Failed to mark correct position", cr.read() == 'W');
+		} catch (IOException e) {
+			fail("Exception during mark test: " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#markSupported()
+	 */
+	public void test_markSupported() {
+		// Test for method boolean java.io.CharArrayReader.markSupported()
+		cr = new CharArrayReader(hw);
+		assertTrue("markSupported returned false", cr.markSupported());
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#read()
+	 */
+	public void test_read() {
+		// Test for method int java.io.CharArrayReader.read()
+		try {
+			cr = new CharArrayReader(hw);
+			assertTrue("Read returned incorrect char", cr.read() == 'H');
+			cr = new CharArrayReader(new char[] { '\u8765' });
+			assertTrue("Incorrect double byte char", cr.read() == '\u8765');
+		} catch (IOException e) {
+			fail("Exception during read test: " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#read(char[], int, int)
+	 */
+	public void test_read$CII() {
+		// Test for method int java.io.CharArrayReader.read(char [], int, int)
+		char[] c = new char[11];
+		try {
+			cr = new CharArrayReader(hw);
+			cr.read(c, 1, 10);
+			assertTrue("Read returned incorrect chars", new String(c, 1, 10)
+					.equals(new String(hw, 0, 10)));
+		} catch (IOException e) {
+			fail("Exception during read test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#ready()
+	 */
+	public void test_ready() {
+		// Test for method boolean java.io.CharArrayReader.ready()
+		cr = new CharArrayReader(hw);
+		boolean expectException = false;
+		try {
+			assertTrue("ready returned false", cr.ready());
+			cr.skip(1000);
+			assertTrue("ready returned true", !cr.ready());
+			cr.close();
+			expectException = true;
+			cr.ready();
+			fail("No exception 1");
+		} catch (IOException e) {
+			if (!expectException)
+				fail("Unexpected: " + e);
+		}
+		try {
+			cr = new CharArrayReader(hw);
+			cr.close();
+			cr.ready();
+			fail("No exception 2");
+		} catch (IOException e) {
+		}
+
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.CharArrayReader.reset()
+		try {
+			cr = new CharArrayReader(hw);
+			cr.skip(5L);
+			cr.mark(100);
+			cr.read();
+			cr.reset();
+			assertTrue("Reset failed to return to marker position",
+					cr.read() == 'W');
+		} catch (IOException e) {
+			fail("Exception during reset test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayReader#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.io.CharArrayReader.skip(long)
+		long skipped = 0;
+		try {
+			cr = new CharArrayReader(hw);
+			skipped = cr.skip(5L);
+		} catch (IOException e) {
+			fail("Exception during skip test : " + e.getMessage());
+		}
+		assertTrue("Failed to skip correct number of chars", skipped == 5L);
+		try {
+			assertTrue("Skip skipped wrong chars", cr.read() == 'W');
+		} catch (IOException e) {
+			fail("read exception during skip test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		if (cr != null)
+			cr.close();
+	}
+}

Added: 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=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,203 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+
+public class CharArrayWriterTest extends junit.framework.TestCase {
+
+	char[] hw = { 'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd' };
+
+	CharArrayWriter cw;
+
+	CharArrayReader cr;
+
+	/**
+	 * @tests java.io.CharArrayWriter#CharArrayWriter()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.CharArrayWriter()
+		cw = new CharArrayWriter(90);
+		assertTrue("Created incorrect writer", cw.size() == 0);
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#CharArrayWriter(int)
+	 */
+	public void test_ConstructorI() {
+		// Test for method java.io.CharArrayWriter(int)
+		cw = new CharArrayWriter();
+		assertTrue("Created incorrect writer", cw.size() == 0);
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.CharArrayWriter.close()
+		cw.close();
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#flush()
+	 */
+	public void test_flush() {
+		// Test for method void java.io.CharArrayWriter.flush()
+		cw.flush();
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.CharArrayWriter.reset()
+		cw.write("HelloWorld", 5, 5);
+		cw.reset();
+		cw.write("HelloWorld", 0, 5);
+		cr = new CharArrayReader(cw.toCharArray());
+		try {
+			char[] c = new char[100];
+			cr.read(c, 0, 5);
+			assertTrue("Reset failed to reset buffer", "Hello"
+					.equals(new String(c, 0, 5)));
+		} catch (IOException e) {
+			fail("Exception during reset test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#size()
+	 */
+	public void test_size() {
+		// Test for method int java.io.CharArrayWriter.size()
+		assertTrue("Returned incorrect size", cw.size() == 0);
+		cw.write(hw, 5, 5);
+		assertTrue("Returned incorrect size", cw.size() == 5);
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#toCharArray()
+	 */
+	public void test_toCharArray() {
+		// Test for method char [] java.io.CharArrayWriter.toCharArray()
+		cw.write("HelloWorld", 0, 10);
+		cr = new CharArrayReader(cw.toCharArray());
+		try {
+			char[] c = new char[100];
+			cr.read(c, 0, 10);
+			assertTrue("toCharArray failed to return correct array",
+					"HelloWorld".equals(new String(c, 0, 10)));
+		} catch (IOException e) {
+			fail("Exception during toCharArray test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String java.io.CharArrayWriter.toString()
+		cw.write("HelloWorld", 5, 5);
+		cr = new CharArrayReader(cw.toCharArray());
+		assertTrue("Returned incorrect string", "World".equals(cw.toString()));
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#write(char[], int, int)
+	 */
+	public void test_write$CII() {
+		// Test for method void java.io.CharArrayWriter.write(char [], int, int)
+		cw.write(hw, 5, 5);
+		cr = new CharArrayReader(cw.toCharArray());
+		try {
+			char[] c = new char[100];
+			cr.read(c, 0, 5);
+			assertTrue("Writer failed to write correct chars", "World"
+					.equals(new String(c, 0, 5)));
+		} catch (IOException e) {
+			fail("Exception during write test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#write(int)
+	 */
+	public void test_writeI() {
+		// Test for method void java.io.CharArrayWriter.write(int)
+		cw.write('T');
+		cr = new CharArrayReader(cw.toCharArray());
+		try {
+			assertTrue("Writer failed to write char", cr.read() == 'T');
+		} catch (IOException e) {
+			fail("Exception during write test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#write(java.lang.String, int, int)
+	 */
+	public void test_writeLjava_lang_StringII() {
+		// Test for method void java.io.CharArrayWriter.write(java.lang.String,
+		// int, int)
+		cw.write("HelloWorld", 5, 5);
+		cr = new CharArrayReader(cw.toCharArray());
+		try {
+			char[] c = new char[100];
+			cr.read(c, 0, 5);
+			assertTrue("Writer failed to write correct chars", "World"
+					.equals(new String(c, 0, 5)));
+		} catch (IOException e) {
+			fail("Exception during write test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.CharArrayWriter#writeTo(java.io.Writer)
+	 */
+	public void test_writeToLjava_io_Writer() {
+		// Test for method void java.io.CharArrayWriter.writeTo(java.io.Writer)
+		cw.write("HelloWorld", 0, 10);
+		StringWriter sw = new StringWriter();
+		try {
+			cw.writeTo(sw);
+			assertTrue("Writer failed to write correct chars", "HelloWorld"
+					.equals(sw.toString()));
+		} catch (IOException e) {
+			fail("Exception during writeTo test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		cw = new CharArrayWriter();
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		if (cr != null)
+			cr.close();
+		cw.close();
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,67 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+public class CharConversionExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.CharConversionException#CharConversionException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.CharConversionException()
+		// Currently, there are no refs to CharConversionException so this is
+		// the best test we can do
+		try {
+			if (true) // BB: getting around LF
+				throw new java.io.CharConversionException();
+			fail("Exception not thrown");
+		} catch (java.io.CharConversionException e) {
+			assertTrue(
+					"Exception defined with no message answers non-null to getMessage()",
+					e.getMessage() == null);
+		}
+	}
+
+	/**
+	 * @tests java.io.CharConversionException#CharConversionException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.CharConversionException(java.lang.String)
+		try {
+			if (true) // getting around LF
+				throw new java.io.CharConversionException("Blah");
+			fail("Exception not thrown");
+		} catch (java.io.CharConversionException e) {
+			assertTrue(
+					"Exception defined with no message answers non-null to getMessage()",
+					e.getMessage().equals("Blah"));
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,392 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package tests.api.java.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+
+public class DataInputStreamTest extends junit.framework.TestCase {
+
+	private DataOutputStream os;
+
+	private DataInputStream dis;
+
+	private ByteArrayOutputStream bos;
+
+	String unihw = "\u0048\u0065\u006C\u006C\u006F\u0020\u0057\u006F\u0072\u006C\u0064";
+
+	public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_DataInputStream\n";
+
+	/**
+	 * @tests java.io.DataInputStream#DataInputStream(java.io.InputStream)
+	 */
+	public void test_ConstructorLjava_io_InputStream() {
+		// Test for method java.io.DataInputStream(java.io.InputStream)
+		try {
+			os.writeChar('t');
+			os.close();
+			openDataInputStream();
+		} catch (IOException e) {
+			fail("IOException during constructor test : " + e.getMessage());
+		} finally {
+			try {
+				dis.close();
+			} catch (IOException e) {
+				fail("IOException during constructor test : " + e.getMessage());
+			}
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#read(byte[])
+	 */
+	public void test_read$B() {
+		// Test for method int java.io.DataInputStream.read(byte [])
+		try {
+			os.write(fileString.getBytes());
+			os.close();
+			openDataInputStream();
+			byte rbytes[] = new byte[fileString.length()];
+			dis.read(rbytes);
+			assertTrue("Incorrect data read", new String(rbytes, 0, fileString
+					.length()).equals(fileString));
+		} catch (IOException e) {
+			fail("IOException during read test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#read(byte[], int, int)
+	 */
+	public void test_read$BII() {
+		// Test for method int java.io.DataInputStream.read(byte [], int, int)
+		try {
+			os.write(fileString.getBytes());
+			os.close();
+			openDataInputStream();
+			byte rbytes[] = new byte[fileString.length()];
+			dis.read(rbytes, 0, rbytes.length);
+			assertTrue("Incorrect data read", new String(rbytes, 0, fileString
+					.length()).equals(fileString));
+		} catch (IOException e) {
+			fail("IOException during read test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readBoolean()
+	 */
+	public void test_readBoolean() {
+		// Test for method boolean java.io.DataInputStream.readBoolean()
+		try {
+			os.writeBoolean(true);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect boolean written", dis.readBoolean() == true);
+		} catch (IOException e) {
+			fail("readBoolean test failed : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readByte()
+	 */
+	public void test_readByte() {
+		// Test for method byte java.io.DataInputStream.readByte()
+		try {
+			os.writeByte((byte) 127);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect byte read", dis.readByte() == (byte) 127);
+		} catch (IOException e) {
+			fail("IOException during readByte test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readChar()
+	 */
+	public void test_readChar() {
+		// Test for method char java.io.DataInputStream.readChar()
+		try {
+			os.writeChar('t');
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect char read", dis.readChar() == 't');
+		} catch (IOException e) {
+			fail("IOException during readChar test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readDouble()
+	 */
+	public void test_readDouble() {
+		// Test for method double java.io.DataInputStream.readDouble()
+		try {
+			os.writeDouble(2345.76834720202);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect double read",
+					dis.readDouble() == 2345.76834720202);
+		} catch (IOException e) {
+			fail("IOException during readDouble test" + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readFloat()
+	 */
+	public void test_readFloat() {
+		// Test for method float java.io.DataInputStream.readFloat()
+		try {
+			os.writeFloat(29.08764f);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect float read", dis.readFloat() == 29.08764f);
+		} catch (IOException e) {
+			fail("readFloat test failed : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readFully(byte[])
+	 */
+	public void test_readFully$B() {
+		// Test for method void java.io.DataInputStream.readFully(byte [])
+		try {
+			os.write(fileString.getBytes());
+			os.close();
+			openDataInputStream();
+			byte rbytes[] = new byte[fileString.length()];
+			dis.readFully(rbytes);
+			assertTrue("Incorrect data read", new String(rbytes, 0, fileString
+					.length()).equals(fileString));
+		} catch (IOException e) {
+			fail("IOException during readFully test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readFully(byte[], int, int)
+	 */
+	public void test_readFully$BII() {
+		// Test for method void java.io.DataInputStream.readFully(byte [], int,
+		// int)
+		try {
+			os.write(fileString.getBytes());
+			os.close();
+			openDataInputStream();
+			byte rbytes[] = new byte[fileString.length()];
+			dis.readFully(rbytes, 0, fileString.length());
+			assertTrue("Incorrect data read", new String(rbytes, 0, fileString
+					.length()).equals(fileString));
+		} catch (IOException e) {
+			fail("IOException during readFully test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readInt()
+	 */
+	public void test_readInt() {
+		// Test for method int java.io.DataInputStream.readInt()
+		try {
+			os.writeInt(768347202);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect int read", dis.readInt() == 768347202);
+		} catch (IOException e) {
+			fail("IOException during readInt test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readLine()
+	 */
+	public void test_readLine() {
+		// Test for method java.lang.String java.io.DataInputStream.readLine()
+		try {
+			os.writeBytes("Hello");
+			os.close();
+			openDataInputStream();
+			String line = dis.readLine();
+			assertTrue("Incorrect line read: " + line, line.equals("Hello"));
+		} catch (IOException e) {
+			fail("IOException during readLine test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readLong()
+	 */
+	public void test_readLong() {
+		// Test for method long java.io.DataInputStream.readLong()
+		try {
+			os.writeLong(9875645283333L);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect long read", dis.readLong() == 9875645283333L);
+		} catch (IOException e) {
+			fail("read long test failed : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readShort()
+	 */
+	public void test_readShort() {
+		// Test for method short java.io.DataInputStream.readShort()
+		try {
+			os.writeShort(9875);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect short read", dis.readShort() == (short) 9875);
+		} catch (IOException e) {
+			fail("Exception during read short test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readUnsignedByte()
+	 */
+	public void test_readUnsignedByte() {
+		// Test for method int java.io.DataInputStream.readUnsignedByte()
+		try {
+			os.writeByte((byte) -127);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect byte read", dis.readUnsignedByte() == 129);
+		} catch (IOException e) {
+			fail("IOException during readUnsignedByte test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readUnsignedShort()
+	 */
+	public void test_readUnsignedShort() {
+		// Test for method int java.io.DataInputStream.readUnsignedShort()
+		try {
+			os.writeShort(9875);
+			os.close();
+			openDataInputStream();
+			assertTrue("Incorrect short read", dis.readUnsignedShort() == 9875);
+		} catch (IOException e) {
+			fail("Exception during readShort test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readUTF()
+	 */
+	public void test_readUTF() {
+		// Test for method java.lang.String java.io.DataInputStream.readUTF()
+		try {
+			os.writeUTF(unihw);
+			os.close();
+			openDataInputStream();
+			assertTrue("Failed to write string in UTF format",
+					dis.available() == unihw.length() + 2);
+			assertTrue("Incorrect string read", dis.readUTF().equals(unihw));
+		} catch (Exception e) {
+			fail("Exception during readUTF : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#readUTF(java.io.DataInput)
+	 */
+	public void test_readUTFLjava_io_DataInput() {
+		// Test for method java.lang.String
+		// java.io.DataInputStream.readUTF(java.io.DataInput)
+		try {
+			os.writeUTF(unihw);
+			os.close();
+			openDataInputStream();
+			assertTrue("Failed to write string in UTF format",
+					dis.available() == unihw.length() + 2);
+			assertTrue("Incorrect string read", DataInputStream.readUTF(dis)
+					.equals(unihw));
+		} catch (Exception e) {
+			fail("Exception during readUTF : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataInputStream#skipBytes(int)
+	 */
+	public void test_skipBytesI() {
+		// Test for method int java.io.DataInputStream.skipBytes(int)
+		try {
+			byte fileBytes[] = fileString.getBytes();
+			os.write(fileBytes);
+			os.close();
+			openDataInputStream();
+			dis.skipBytes(100);
+			byte rbytes[] = new byte[fileString.length()];
+			dis.read(rbytes, 0, 50);
+			dis.close();
+			assertTrue("Incorrect data read", new String(rbytes, 0, 50)
+					.equals(fileString.substring(100, 150)));
+		} catch (IOException e) {
+			fail("IOException during skipBytes test 1 : " + e.getMessage());
+		}
+		try {
+			// boolean eofException = false; //what is this var for?
+			int skipped = 0;
+			openDataInputStream();
+			try {
+				skipped = dis.skipBytes(50000);
+			} catch (EOFException e) {
+				// eofException = true;
+			}
+			;
+			assertTrue("Skipped should report " + fileString.length() + " not "
+					+ skipped, skipped == fileString.length());
+		} catch (IOException e) {
+			fail("IOException during skipBytes test 2 : " + e.getMessage());
+		}
+	}
+
+	private void openDataInputStream() throws IOException {
+		dis = new DataInputStream(new ByteArrayInputStream(bos.toByteArray()));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		bos = new ByteArrayOutputStream();
+		os = new DataOutputStream(bos);
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		try {
+			os.close();
+			dis.close();
+		} catch (Exception e) {
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,338 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+public class DataOutputStreamTest extends junit.framework.TestCase {
+
+	private DataOutputStream os;
+
+	private DataInputStream dis;
+
+	private ByteArrayOutputStream bos;
+
+	String unihw = "\u0048\u0065\u006C\u006C\u006F\u0020\u0057\u006F\u0072\u006C\u0064";
+
+	public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\n";
+
+	/**
+	 * @tests java.io.DataOutputStream#DataOutputStream(java.io.OutputStream)
+	 */
+	public void test_ConstructorLjava_io_OutputStream() {
+		// Test for method java.io.DataOutputStream(java.io.OutputStream)
+		assertTrue("Used in all tests", true);
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#flush()
+	 */
+	public void test_flush() {
+		// Test for method void java.io.DataOutputStream.flush()
+		try {
+			os.writeInt(9087589);
+			os.flush();
+			openDataInputStream();
+			int c = dis.readInt();
+			dis.close();
+			assertTrue("Failed to flush correctly", c == 9087589);
+		} catch (IOException e) {
+			fail("Exception during flush test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#size()
+	 */
+	public void test_size() {
+		// Test for method int java.io.DataOutputStream.size()
+
+		try {
+			os.write(fileString.getBytes(), 0, 150);
+			os.close();
+			openDataInputStream();
+			byte[] rbuf = new byte[150];
+			dis.read(rbuf, 0, 150);
+			dis.close();
+			assertTrue("Incorrect size returned", os.size() == 150);
+		} catch (IOException e) {
+			fail("Exception during write test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#write(byte[], int, int)
+	 */
+	public void test_write$BII() {
+		// Test for method void java.io.DataOutputStream.write(byte [], int,
+		// int)
+		try {
+			os.write(fileString.getBytes(), 0, 150);
+			os.close();
+			openDataInputStream();
+			byte[] rbuf = new byte[150];
+			dis.read(rbuf, 0, 150);
+			dis.close();
+			assertTrue("Incorrect bytes written", new String(rbuf, 0, 150)
+					.equals(fileString.substring(0, 150)));
+		} catch (IOException e) {
+			fail("Exception during write test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#write(int)
+	 */
+	public void test_writeI() {
+		// Test for method void java.io.DataOutputStream.write(int)
+		try {
+			os.write((int) 't');
+			os.close();
+			openDataInputStream();
+			int c = dis.read();
+			dis.close();
+			assertTrue("Incorrect int written", (int) 't' == c);
+		} catch (IOException e) {
+			fail("Exception during write test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeBoolean(boolean)
+	 */
+	public void test_writeBooleanZ() {
+		// Test for method void java.io.DataOutputStream.writeBoolean(boolean)
+		try {
+			os.writeBoolean(true);
+			os.close();
+			openDataInputStream();
+			boolean c = dis.readBoolean();
+			dis.close();
+			assertTrue("Incorrect boolean written", c == true);
+		} catch (IOException e) {
+			fail("Exception during writeBoolean test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeByte(int)
+	 */
+	public void test_writeByteI() {
+		// Test for method void java.io.DataOutputStream.writeByte(int)
+		try {
+			os.writeByte((byte) 127);
+			os.close();
+			openDataInputStream();
+			byte c = dis.readByte();
+			dis.close();
+			assertTrue("Incorrect byte written", c == (byte) 127);
+		} catch (IOException e) {
+			fail("Exception during writeByte test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeBytes(java.lang.String)
+	 */
+	public void test_writeBytesLjava_lang_String() {
+		// Test for method void
+		// java.io.DataOutputStream.writeBytes(java.lang.String)
+		try {
+			os.write(fileString.getBytes());
+			os.close();
+			openDataInputStream();
+			byte[] rbuf = new byte[4000];
+			dis.read(rbuf, 0, fileString.length());
+			dis.close();
+			assertTrue("Incorrect bytes written", new String(rbuf, 0,
+					fileString.length()).equals(fileString));
+		} catch (IOException e) {
+			fail("Exception during writeBytes test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeChar(int)
+	 */
+	public void test_writeCharI() {
+		// Test for method void java.io.DataOutputStream.writeChar(int)
+		try {
+			os.writeChar('T');
+			os.close();
+			openDataInputStream();
+			char c = dis.readChar();
+			dis.close();
+			assertTrue("Incorrect char written", c == 'T');
+		} catch (IOException e) {
+			fail("Exception during writeChar test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeChars(java.lang.String)
+	 */
+	public void test_writeCharsLjava_lang_String() {
+		// Test for method void
+		// java.io.DataOutputStream.writeChars(java.lang.String)
+		try {
+			os.writeChars("Test String");
+			os.close();
+			openDataInputStream();
+			char[] chars = new char[50];
+			int i, a = dis.available() / 2;
+			for (i = 0; i < a; i++)
+				chars[i] = dis.readChar();
+			assertTrue("Incorrect chars written", new String(chars, 0, i)
+					.equals("Test String"));
+		} catch (IOException e) {
+			fail("Exception during writeChars test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeDouble(double)
+	 */
+	public void test_writeDoubleD() {
+		// Test for method void java.io.DataOutputStream.writeDouble(double)
+		try {
+			os.writeDouble(908755555456.98);
+			os.close();
+			openDataInputStream();
+			double c = dis.readDouble();
+			dis.close();
+			assertTrue("Incorrect double written", c == 908755555456.98);
+		} catch (IOException e) {
+			fail("Exception during writeDouble test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeFloat(float)
+	 */
+	public void test_writeFloatF() {
+		// Test for method void java.io.DataOutputStream.writeFloat(float)
+		try {
+			os.writeFloat(9087.456f);
+			os.close();
+			openDataInputStream();
+			float c = dis.readFloat();
+			dis.close();
+			assertTrue("Incorrect float written", c == 9087.456f);
+		} catch (IOException e) {
+			fail("Exception during writeFloattest : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeInt(int)
+	 */
+	public void test_writeIntI() {
+		// Test for method void java.io.DataOutputStream.writeInt(int)
+		try {
+			os.writeInt(9087589);
+			os.close();
+			openDataInputStream();
+			int c = dis.readInt();
+			dis.close();
+			assertTrue("Incorrect int written", c == 9087589);
+		} catch (IOException e) {
+			fail("Exception during writeInt test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeLong(long)
+	 */
+	public void test_writeLongJ() {
+		// Test for method void java.io.DataOutputStream.writeLong(long)
+		try {
+			os.writeLong(908755555456L);
+			os.close();
+			openDataInputStream();
+			long c = dis.readLong();
+			dis.close();
+			assertTrue("Incorrect long written", c == 908755555456L);
+		} catch (IOException e) {
+			fail("Exception during writeLong test" + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeShort(int)
+	 */
+	public void test_writeShortI() {
+		// Test for method void java.io.DataOutputStream.writeShort(int)
+		try {
+			os.writeShort((short) 9087);
+			os.close();
+			openDataInputStream();
+			short c = dis.readShort();
+			dis.close();
+			assertTrue("Incorrect short written", c == 9087);
+		} catch (IOException e) {
+			fail("Exception during writeShort test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.DataOutputStream#writeUTF(java.lang.String)
+	 */
+	public void test_writeUTFLjava_lang_String() {
+		// Test for method void
+		// java.io.DataOutputStream.writeUTF(java.lang.String)
+		try {
+			os.writeUTF(unihw);
+			os.close();
+			openDataInputStream();
+			assertTrue("Failed to write string in UTF format",
+					dis.available() == unihw.length() + 2);
+			assertTrue("Incorrect string returned", dis.readUTF().equals(unihw));
+		} catch (Exception e) {
+			fail("Exception during writeUTF" + e.getMessage());
+		}
+	}
+
+	private void openDataInputStream() throws IOException {
+		dis = new DataInputStream(new ByteArrayInputStream(bos.toByteArray()));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		bos = new ByteArrayOutputStream();
+		os = new DataOutputStream(bos);
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		try {
+			if (os != null)
+				os.close();
+			if (dis != null)
+				dis.close();
+		} catch (IOException e) {
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/EOFExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/EOFExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/EOFExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/EOFExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,69 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.EOFException;
+
+public class EOFExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.EOFException#EOFException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.EOFException()
+		try {
+			new DataInputStream(new ByteArrayInputStream(new byte[1]))
+					.readShort();
+		} catch (EOFException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during EOFException test" + e.toString());
+		}
+		fail("Failed to generate exception");
+	}
+
+	/**
+	 * @tests java.io.EOFException#EOFException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.EOFException(java.lang.String)
+		try {
+			new DataInputStream(new ByteArrayInputStream(new byte[1]))
+					.readShort();
+		} catch (EOFException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during EOFException test" + e.toString());
+		}
+		fail("Failed to generate exception");
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileDescriptorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileDescriptorTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileDescriptorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileDescriptorTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,121 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.io;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+public class FileDescriptorTest extends junit.framework.TestCase {
+
+	private static String platformId = "JDK"
+			+ System.getProperty("java.vm.version").replace('.', '-');
+
+	FileOutputStream fos;
+
+	BufferedOutputStream os;
+
+	FileInputStream fis;
+
+	File f;
+
+	/**
+	 * @tests java.io.FileDescriptor#FileDescriptor()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.FileDescriptor()
+		FileDescriptor fd = new FileDescriptor();
+		assertTrue("Failed to create FileDescriptor",
+				fd instanceof FileDescriptor);
+	}
+
+	/**
+	 * @tests java.io.FileDescriptor#sync()
+	 */
+	public void test_sync() {
+		// Test for method void java.io.FileDescriptor.sync()
+
+		try {
+			f = new File(System.getProperty("user.dir"), "fd" + platformId
+					+ ".tst");
+			f.delete();
+			fos = new FileOutputStream(f.getPath());
+			fos.write("Test String".getBytes());
+			fis = new FileInputStream(f.getPath());
+			FileDescriptor fd = fos.getFD();
+			fd.sync();
+			assertTrue("Bytes were not written after sync",
+					fis.available() == "Test String".length());
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.FileDescriptor#valid()
+	 */
+	public void test_valid() {
+		// Test for method boolean java.io.FileDescriptor.valid()
+		try {
+			f = new File(System.getProperty("user.dir"), "fd.tst");
+			f.delete();
+			os = new BufferedOutputStream(fos = new FileOutputStream(f
+					.getPath()), 4096);
+			FileDescriptor fd = fos.getFD();
+			assertTrue("Valid fd returned false", fd.valid());
+			os.close();
+			assertTrue("Invalid fd returned true", !fd.valid());
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		try {
+			os.close();
+		} catch (Exception e) {
+		}
+		try {
+			fis.close();
+		} catch (Exception e) {
+		}
+		try {
+			fos.close();
+		} catch (Exception e) {
+		}
+		try {
+			f.delete();
+		} catch (Exception e) {
+		}
+	}
+
+	protected void doneSuite() {
+	}
+}