harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r612833 [4/4] - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/
Date Thu, 17 Jan 2008 14:49:14 GMT
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileWriterTest.java?rev=612833&r1=612832&r2=612833&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileWriterTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileWriterTest.java
Thu Jan 17 06:47:37 2008
@@ -24,178 +24,172 @@
 import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.FileWriter;
+import java.io.IOException;
 
 public class FileWriterTest extends junit.framework.TestCase {
 
-	FileWriter fw;
+    FileWriter fw;
 
-	FileInputStream fis;
+    FileInputStream fis;
 
-	BufferedWriter bw;
+    BufferedWriter bw;
 
-	File f;
+    File f;
 
-	FileOutputStream fos;
-
-	BufferedReader br;
-
-	/**
-	 * @tests java.io.FileWriter#FileWriter(java.io.File)
-	 */
-	public void test_ConstructorLjava_io_File() throws Exception {
-		// Test for method java.io.FileWriter(java.io.File)
-                fos = new FileOutputStream(f.getPath());
-                fos.write("Test String".getBytes());
-                fos.close();
-                bw = new BufferedWriter(new FileWriter(f));
-                bw.write(" After test string", 0, 18);
-                bw.close();
-                br = new BufferedReader(new FileReader(f.getPath()));
-                char[] buf = new char[100];
-                int r = br.read(buf);
-                br.close();
-                assertEquals("Failed to write correct chars", " After test string", new String(buf,
0, r));
-	}
+    FileOutputStream fos;
+
+    BufferedReader br;
+
+    /**
+     * @tests java.io.FileWriter#FileWriter(java.io.File)
+     */
+    public void test_ConstructorLjava_io_File() throws IOException {
+        fos = new FileOutputStream(f.getPath());
+        fos.write("Test String".getBytes());
+        fos.close();
+        bw = new BufferedWriter(new FileWriter(f));
+        bw.write(" After test string", 0, 18);
+        bw.close();
+        br = new BufferedReader(new FileReader(f.getPath()));
+        char[] buf = new char[100];
+        int r = br.read(buf);
+        br.close();
+        assertEquals("Failed to write correct chars", " After test string",
+                new String(buf, 0, r));
+    }
 
     /**
      * @tests java.io.FileWriter#FileWriter(java.io.File, boolean)
      */
-    public void test_ConstructorLjava_io_FileZ() throws Exception {
-        // Test for method java.io.FileWriter(java.io.File)
-        //append = true
-        {
-            FileWriter fileWriter = new FileWriter(f);
-
-            String first = "The first string for testing. ";
-            fileWriter.write(first);
-            fileWriter.close();
-
-            fileWriter = new FileWriter(f, true);
-            String second = "The second String for testing.";
-            fileWriter.write(second);
-            fileWriter.close();
-
-            FileReader fileReader = new FileReader(f);
-            char[] out = new char[first.length() + second.length() + 10];
-            int length = fileReader.read(out);
-            fileReader.close();
-            assertEquals(first + second, new String(out, 0, length));
+    public void test_ConstructorLjava_io_FileZ() throws IOException {
+        FileWriter fileWriter = new FileWriter(f);
+
+        String first = "The first string for testing. ";
+        fileWriter.write(first);
+        fileWriter.close();
+
+        fileWriter = new FileWriter(f, true);
+        String second = "The second String for testing.";
+        fileWriter.write(second);
+        fileWriter.close();
+
+        FileReader fileReader = new FileReader(f);
+        char[] out = new char[first.length() + second.length() + 10];
+        int length = fileReader.read(out);
+        fileReader.close();
+        assertEquals(first + second, new String(out, 0, length));
+
+        fileWriter = new FileWriter(f);
+        first = "The first string for testing. ";
+        fileWriter.write(first);
+        fileWriter.close();
+
+        fileWriter = new FileWriter(f, false);
+        second = "The second String for testing.";
+        fileWriter.write(second);
+        fileWriter.close();
+
+        fileReader = new FileReader(f);
+        out = new char[first.length() + second.length() + 10];
+        length = fileReader.read(out);
+        fileReader.close();
+        assertEquals(second, new String(out, 0, length));
+    }
+
+    /**
+     * @tests java.io.FileWriter#FileWriter(java.io.FileDescriptor)
+     */
+    public void test_ConstructorLjava_io_FileDescriptor() throws IOException {
+        fos = new FileOutputStream(f.getPath());
+        fos.write("Test String".getBytes());
+        fos.close();
+        fis = new FileInputStream(f.getPath());
+        br = new BufferedReader(new FileReader(fis.getFD()));
+        char[] buf = new char[100];
+        int r = br.read(buf);
+        br.close();
+        fis.close();
+        assertTrue("Failed to write correct chars: " + new String(buf, 0, r),
+                new String(buf, 0, r).equals("Test String"));
+    }
+
+    /**
+     * @tests java.io.FileWriter#FileWriter(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() throws IOException {
+        fos = new FileOutputStream(f.getPath());
+        fos.write("Test String".getBytes());
+        fos.close();
+        bw = new BufferedWriter(new FileWriter(f.getPath()));
+        bw.write(" After test string", 0, 18);
+        bw.close();
+        br = new BufferedReader(new FileReader(f.getPath()));
+        char[] buf = new char[100];
+        int r = br.read(buf);
+        br.close();
+        assertEquals("Failed to write correct chars", " After test string",
+                new String(buf, 0, r));
+    }
+
+    /**
+     * @tests java.io.FileWriter#FileWriter(java.lang.String, boolean)
+     */
+    public void test_ConstructorLjava_lang_StringZ() throws IOException {
+        fos = new FileOutputStream(f.getPath());
+        fos.write("Test String".getBytes());
+        fos.close();
+        bw = new BufferedWriter(new FileWriter(f.getPath(), true));
+        bw.write(" After test string", 0, 18);
+        bw.close();
+        br = new BufferedReader(new FileReader(f.getPath()));
+        char[] buf = new char[100];
+        int r = br.read(buf);
+        br.close();
+        assertEquals("Failed to append to file",
+                "Test String After test string", new String(buf, 0, r));
+
+        fos = new FileOutputStream(f.getPath());
+        fos.write("Test String".getBytes());
+        fos.close();
+        bw = new BufferedWriter(new FileWriter(f.getPath(), false));
+        bw.write(" After test string", 0, 18);
+        bw.close();
+        br = new BufferedReader(new FileReader(f.getPath()));
+        buf = new char[100];
+        r = br.read(buf);
+        br.close();
+        assertEquals("Failed to overwrite file", " After test string",
+                new String(buf, 0, r));
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection. This method
+     * is called before a test is executed.
+     */
+    @Override
+    protected void setUp() {
+        f = new File(System.getProperty("user.home"), "writer.tst");
+        if (f.exists()) {
+            if (!f.delete()) {
+                fail("Unable to delete test file");
+            }
+        }
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    @Override
+    protected void tearDown() {
+        try {
+            bw.close();
+        } catch (Exception e) {
         }
-        //append = false
-        {
-            FileWriter fileWriter = new FileWriter(f);
-            String first = "The first string for testing. ";
-            fileWriter.write(first);
-            fileWriter.close();
-
-            fileWriter = new FileWriter(f, false);
-            String second = "The second String for testing.";
-            fileWriter.write(second);
-            fileWriter.close();
-
-            FileReader fileReader = new FileReader(f);
-            char[] out = new char[first.length() + second.length() + 10];
-            int length = fileReader.read(out);
-            fileReader.close();
-            assertEquals(second, new String(out, 0, length));
+        try {
+            fis.close();
+        } catch (Exception e) {
         }
+        f.delete();
     }
-    
-	/**
-	 * @tests java.io.FileWriter#FileWriter(java.io.FileDescriptor)
-	 */
-	public void test_ConstructorLjava_io_FileDescriptor() throws Exception {
-		// Test for method java.io.FileWriter(java.io.FileDescriptor)
-                fos = new FileOutputStream(f.getPath());
-                fos.write("Test String".getBytes());
-                fos.close();
-                fis = new FileInputStream(f.getPath());
-                br = new BufferedReader(new FileReader(fis.getFD()));
-                char[] buf = new char[100];
-                int r = br.read(buf);
-                br.close();
-                fis.close();
-                assertTrue("Failed to write correct chars: "
-                                + new String(buf, 0, r), new String(buf, 0, r)
-                                .equals("Test String"));
-	}
-
-	/**
-	 * @tests java.io.FileWriter#FileWriter(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() throws Exception {
-		// Test for method java.io.FileWriter(java.lang.String)
-                fos = new FileOutputStream(f.getPath());
-                fos.write("Test String".getBytes());
-                fos.close();
-                bw = new BufferedWriter(new FileWriter(f.getPath()));
-                bw.write(" After test string", 0, 18);
-                bw.close();
-                br = new BufferedReader(new FileReader(f.getPath()));
-                char[] buf = new char[100];
-                int r = br.read(buf);
-                br.close();
-                assertEquals("Failed to write correct chars", " After test string", new String(buf,
0, r));
-	}
-
-	/**
-	 * @tests java.io.FileWriter#FileWriter(java.lang.String, boolean)
-	 */
-	public void test_ConstructorLjava_lang_StringZ() throws Exception {
-		// Test for method java.io.FileWriter(java.lang.String, boolean)
-                fos = new FileOutputStream(f.getPath());
-                fos.write("Test String".getBytes());
-                fos.close();
-                bw = new BufferedWriter(new FileWriter(f.getPath(), true));
-                bw.write(" After test string", 0, 18);
-                bw.close();
-                br = new BufferedReader(new FileReader(f.getPath()));
-                char[] buf = new char[100];
-                int r = br.read(buf);
-                br.close();
-                assertEquals("Failed to append to file", "Test String After test string",
new String(buf, 0, r)
-                                );
-    
-                fos = new FileOutputStream(f.getPath());
-                fos.write("Test String".getBytes());
-                fos.close();
-                bw = new BufferedWriter(new FileWriter(f.getPath(), false));
-                bw.write(" After test string", 0, 18);
-                bw.close();
-                br = new BufferedReader(new FileReader(f.getPath()));
-                buf = new char[100];
-                r = br.read(buf);
-                br.close();
-                assertEquals("Failed to overwrite file", " After test string", new String(buf,
0, r));
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-
-		f = new File(System.getProperty("user.home"), "writer.tst");
-
-		if (f.exists())
-			if (!f.delete()) {
-				fail("Unable to delete test file");
-			}
-	}
-
-	/**
-	 * 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) {
-		}
-		try {
-			fis.close();
-		} catch (Exception e) {
-		}
-		f.delete();
-	}
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterInputStreamTest.java?rev=612833&r1=612832&r2=612833&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterInputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterInputStreamTest.java
Thu Jan 17 06:47:37 2008
@@ -17,164 +17,147 @@
 
 package org.apache.harmony.luni.tests.java.io;
 
+import java.io.File;
 import java.io.IOException;
 
 import tests.support.Support_PlatformFile;
 
 public class FilterInputStreamTest extends junit.framework.TestCase {
 
-	static class MyFilterInputStream extends java.io.FilterInputStream {
-		public MyFilterInputStream(java.io.InputStream is) {
-			super(is);
-		}
-	}
-
-	private String fileName;
-
-	private java.io.InputStream is;
-
-	byte[] ibuf = new byte[4096];
-
-	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\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_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_Class
 NotFoundException\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_Obj
 ect\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_SocketE
 xception\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.FilterInputStream#available()
-	 */
-	public void test_available() throws Exception {
-		// Test for method int java.io.FilterInputStream.available()
-		assertTrue("Returned incorrect number of available bytes", is
-				.available() == fileString.length());
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#close()
-	 */
-	public void test_close() {
-		// Test for method void java.io.FilterInputStream.close()
-		try {
-			is.close();
-		} catch (java.io.IOException e) {
-			fail("Exception attempting to close stream : " + e.getMessage());
-		}
-
-		try {
-			is.read();
-		} catch (java.io.IOException e) {
-			return;
-		}
-		fail("Able to read from closed stream");
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#mark(int)
-	 */
-	public void test_markI() {
-		// Test for method void java.io.FilterInputStream.mark(int)
-		assertTrue("Mark not supported by parent InputStream", true);
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#markSupported()
-	 */
-	public void test_markSupported() {
-		// Test for method boolean java.io.FilterInputStream.markSupported()
-		assertTrue("markSupported returned true", !is.markSupported());
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#read()
-	 */
-	public void test_read() throws Exception {
-		// Test for method int java.io.FilterInputStream.read()
-		int c = is.read();
-		assertTrue("read returned incorrect char", c == fileString
-				.charAt(0));
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#read(byte[])
-	 */
-	public void test_read$B() throws Exception {
-		// Test for method int java.io.FilterInputStream.read(byte [])
-		byte[] buf1 = new byte[100];
-		is.read(buf1);
-		assertTrue("Failed to read correct data", new String(buf1, 0,
-				buf1.length).equals(fileString.substring(0, 100)));
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#read(byte[], int, int)
-	 */
-	public void test_read$BII() throws Exception {
-		// Test for method int java.io.FilterInputStream.read(byte [], int, int)
-		byte[] buf1 = new byte[100];
-		is.skip(3000);
-		is.mark(1000);
-		is.read(buf1, 0, buf1.length);
-		assertTrue("Failed to read correct data", new String(buf1, 0,
-				buf1.length).equals(fileString.substring(3000, 3100)));
-	}
-
-	/**
-	 * @tests java.io.FilterInputStream#reset()
-	 */
-	public void test_reset() {
-		// Test for method void java.io.FilterInputStream.reset()
+    static class MyFilterInputStream extends java.io.FilterInputStream {
+        public MyFilterInputStream(java.io.InputStream is) {
+            super(is);
+        }
+    }
+
+    private String fileName;
+
+    private java.io.InputStream is;
+
+    byte[] ibuf = new byte[4096];
+
+    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\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_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_Cl
 assNotFoundException\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_Sock
 etException\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.FilterInputStream#available()
+     */
+    public void test_available() throws IOException {
+        assertTrue("Returned incorrect number of available bytes", is
+                .available() == fileString.length());
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#close()
+     */
+    public void test_close() throws IOException {
+        is.close();
+
+        try {
+            is.read();
+            fail("Able to read from closed stream");
+        } catch (java.io.IOException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#mark(int)
+     */
+    public void test_markI() {
+        assertTrue("Mark not supported by parent InputStream", true);
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#markSupported()
+     */
+    public void test_markSupported() {
+        assertTrue("markSupported returned true", !is.markSupported());
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#read()
+     */
+    public void test_read() throws Exception {
+        int c = is.read();
+        assertTrue("read returned incorrect char", c == fileString.charAt(0));
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#read(byte[])
+     */
+    public void test_read$B() throws Exception {
+        byte[] buf1 = new byte[100];
+        is.read(buf1);
+        assertTrue("Failed to read correct data", new String(buf1, 0,
+                buf1.length).equals(fileString.substring(0, 100)));
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#read(byte[], int, int)
+     */
+    public void test_read$BII() throws Exception {
+        byte[] buf1 = new byte[100];
+        is.skip(3000);
+        is.mark(1000);
+        is.read(buf1, 0, buf1.length);
+        assertTrue("Failed to read correct data", new String(buf1, 0,
+                buf1.length).equals(fileString.substring(3000, 3100)));
+    }
+
+    /**
+     * @tests java.io.FilterInputStream#reset()
+     */
+    public void test_reset() {
         try {
             is.reset();
             fail("should throw IOException");
         } catch (IOException e) {
             // expected
         }
-	}
+    }
 
-	/**
-	 * @tests java.io.FilterInputStream#skip(long)
-	 */
-	public void test_skipJ() throws Exception {
-		// Test for method long java.io.FilterInputStream.skip(long)
-		byte[] buf1 = new byte[10];
-
-                is.skip(1000);
-                is.read(buf1, 0, buf1.length);
-                assertTrue("Failed to skip to correct position", new String(buf1,
-                                0, buf1.length).equals(fileString.substring(1000, 1010)));
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-		try {
-			fileName = System.getProperty("user.dir");
-			String separator = System.getProperty("file.separator");
-			if (fileName.charAt(fileName.length() - 1) == separator.charAt(0))
-				fileName = Support_PlatformFile.getNewPlatformFile(fileName,
-						"input.tst");
-			else
-				fileName = Support_PlatformFile.getNewPlatformFile(fileName
-						+ separator, "input.tst");
-			java.io.OutputStream fos = new java.io.FileOutputStream(fileName);
-			fos.write(fileString.getBytes());
-			fos.close();
-			is = new MyFilterInputStream(new java.io.FileInputStream(fileName));
-		} catch (java.io.IOException e) {
-			System.out.println("Exception during setup");
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 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) {
-			System.out.println("Exception during BIS tearDown");
-		}
-		new java.io.File(fileName).delete();
-	}
+    /**
+     * @tests java.io.FilterInputStream#skip(long)
+     */
+    public void test_skipJ() throws Exception {
+        byte[] buf1 = new byte[10];
+        is.skip(1000);
+        is.read(buf1, 0, buf1.length);
+        assertTrue("Failed to skip to correct position", new String(buf1, 0,
+                buf1.length).equals(fileString.substring(1000, 1010)));
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection. This method
+     * is called before a test is executed.
+     */
+    @Override
+    protected void setUp() throws IOException {
+        fileName = System.getProperty("user.dir");
+        String separator = System.getProperty("file.separator");
+        if (fileName.charAt(fileName.length() - 1) == separator.charAt(0)) {
+            fileName = Support_PlatformFile.getNewPlatformFile(fileName,
+                    "input.tst");
+        } else {
+            fileName = Support_PlatformFile.getNewPlatformFile(fileName
+                    + separator, "input.tst");
+        }
+        java.io.OutputStream fos = new java.io.FileOutputStream(fileName);
+        fos.write(fileString.getBytes());
+        fos.close();
+        is = new MyFilterInputStream(new java.io.FileInputStream(fileName));
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    @Override
+    protected void tearDown() {
+        try {
+            is.close();
+        } catch (Exception e) {
+        }
+        new File(fileName).delete();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterOutputStreamTest.java?rev=612833&r1=612832&r2=612833&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterOutputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterOutputStreamTest.java
Thu Jan 17 06:47:37 2008
@@ -17,151 +17,116 @@
 
 package org.apache.harmony.luni.tests.java.io;
 
-public class FilterOutputStreamTest extends junit.framework.TestCase {
+import java.io.IOException;
+import junit.framework.TestCase;
 
-	private java.io.OutputStream os;
+public class FilterOutputStreamTest extends TestCase {
 
-	java.io.ByteArrayOutputStream bos;
+    private java.io.OutputStream os;
 
-	java.io.ByteArrayInputStream bis;
+    java.io.ByteArrayOutputStream bos;
 
-	byte[] ibuf = new byte[4096];
-
-	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\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_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_Class
 NotFoundException\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_Obj
 ect\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_SocketE
 xception\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.FilterOutputStream#FilterOutputStream(java.io.OutputStream)
-	 */
-	public void test_ConstructorLjava_io_OutputStream() {
-		// Test for method java.io.FilterOutputStream(java.io.OutputStream)
-		try {
-			bos = new java.io.ByteArrayOutputStream();
-			os = new java.io.FilterOutputStream(bos);
-			os.write('t');
-		} catch (java.io.IOException e) {
-			fail("Constructor test failed : " + e.getMessage());
-		}
-	}
-
-	/**
-	 * @tests java.io.FilterOutputStream#close()
-	 */
-	public void test_close() {
-		// Test for method void java.io.FilterOutputStream.close()
-		try {
-			bos = new java.io.ByteArrayOutputStream();
-			os = new java.io.FilterOutputStream(bos);
-			os.write(fileString.getBytes(), 0, 500);
-			os.flush();
-			assertEquals("Bytes not written after flush", 500, bos.size());
-			os.close();
-		} catch (java.io.IOException e) {
-			fail("Close test failed : " + e.getMessage());
-		}
-	}
-
-	/**
-	 * @tests java.io.FilterOutputStream#flush()
-	 */
-	public void test_flush() {
-		// Test for method void java.io.FilterOutputStream.flush()
-		try {
-			bos = new java.io.ByteArrayOutputStream();
-			os = new java.io.FilterOutputStream(bos);
-			os.write(fileString.getBytes(), 0, 500);
-			os.flush();
-			assertEquals("Bytes not written after flush", 500, bos.size());
-			os.close();
-		} catch (java.io.IOException e) {
-			fail("Flush test failed : " + e.getMessage());
-		}
-	}
-
-	/**
-	 * @tests java.io.FilterOutputStream#write(byte[])
-	 */
-	public void test_write$B() {
-		// Test for method void java.io.FilterOutputStream.write(byte [])
-		try {
-			bos = new java.io.ByteArrayOutputStream();
-			os = new java.io.FilterOutputStream(bos);
-			os.write(fileString.getBytes());
-			bis = new java.io.ByteArrayInputStream(bos.toByteArray());
-			os.flush();
-			assertTrue("Bytes not written after flush",
-					bis.available() == fileString.length());
-			byte[] wbytes = new byte[fileString.length()];
-			bis.read(wbytes, 0, fileString.length());
-			assertTrue("Incorrect bytes written", fileString.equals(new String(
-					wbytes, 0, wbytes.length)));
-		} catch (java.io.IOException e) {
-			fail("Write test failed : " + e.getMessage());
-		}
-	}
-
-	/**
-	 * @tests java.io.FilterOutputStream#write(byte[], int, int)
-	 */
-	public void test_write$BII() {
-		// Test for method void java.io.FilterOutputStream.write(byte [], int,
-		// int)
-		try {
-			bos = new java.io.ByteArrayOutputStream();
-			os = new java.io.FilterOutputStream(bos);
-			os.write(fileString.getBytes(), 0, fileString.length());
-			bis = new java.io.ByteArrayInputStream(bos.toByteArray());
-			os.flush();
-			assertTrue("Bytes not written after flush",
-					bis.available() == fileString.length());
-			byte[] wbytes = new byte[fileString.length()];
-			bis.read(wbytes, 0, fileString.length());
-			assertTrue("Incorrect bytes written", fileString.equals(new String(
-					wbytes, 0, wbytes.length)));
-		} catch (java.io.IOException e) {
-			fail("Write test failed : " + e.getMessage());
-		}
-	}
-
-	/**
-	 * @tests java.io.FilterOutputStream#write(int)
-	 */
-	public void test_writeI() {
-		// Test for method void java.io.FilterOutputStream.write(int)
-		try {
-			bos = new java.io.ByteArrayOutputStream();
-			os = new java.io.FilterOutputStream(bos);
-			os.write('t');
-			bis = new java.io.ByteArrayInputStream(bos.toByteArray());
-			os.flush();
-			assertEquals("Byte not written after flush", 1, bis.available());
-			byte[] wbytes = new byte[1];
-			bis.read(wbytes, 0, 1);
-			assertEquals("Incorrect byte written", 't', wbytes[0]);
-		} catch (java.io.IOException e) {
-			fail("Write test failed : " + 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 {
-			if (bos != null)
-				bos.close();
-			if (bis != null)
-				bis.close();
-			if (os != null)
-				os.close();
-		} catch (Exception e) {
-		}
-	}
+    java.io.ByteArrayInputStream bis;
+
+    byte[] ibuf = new byte[4096];
+
+    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\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_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_Cl
 assNotFoundException\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_Sock
 etException\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.FilterOutputStream#FilterOutputStream(java.io.OutputStream)
+     */
+    public void test_ConstructorLjava_io_OutputStream() throws IOException {
+        bos = new java.io.ByteArrayOutputStream();
+        os = new java.io.FilterOutputStream(bos);
+        os.write('t');
+    }
+
+    /**
+     * @tests java.io.FilterOutputStream#close()
+     */
+    public void test_close() throws IOException {
+        bos = new java.io.ByteArrayOutputStream();
+        os = new java.io.FilterOutputStream(bos);
+        os.write(fileString.getBytes(), 0, 500);
+        os.flush();
+        assertEquals("Bytes not written after flush", 500, bos.size());
+        os.close();
+    }
+
+    /**
+     * @tests java.io.FilterOutputStream#flush()
+     */
+    public void test_flush() throws IOException {
+        bos = new java.io.ByteArrayOutputStream();
+        os = new java.io.FilterOutputStream(bos);
+        os.write(fileString.getBytes(), 0, 500);
+        os.flush();
+        assertEquals("Bytes not written after flush", 500, bos.size());
+        os.close();
+    }
+
+    /**
+     * @tests java.io.FilterOutputStream#write(byte[])
+     */
+    public void test_write$B() throws IOException {
+        bos = new java.io.ByteArrayOutputStream();
+        os = new java.io.FilterOutputStream(bos);
+        os.write(fileString.getBytes());
+        bis = new java.io.ByteArrayInputStream(bos.toByteArray());
+        os.flush();
+        assertTrue("Bytes not written after flush",
+                bis.available() == fileString.length());
+        byte[] wbytes = new byte[fileString.length()];
+        bis.read(wbytes, 0, fileString.length());
+        assertTrue("Incorrect bytes written", fileString.equals(new String(
+                wbytes, 0, wbytes.length)));
+    }
+
+    /**
+     * @tests java.io.FilterOutputStream#write(byte[], int, int)
+     */
+    public void test_write$BII() throws IOException {
+        bos = new java.io.ByteArrayOutputStream();
+        os = new java.io.FilterOutputStream(bos);
+        os.write(fileString.getBytes(), 0, fileString.length());
+        bis = new java.io.ByteArrayInputStream(bos.toByteArray());
+        os.flush();
+        assertTrue("Bytes not written after flush",
+                bis.available() == fileString.length());
+        byte[] wbytes = new byte[fileString.length()];
+        bis.read(wbytes, 0, fileString.length());
+        assertTrue("Incorrect bytes written", fileString.equals(new String(
+                wbytes, 0, wbytes.length)));
+    }
+
+    /**
+     * @tests java.io.FilterOutputStream#write(int)
+     */
+    public void test_writeI() throws IOException {
+        bos = new java.io.ByteArrayOutputStream();
+        os = new java.io.FilterOutputStream(bos);
+        os.write('t');
+        bis = new java.io.ByteArrayInputStream(bos.toByteArray());
+        os.flush();
+        assertEquals("Byte not written after flush", 1, bis.available());
+        byte[] wbytes = new byte[1];
+        bis.read(wbytes, 0, 1);
+        assertEquals("Incorrect byte written", 't', wbytes[0]);
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    protected void tearDown() {
+        try {
+            if (bos != null)
+                bos.close();
+            if (bis != null)
+                bis.close();
+            if (os != null)
+                os.close();
+        } catch (Exception e) {
+        }
+    }
 }



Mime
View raw message