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 2008/01/17 15:49:14 UTC

svn commit: r612833 [1/4] - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/

Author: tellison
Date: Thu Jan 17 06:47:37 2008
New Revision: 612833

URL: http://svn.apache.org/viewvc?rev=612833&view=rev
Log:
Another round of LUNI test tidy-ups, including formatting, tidy-up imports, and letting JUnit handle the exceptions.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileDescriptorTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileNotFoundExceptionTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileReaderTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileWriterTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterInputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilterOutputStreamTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileDescriptorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileDescriptorTest.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/FileDescriptorTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileDescriptorTest.java Thu Jan 17 06:47:37 2008
@@ -22,36 +22,35 @@
 import java.io.FileDescriptor;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.RandomAccessFile;
 
 public class FileDescriptorTest extends junit.framework.TestCase {
 
-	private static String platformId = "JDK"
-			+ System.getProperty("java.vm.version").replace('.', '-');
+    private static String platformId = "JDK"
+            + System.getProperty("java.vm.version").replace('.', '-');
 
-	FileOutputStream fos;
+    FileOutputStream fos;
 
-	BufferedOutputStream os;
+    BufferedOutputStream os;
 
-	FileInputStream fis;
+    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() throws Exception {
-		// Test for method void java.io.FileDescriptor.sync()
+    File f;
+
+    /**
+     * @tests java.io.FileDescriptor#FileDescriptor()
+     */
+    public void test_Constructor() {
+        FileDescriptor fd = new FileDescriptor();
+        assertTrue("Failed to create FileDescriptor",
+                fd instanceof FileDescriptor);
+    }
+
+    /**
+     * @tests java.io.FileDescriptor#sync()
+     */
+    public void test_sync() throws IOException {
         f = new File(System.getProperty("user.dir"), "fd" + platformId + ".tst");
         f.delete();
         fos = new FileOutputStream(f.getPath());
@@ -62,64 +61,53 @@
         int length = "Test String".length();
         assertEquals("Bytes were not written after sync", length, fis
                 .available());
-        
+
         // Regression test for Harmony-1494
         fd = fis.getFD();
         fd.sync();
         assertEquals("Bytes were not written after sync", length, fis
                 .available());
-        
+
         RandomAccessFile raf = new RandomAccessFile(f, "r");
-        fd = raf.getFD(); 
+        fd = raf.getFD();
         fd.sync();
         raf.close();
-	}
-
-	/**
-	 * @tests java.io.FileDescriptor#valid()
-	 */
-	public void test_valid() throws Exception {
-		// Test for method boolean java.io.FileDescriptor.valid()
-                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());
-	}
-
-	/**
-	 * 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() {
-	}
+    /**
+     * @tests java.io.FileDescriptor#valid()
+     */
+    public void test_valid() throws IOException {
+        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());
+    }
+
+    /**
+     * 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) {
+        }
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.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/FileInputStreamTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java Thu Jan 17 06:47:37 2008
@@ -1,427 +1,406 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You 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 org.apache.harmony.luni.tests.java.io;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.security.Permission;
-
-import tests.support.Support_PlatformFile;
-
-public class FileInputStreamTest extends junit.framework.TestCase {
-
-	public 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_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_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.FileInputStream#FileInputStream(java.io.File)
-	 */
-	public void test_ConstructorLjava_io_File() throws Exception {
-		// Test for method java.io.FileInputStream(java.io.File)
-                java.io.File f = new java.io.File(fileName);
-                is = new java.io.FileInputStream(f);
-                is.close();
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#FileInputStream(java.io.FileDescriptor)
-	 */
-	public void test_ConstructorLjava_io_FileDescriptor() throws Exception {
-		// Test for method java.io.FileInputStream(java.io.FileDescriptor)
-                FileOutputStream fos = new FileOutputStream(fileName);
-                FileInputStream fis = new FileInputStream(fos.getFD());
-                fos.close();
-                fis.close();
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#FileInputStream(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() throws Exception {
-		// Test for method java.io.FileInputStream(java.lang.String)
-                is = new java.io.FileInputStream(fileName);
-                is.close();
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#available()
-	 */
-	public void test_available() throws Exception {
-		// Test for method int java.io.FileInputStream.available()
-		try {
-			is = new java.io.FileInputStream(fileName);
-			assertTrue("Returned incorrect number of available bytes", is
-					.available() == fileString.length());
-		} finally {
-			try {
-				is.close();
-			} catch (java.io.IOException e) {
-			}
-		}
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#close()
-	 */
-	public void test_close() {
-		// Test for method void java.io.FileInputStream.close()
-
-		try {
-			is = new java.io.FileInputStream(fileName);
-			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.FileInputStream#getFD()
-	 */
-	public void test_getFD() {
-		// Test for method java.io.FileDescriptor
-		// java.io.FileInputStream.getFD()
-		try {
-
-			FileInputStream fis = new FileInputStream(fileName);
-			assertTrue("Returned invalid fd", fis.getFD().valid());
-			fis.close();
-			assertTrue("Returned invalid fd", !fis.getFD().valid());
-		} catch (FileNotFoundException e) {
-			fail("Could not find : " + fileName);
-		}
-
-		catch (IOException e) {
-			fail("Exception during test : " + e.getMessage());
-		}
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#read()
-	 */
-	public void test_read() throws Exception {
-		// Test for method int java.io.FileInputStream.read()
-            is = new java.io.FileInputStream(fileName);
-            int c = is.read();
-            is.close();
-            assertTrue("read returned incorrect char", c == fileString
-                            .charAt(0));
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#read(byte[])
-	 */
-	public void test_read$B() throws Exception {
-		// Test for method int java.io.FileInputStream.read(byte [])
-		byte[] buf1 = new byte[100];
-                is = new java.io.FileInputStream(fileName);
-                is.skip(3000);
-                is.read(buf1);
-                is.close();
-                assertTrue("Failed to read correct data", new String(buf1, 0,
-                                buf1.length).equals(fileString.substring(3000, 3100)));
-	}
-
-	/**
-	 * @tests java.io.FileInputStream#read(byte[], int, int)
-	 */
-	public void test_read$BII() throws IOException {
-        byte[] buf1 = new byte[100];
-        is = new FileInputStream(fileName);
-        is.skip(3000);
-        is.read(buf1, 0, buf1.length);
-        is.close();
-        assertTrue("Failed to read correct data", new String(buf1, 0,
-                buf1.length).equals(fileString.substring(3000, 3100)));
-        // Regression test for HARMONY-285
-        File file = new File("FileInputStream.tmp");
-        file.createNewFile();
-        file.deleteOnExit();
-        FileInputStream in = new FileInputStream(file);
-        try {
-            in.read(null, 0, 0);
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // Expected
-        }
-    }
-    
-    /**
-     * @tests java.io.FileInputStream#read(byte[], int, int)
-     */
-    public void test_read_$BII_IOException() throws IOException {
-        byte[] buf = new byte[1000];
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, -1, 0);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, 0, -1);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, -1, -1);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, 0, 1001);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, 1001, 0);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, 500, 501);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-        
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.close();
-            is.read(buf, 0, 100);
-            fail("should throw IOException");
-        } catch (IOException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-        
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.close();
-            is.read(buf, 0, 0);
-        } finally {
-            is.close();
-        }
-    }
-
-    /**
-     * @tests java.io.FileInputStream#read(byte[], int, int)
-     */
-    public void test_read_$BII_NullPointerException() throws IOException {
-        byte[] buf = null;
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.read(buf, -1, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-    }
-
-    /**
-     * @tests java.io.FileInputStream#read(byte[], int, int)
-     */
-    public void test_read_$BII_IndexOutOfBoundsException() throws IOException {
-        byte[] buf = new byte[1000];
-        try {
-            is = new java.io.FileInputStream(fileName);
-            is.close();
-            is.read(buf, -1, -1);
-            fail("should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        } finally {
-            is.close();
-        }
-    }
-
-	/**
-	 * @tests java.io.FileInputStream#skip(long)
-	 */
-	public void test_skipJ() throws Exception {
-		// Test for method long java.io.FileInputStream.skip(long)
-		byte[] buf1 = new byte[10];
-                is = new java.io.FileInputStream(fileName);
-                is.skip(1000);
-                is.read(buf1, 0, buf1.length);
-                is.close();
-                assertTrue("Failed to skip to correct position", new String(buf1,
-                                0, buf1.length).equals(fileString.substring(1000, 1010)));
-	}
-
-    /**
-     * @tests java.io.FileInputStream#read(byte[], int, int))
-     */
-    public void test_regressionNNN() throws IOException {
-        // Regression for HARMONY-434
-        FileInputStream fis = new java.io.FileInputStream(fileName);
-
-        try {
-            fis.read(new byte[1], -1, 1);
-            fail("IndexOutOfBoundsException must be thrown if off <0");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fis.read(new byte[1], 0, -1);
-            fail("IndexOutOfBoundsException must be thrown if len <0");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fis.read(new byte[1], 0, 5);
-            fail("IndexOutOfBoundsException must be thrown if off+len > b.length");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fis.read(new byte[10], Integer.MAX_VALUE, 5);
-            fail("IndexOutOfBoundsException expected");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fis.read(new byte[10], 5, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException expected");
-        } catch (IndexOutOfBoundsException e) {}
-        fis.close();
-    }
-    
-    /**
-     * @tests java.io.FileInputStream#FileInputStream(String)
-     */
-    public void test_Constructor_LString_WithSecurityManager() throws IOException {
-        SecurityManager old = System.getSecurityManager();
-        try {
-            MockSecurityManager msm = new MockSecurityManager();
-            System.setSecurityManager(msm);
-            new FileInputStream((String)null);
-            fail("should throw SecurityException");
-        } catch (SecurityException e) {
-            //expected
-        } finally {
-            System.setSecurityManager(old);
-        }
-    }
-    
-    /**
-     * @tests java.io.FileInputStream#skip(long)
-     */
-    public void test_skipNegativeArgumentJ() throws IOException{
-        
-        FileInputStream fis = new java.io.FileInputStream(fileName);
-
-        try {
-            fis.skip(-5);
-            fail("IOException must be thrown if number of bytes to skip <0");
-        } catch (IOException e) {
-            // Expected IOException
-        }
-        
-        fis.close();
-    } 
-    
-    /**
-     * Sets up the fixture, for example, open a network connection. This method
-     * is called before a test is executed.
-     */
-	protected void setUp() {
-		try {
-			fileName = System.getProperty("user.dir");
-			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();
-		} 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() {
-		new File(fileName).delete();
-
-	}
-}
-
-class MockSecurityManager extends SecurityManager {  
-    public void checkPermission(Permission permission) {
-        if (permission instanceof FilePermission) {
-           if (permission.getActions().indexOf("read") == 0)
-               throw new SecurityException();
-        }
-    }
-    
-    public void checkRead(String file) {
-       if( null == file) {
-            file = "";
-        }
-       checkPermission(new FilePermission(file,"read"));
-    }  
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.luni.tests.java.io;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.security.Permission;
+
+import tests.support.Support_PlatformFile;
+
+public class FileInputStreamTest extends junit.framework.TestCase {
+
+    public 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_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_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.FileInputStream#FileInputStream(java.io.File)
+     */
+    public void test_ConstructorLjava_io_File() throws IOException {
+        java.io.File f = new File(fileName);
+        is = new FileInputStream(f);
+        is.close();
+    }
+
+    /**
+     * @tests java.io.FileInputStream#FileInputStream(java.io.FileDescriptor)
+     */
+    public void test_ConstructorLjava_io_FileDescriptor() throws IOException {
+        FileOutputStream fos = new FileOutputStream(fileName);
+        FileInputStream fis = new FileInputStream(fos.getFD());
+        fos.close();
+        fis.close();
+    }
+
+    /**
+     * @tests java.io.FileInputStream#FileInputStream(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() throws IOException {
+        is = new FileInputStream(fileName);
+        is.close();
+    }
+
+    /**
+     * @tests java.io.FileInputStream#available()
+     */
+    public void test_available() throws IOException {
+        try {
+            is = new FileInputStream(fileName);
+            assertTrue("Returned incorrect number of available bytes", is
+                    .available() == fileString.length());
+        } finally {
+            try {
+                is.close();
+            } catch (IOException e) {
+            }
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#close()
+     */
+    public void test_close() throws IOException {
+        is = new FileInputStream(fileName);
+        is.close();
+
+        try {
+            is.read();
+            fail("Able to read from closed stream");
+        } catch (IOException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#getFD()
+     */
+    public void test_getFD() throws IOException {
+        FileInputStream fis = new FileInputStream(fileName);
+        assertTrue("Returned invalid fd", fis.getFD().valid());
+        fis.close();
+        assertTrue("Returned invalid fd", !fis.getFD().valid());
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read()
+     */
+    public void test_read() throws IOException {
+        is = new FileInputStream(fileName);
+        int c = is.read();
+        is.close();
+        assertTrue("read returned incorrect char", c == fileString.charAt(0));
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[])
+     */
+    public void test_read$B() throws IOException {
+        byte[] buf1 = new byte[100];
+        is = new FileInputStream(fileName);
+        is.skip(3000);
+        is.read(buf1);
+        is.close();
+        assertTrue("Failed to read correct data", new String(buf1, 0,
+                buf1.length).equals(fileString.substring(3000, 3100)));
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int)
+     */
+    public void test_read$BII() throws IOException {
+        byte[] buf1 = new byte[100];
+        is = new FileInputStream(fileName);
+        is.skip(3000);
+        is.read(buf1, 0, buf1.length);
+        is.close();
+        assertTrue("Failed to read correct data", new String(buf1, 0,
+                buf1.length).equals(fileString.substring(3000, 3100)));
+
+        // Regression test for HARMONY-285
+        File file = new File("FileInputStream.tmp");
+        file.createNewFile();
+        file.deleteOnExit();
+        FileInputStream in = new FileInputStream(file);
+        try {
+            in.read(null, 0, 0);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        } finally {
+            in.close();
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int)
+     */
+    public void test_read_$BII_IOException() throws IOException {
+        byte[] buf = new byte[1000];
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, -1, 0);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, 0, -1);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, -1, -1);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, 0, 1001);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, 1001, 0);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, 500, 501);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.close();
+            is.read(buf, 0, 100);
+            fail("should throw IOException");
+        } catch (IOException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+
+        try {
+            is = new FileInputStream(fileName);
+            is.close();
+            is.read(buf, 0, 0);
+        } finally {
+            is.close();
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int)
+     */
+    public void test_read_$BII_NullPointerException() throws IOException {
+        byte[] buf = null;
+        try {
+            is = new FileInputStream(fileName);
+            is.read(buf, -1, 0);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int)
+     */
+    public void test_read_$BII_IndexOutOfBoundsException() throws IOException {
+        byte[] buf = new byte[1000];
+        try {
+            is = new FileInputStream(fileName);
+            is.close();
+            is.read(buf, -1, -1);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        } finally {
+            is.close();
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#skip(long)
+     */
+    public void test_skipJ() throws IOException {
+        byte[] buf1 = new byte[10];
+        is = new FileInputStream(fileName);
+        is.skip(1000);
+        is.read(buf1, 0, buf1.length);
+        is.close();
+        assertTrue("Failed to skip to correct position", new String(buf1, 0,
+                buf1.length).equals(fileString.substring(1000, 1010)));
+    }
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int))
+     */
+    public void test_regressionNNN() throws IOException {
+        // Regression for HARMONY-434
+        FileInputStream fis = new FileInputStream(fileName);
+
+        try {
+            fis.read(new byte[1], -1, 1);
+            fail("IndexOutOfBoundsException must be thrown if off <0");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+
+        try {
+            fis.read(new byte[1], 0, -1);
+            fail("IndexOutOfBoundsException must be thrown if len <0");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+
+        try {
+            fis.read(new byte[1], 0, 5);
+            fail("IndexOutOfBoundsException must be thrown if off+len > b.length");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+
+        try {
+            fis.read(new byte[10], Integer.MAX_VALUE, 5);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+
+        try {
+            fis.read(new byte[10], 5, Integer.MAX_VALUE);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+        fis.close();
+    }
+
+    /**
+     * @tests java.io.FileInputStream#FileInputStream(String)
+     */
+    public void test_Constructor_LString_WithSecurityManager()
+            throws IOException {
+        SecurityManager old = System.getSecurityManager();
+        try {
+            MockSecurityManager msm = new MockSecurityManager();
+            System.setSecurityManager(msm);
+            new FileInputStream((String) null);
+            fail("should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        } finally {
+            System.setSecurityManager(old);
+        }
+    }
+
+    /**
+     * @tests java.io.FileInputStream#skip(long)
+     */
+    public void test_skipNegativeArgumentJ() throws IOException {
+        FileInputStream fis = new FileInputStream(fileName);
+        try {
+            fis.skip(-5);
+            fail("IOException must be thrown if number of bytes to skip <0");
+        } catch (IOException e) {
+            // Expected IOException
+        } finally {
+            fis.close();
+        }
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection. This method
+     * is called before a test is executed.
+     */
+    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();
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    protected void tearDown() {
+        new File(fileName).delete();
+    }
+}
+
+class MockSecurityManager extends SecurityManager {
+    public void checkPermission(Permission permission) {
+        if (permission instanceof FilePermission) {
+            if (permission.getActions().indexOf("read") == 0)
+                throw new SecurityException();
+        }
+    }
+
+    public void checkRead(String file) {
+        if (null == file) {
+            file = "";
+        }
+        checkPermission(new FilePermission(file, "read"));
+    }
+}

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileNotFoundExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileNotFoundExceptionTest.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/FileNotFoundExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileNotFoundExceptionTest.java Thu Jan 17 06:47:37 2008
@@ -29,26 +29,12 @@
         assertNull(e.getMessage());
     }
 
-	/**
-	 * @tests java.io.FileNotFoundException#FileNotFoundException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		String message = "Cannot found file: 9://0//l";
+    /**
+     * @tests java.io.FileNotFoundException#FileNotFoundException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        String message = "Cannot found file: 9://0//l";
         FileNotFoundException e = new FileNotFoundException(message);
         assertSame(message, 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() {
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.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/FileOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java Thu Jan 17 06:47:37 2008
@@ -1,267 +1,263 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.luni.tests.java.io;
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-public class FileOutputStreamTest extends junit.framework.TestCase {
-
-    public String fileName;
-
-    java.io.FileOutputStream fos;
-
-    java.io.FileInputStream fis;
-
-    java.io.File f;
-
-    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_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_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.FileOutputStream#FileOutputStream(java.io.File)
-     */
-    public void test_ConstructorLjava_io_File() throws Exception {
-        // Test for method java.io.FileOutputStream(java.io.File)
-        f = new File(fileName = System.getProperty("user.home"), "fos.tst");
-        fos = new java.io.FileOutputStream(f);
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#FileOutputStream(java.io.FileDescriptor)
-     */
-    public void test_ConstructorLjava_io_FileDescriptor() throws Exception {
-        // Test for method java.io.FileOutputStream(java.io.FileDescriptor)
-        f = new File(fileName = System.getProperty("user.home"), "fos.tst");
-        fileName = f.getAbsolutePath();
-        fos = new FileOutputStream(fileName);
-        fos.write('l');
-        fos.close();
-        fis = new FileInputStream(fileName);
-        fos = new FileOutputStream(fis.getFD());
-        fos.close();
-        fis.close();
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#FileOutputStream(java.lang.String)
-     */
-    public void test_ConstructorLjava_lang_String() throws Exception {
-        // Test for method java.io.FileOutputStream(java.lang.String)
-        f = new File(fileName = System.getProperty("user.home"), "fos.tst");
-        fileName = f.getAbsolutePath();
-        fos = new FileOutputStream(fileName);
-
-        // Regression test for HARMONY-4012
-        new FileOutputStream("nul");
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#FileOutputStream(java.lang.String,
-     *        boolean)
-     */
-    public void test_ConstructorLjava_lang_StringZ() throws Exception {
-        // Test for method java.io.FileOutputStream(java.lang.String, boolean)
-        f = new java.io.File(System.getProperty("user.home"), "fos.tst");
-        fos = new java.io.FileOutputStream(f.getPath(), false);
-        fos.write("HI".getBytes(), 0, 2);
-        fos.close();
-        fos = new java.io.FileOutputStream(f.getPath(), true);
-        fos.write(fileString.getBytes());
-        fos.close();
-        byte[] buf = new byte[fileString.length() + 2];
-        fis = new FileInputStream(f.getPath());
-        fis.read(buf, 0, buf.length);
-        assertTrue("Failed to create appending stream", new String(buf, 0,
-                buf.length).equals("HI" + fileString));
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#close()
-     */
-    public void test_close() throws Exception {
-        // Test for method void java.io.FileOutputStream.close()
-
-        f = new java.io.File(System.getProperty("user.home"), "output.tst");
-        fos = new java.io.FileOutputStream(f.getPath());
-        fos.close();
-
-        try {
-            fos.write(fileString.getBytes());
-            fail("Close test failed - wrote to closed stream");
-        } catch (java.io.IOException e) {
-            // correct
-        }
-
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#getFD()
-     */
-    public void test_getFD() throws Exception {
-        // Test for method java.io.FileDescriptor
-        // java.io.FileOutputStream.getFD()
-        f = new File(fileName = System.getProperty("user.home"), "testfd");
-        fileName = f.getAbsolutePath();
-        fos = new FileOutputStream(f);
-        assertTrue("Returned invalid fd", fos.getFD().valid());
-        fos.close();
-        assertTrue("Returned invalid fd", !fos.getFD().valid());
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#write(byte[])
-     */
-    public void test_write$B() throws Exception {
-        // Test for method void java.io.FileOutputStream.write(byte [])
-        f = new java.io.File(System.getProperty("user.home"), "output.tst");
-        fos = new java.io.FileOutputStream(f.getPath());
-        fos.write(fileString.getBytes());
-        fis = new java.io.FileInputStream(f.getPath());
-        byte rbytes[] = new byte[4000];
-        fis.read(rbytes, 0, fileString.length());
-        assertTrue("Incorrect string returned", new String(rbytes, 0,
-                fileString.length()).equals(fileString));
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#write(byte[], int, int)
-     */
-    public void test_write$BII() throws IOException {
-        f = new java.io.File(System.getProperty("user.home"), "output.tst");
-        fos = new java.io.FileOutputStream(f.getPath());
-        fos.write(fileString.getBytes(), 0, fileString.length());
-        fis = new java.io.FileInputStream(f.getPath());
-        byte rbytes[] = new byte[4000];
-        fis.read(rbytes, 0, fileString.length());
-        assertTrue("Incorrect bytes written", new String(rbytes, 0, fileString
-                .length()).equals(fileString));
-
-        // Regression test for HARMONY-285
-        File file = new File("FileOutputStream.tmp");
-        file.deleteOnExit();
-        FileOutputStream out = new FileOutputStream(file);
-        try {
-            out.write(null, 0, 0);
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // Expected
-        }
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#write(int)
-     */
-    public void test_writeI() throws Exception {
-        // Test for method void java.io.FileOutputStream.write(int)
-        f = new java.io.File(System.getProperty("user.home"), "output.tst");
-        fos = new java.io.FileOutputStream(f.getPath());
-        fos.write('t');
-        fis = new java.io.FileInputStream(f.getPath());
-        assertEquals("Incorrect char written", 't', fis.read());
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#write(byte[], int, int)
-     */
-    public void test_write$BII2() throws Exception {
-        // Regression for HARMONY-437
-
-        f = new java.io.File(System.getProperty("user.home"), "output.tst");
-        fos = new java.io.FileOutputStream(f.getPath());
-
-        try {
-            fos.write(null, 1, 1);
-            fail("NullPointerException must be thrown");
-        } catch (NullPointerException e) {}
-
-        try {
-            fos.write(new byte[1], -1, 1);
-            fail("IndexOutOfBoundsException must be thrown if off <0");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fos.write(new byte[1], 0, -1);
-            fail("IndexOutOfBoundsException must be thrown if len <0");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fos.write(new byte[1], 0, 5);
-            fail("IndexOutOfBoundsException must be thrown if off+len > b.length");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fos.write(new byte[10], Integer.MAX_VALUE, 5);
-            fail("IndexOutOfBoundsException expected");
-        } catch (IndexOutOfBoundsException e) {}
-
-        try {
-            fos.write(new byte[10], 5, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException expected");
-        } catch (IndexOutOfBoundsException e) {}
-        fos.close();
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#write(byte[], int, int)
-     */
-    public void test_write$BII3() throws Exception {
-        // Regression for HARMONY-834
-        //no exception expected
-        new FileOutputStream(new FileDescriptor()).write(new byte[1], 0, 0);
-    }
-
-    /**
-     * @tests java.io.FileOutputStream#getChannel()
-     */
-    public void test_getChannel() throws Exception {
-		// Regression for HARMONY-508
-		File tmpfile = File.createTempFile("FileOutputStream", "tmp");
-		tmpfile.deleteOnExit();
-		FileOutputStream fos = new FileOutputStream(tmpfile);
-		byte[] b = new byte[10];
-		for (int i = 0; i < b.length; i++) {
-			b[i] = (byte) i;
-		}
-		fos.write(b);
-		fos.flush();
-		fos.close();
-		FileOutputStream f = new FileOutputStream(tmpfile, true);
-		assertEquals(10, f.getChannel().position()); 
-    }
-
-    /**
-     * Tears down the fixture, for example, close a network connection. This
-     * method is called after a test is executed.
-     */
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        try {
-            if (f != null)
-                f.delete();
-            if (fis != null)
-                fis.close();
-            if (fos != null)
-                fos.close();
-        } catch (Exception e) {}
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.harmony.luni.tests.java.io;
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class FileOutputStreamTest extends junit.framework.TestCase {
+
+    public String fileName;
+
+    FileOutputStream fos;
+
+    FileInputStream fis;
+
+    File f;
+
+    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_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_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.FileOutputStream#FileOutputStream(java.io.File)
+     */
+    public void test_ConstructorLjava_io_File() throws IOException {
+        f = new File(fileName = System.getProperty("user.home"), "fos.tst");
+        fos = new FileOutputStream(f);
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#FileOutputStream(java.io.FileDescriptor)
+     */
+    public void test_ConstructorLjava_io_FileDescriptor() throws IOException {
+        f = new File(fileName = System.getProperty("user.home"), "fos.tst");
+        fileName = f.getAbsolutePath();
+        fos = new FileOutputStream(fileName);
+        fos.write('l');
+        fos.close();
+        fis = new FileInputStream(fileName);
+        fos = new FileOutputStream(fis.getFD());
+        fos.close();
+        fis.close();
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#FileOutputStream(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() throws IOException {
+        f = new File(fileName = System.getProperty("user.home"), "fos.tst");
+        fileName = f.getAbsolutePath();
+        fos = new FileOutputStream(fileName);
+
+        // Regression test for HARMONY-4012
+        new FileOutputStream("nul");
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#FileOutputStream(java.lang.String,
+     *        boolean)
+     */
+    public void test_ConstructorLjava_lang_StringZ() throws IOException {
+        f = new File(System.getProperty("user.home"), "fos.tst");
+        fos = new FileOutputStream(f.getPath(), false);
+        fos.write("HI".getBytes(), 0, 2);
+        fos.close();
+        fos = new FileOutputStream(f.getPath(), true);
+        fos.write(fileString.getBytes());
+        fos.close();
+        byte[] buf = new byte[fileString.length() + 2];
+        fis = new FileInputStream(f.getPath());
+        fis.read(buf, 0, buf.length);
+        assertTrue("Failed to create appending stream", new String(buf, 0,
+                buf.length).equals("HI" + fileString));
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#close()
+     */
+    public void test_close() throws IOException {
+        f = new File(System.getProperty("user.home"), "output.tst");
+        fos = new FileOutputStream(f.getPath());
+        fos.close();
+
+        try {
+            fos.write(fileString.getBytes());
+            fail("Close test failed - wrote to closed stream");
+        } catch (IOException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#getFD()
+     */
+    public void test_getFD() throws IOException {
+        f = new File(fileName = System.getProperty("user.home"), "testfd");
+        fileName = f.getAbsolutePath();
+        fos = new FileOutputStream(f);
+        assertTrue("Returned invalid fd", fos.getFD().valid());
+        fos.close();
+        assertTrue("Returned invalid fd", !fos.getFD().valid());
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#write(byte[])
+     */
+    public void test_write$B() throws IOException {
+        f = new File(System.getProperty("user.home"), "output.tst");
+        fos = new FileOutputStream(f.getPath());
+        fos.write(fileString.getBytes());
+        fis = new FileInputStream(f.getPath());
+        byte rbytes[] = new byte[4000];
+        fis.read(rbytes, 0, fileString.length());
+        assertTrue("Incorrect string returned", new String(rbytes, 0,
+                fileString.length()).equals(fileString));
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#write(byte[], int, int)
+     */
+    public void test_write$BII() throws IOException {
+        f = new File(System.getProperty("user.home"), "output.tst");
+        fos = new FileOutputStream(f.getPath());
+        fos.write(fileString.getBytes(), 0, fileString.length());
+        fis = new FileInputStream(f.getPath());
+        byte rbytes[] = new byte[4000];
+        fis.read(rbytes, 0, fileString.length());
+        assertTrue("Incorrect bytes written", new String(rbytes, 0, fileString
+                .length()).equals(fileString));
+
+        // Regression test for HARMONY-285
+        File file = new File("FileOutputStream.tmp");
+        file.deleteOnExit();
+        FileOutputStream out = new FileOutputStream(file);
+        try {
+            out.write(null, 0, 0);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#write(int)
+     */
+    public void test_writeI() throws IOException {
+        f = new File(System.getProperty("user.home"), "output.tst");
+        fos = new FileOutputStream(f.getPath());
+        fos.write('t');
+        fis = new FileInputStream(f.getPath());
+        assertEquals("Incorrect char written", 't', fis.read());
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#write(byte[], int, int)
+     */
+    public void test_write$BII2() throws IOException {
+        // Regression for HARMONY-437
+        f = new File(System.getProperty("user.home"), "output.tst");
+        fos = new FileOutputStream(f.getPath());
+
+        try {
+            fos.write(null, 1, 1);
+            fail("NullPointerException must be thrown");
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            fos.write(new byte[1], -1, 1);
+            fail("IndexOutOfBoundsException must be thrown if off <0");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            fos.write(new byte[1], 0, -1);
+            fail("IndexOutOfBoundsException must be thrown if len <0");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            fos.write(new byte[1], 0, 5);
+            fail("IndexOutOfBoundsException must be thrown if off+len > b.length");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            fos.write(new byte[10], Integer.MAX_VALUE, 5);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            fos.write(new byte[10], 5, Integer.MAX_VALUE);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        fos.close();
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#write(byte[], int, int)
+     */
+    public void test_write$BII3() throws IOException {
+        // Regression for HARMONY-834
+        // no exception expected
+        new FileOutputStream(new FileDescriptor()).write(new byte[1], 0, 0);
+    }
+
+    /**
+     * @tests java.io.FileOutputStream#getChannel()
+     */
+    public void test_getChannel() throws IOException {
+        // Regression for HARMONY-508
+        File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+        tmpfile.deleteOnExit();
+        FileOutputStream fos = new FileOutputStream(tmpfile);
+        byte[] b = new byte[10];
+        for (int i = 0; i < b.length; i++) {
+            b[i] = (byte) i;
+        }
+        fos.write(b);
+        fos.flush();
+        fos.close();
+        FileOutputStream f = new FileOutputStream(tmpfile, true);
+        assertEquals(10, f.getChannel().position());
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (f != null) {
+            f.delete();
+        }
+        if (fis != null) {
+            fis.close();
+        }
+        if (fos != null) {
+            fos.close();
+        }
+    }
+}

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.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/FilePermissionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java Thu Jan 17 06:47:37 2008
@@ -1,230 +1,209 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You 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 org.apache.harmony.luni.tests.java.io;
-
-import java.io.File;
-import java.io.FilePermission;
-import java.security.PermissionCollection;
-
-public class FilePermissionTest extends junit.framework.TestCase {
-
-	FilePermission readAllFiles = new FilePermission("<<ALL FILES>>", "read");
-
-	FilePermission alsoReadAllFiles = new FilePermission("<<ALL FILES>>",
-			"read");
-
-	FilePermission allInCurrent = new FilePermission("*",
-			"read, write, execute,delete");
-
-	FilePermission readInCurrent = new FilePermission("*", "read");
-
-	FilePermission readInFile = new FilePermission("aFile.file", "read");
-
-	/**
-	 * @tests java.io.FilePermission#FilePermission(java.lang.String,
-	 *        java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_StringLjava_lang_String() {
-		// Test for method java.io.FilePermission(java.lang.String,
-		// java.lang.String)
-		assertTrue("Used to test", true);
-		FilePermission constructFile = new FilePermission("test constructor",
-				"write");
-		assertEquals("action given to the constructor did not correspond - constructor failed",
-				"write", constructFile.getActions());
-		assertTrue(
-				"name given to the constructor did not correspond - constructor failed",
-				constructFile.getName() == "test constructor");
-
-        // Regression test for HARMONY-1050
-        try {
-            new FilePermission(null, "drink");
-            fail("Expected IAE");
-        } catch (IllegalArgumentException e) {
-            // Expected
-        }
-        
-        try {
-            new FilePermission(null, "read");
-            fail("Expected NPE");
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        
-        try {
-            new FilePermission(null, null);
-            fail("Expected IAE");
-        } catch (IllegalArgumentException e) {
-            // Expected
-        }
-	}
-
-	/**
-	 * @tests java.io.FilePermission#getActions()
-	 */
-	public void test_getActions() {
-		// Test for method java.lang.String java.io.FilePermission.getActions()
-		assertEquals("getActions should have returned only read", "read", readAllFiles
-				.getActions());
-		assertEquals("getActions should have returned all actions", "read,write,execute,delete", allInCurrent
-				.getActions());
-	}
-
-	/**
-	 * @tests java.io.FilePermission#equals(java.lang.Object)
-	 */
-	public void test_equalsLjava_lang_Object() {
-		// test for method java.io.FilePermission.equals()
-		assertTrue(
-				"returned false when two instance of FilePermission is equal",
-				readAllFiles.equals(alsoReadAllFiles));
-		assertTrue(
-				"returned true when two instance	of FilePermission is not equal",
-				!(readInCurrent.equals(readInFile)));
-	}
-
-	/**
-	 * @tests java.io.FilePermission#implies(java.security.Permission)
-	 */
-	public void test_impliesLjava_security_Permission() {
-		// Test for method boolean
-		// java.io.FilePermission.implies(java.security.Permission)
-		assertTrue("Returned true for non-subset of actions", !readAllFiles
-				.implies(allInCurrent));
-		assertTrue("Returned true for non-subset of files", !allInCurrent
-				.implies(readAllFiles));
-		assertTrue("Returned false for subset of actions", allInCurrent
-				.implies(readInCurrent));
-		assertTrue("Returned false for subset of files", readAllFiles
-				.implies(readInCurrent));
-		assertTrue("Returned false for subset of files and actions",
-				allInCurrent.implies(readInFile));
-		assertTrue("Returned false for equal FilePermissions", readAllFiles
-				.implies(alsoReadAllFiles));
-
-		FilePermission fp3 = new FilePermission("/bob/*".replace('/',
-				File.separatorChar), "read,write");
-		FilePermission fp4 = new FilePermission("/bob/".replace('/',
-				File.separatorChar), "write");
-		assertTrue("returned true for same dir using * and not *", !fp3
-				.implies(fp4));
-		FilePermission fp5 = new FilePermission("/bob/file".replace('/',
-				File.separatorChar), "write");
-		assertTrue("returned false for same dir using * and file", fp3
-				.implies(fp5));
-
-		FilePermission fp6 = new FilePermission("/bob/".replace('/',
-				File.separatorChar), "read,write");
-		FilePermission fp7 = new FilePermission("/bob/*".replace('/',
-				File.separatorChar), "write");
-		assertTrue("returned false for same dir using not * and *", !fp6
-				.implies(fp7));
-		assertTrue("returned false for same subdir", fp6.implies(fp4));
-
-		FilePermission fp8 = new FilePermission("/".replace('/',
-				File.separatorChar), "read,write");
-		FilePermission fp9 = new FilePermission("/".replace('/',
-				File.separatorChar), "write");
-		assertTrue("returned false for same dir", fp8.implies(fp9));
-
-		FilePermission fp10 = new FilePermission("/".replace('/',
-				File.separatorChar), "read,write");
-		FilePermission fp11 = new FilePermission("/".replace('/',
-				File.separatorChar), "write");
-		assertTrue("returned false for same dir", fp10.implies(fp11));
-
-		FilePermission fp12 = new FilePermission("/*".replace('/',
-				File.separatorChar), "read,write");
-		assertTrue("returned false for same dir using * and dir", !fp12
-				.implies(fp10));
-		
-        // Regression for HARMONY-47
-        char separator = File.separatorChar;
-        char nonSeparator = (separator == '/') ? '\\' : '/';
-
-        FilePermission fp1 = new FilePermission(nonSeparator + "*", "read");
-        FilePermission fp2 = new FilePermission(separator + "a", "read");
-        assertFalse("Assert 0: non-separator worked", fp1.implies(fp2));
-        fp1 = new FilePermission(nonSeparator + "-", "read");
-        assertFalse("Assert 1: non-separator worked", fp1.implies(fp2));
-	}
-
-	/**
-	 * @tests java.io.FilePermission#newPermissionCollection()
-	 */
-	public void test_newPermissionCollection() {
-		// test for method java.io.FilePermission.newPermissionCollection
-		char s = File.separatorChar;
-		FilePermission perm[] = new FilePermission[4];
-		perm[0] = readAllFiles;
-		perm[1] = allInCurrent;
-		perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
-				"read,write");
-		perm[3] = new FilePermission(s + "tmp" + s + "test" + s
-				+ "collection.file", "read");
-
-		PermissionCollection collect = perm[0].newPermissionCollection();
-		for (int i = 0; i < perm.length; i++) {
-			collect.add(perm[i]);
-		}
-		assertTrue("returned false for subset of files", collect
-				.implies(new FilePermission("*", "write")));
-		assertTrue("returned false for subset of name and action", collect
-				.implies(new FilePermission(s + "tmp", "read")));
-		assertTrue("returned true for non subset of file and action", collect
-				.implies(readInFile));
-
-		FilePermission fp1 = new FilePermission("/tmp/-".replace('/',
-				File.separatorChar), "read");
-		PermissionCollection fpc = fp1.newPermissionCollection();
-		fpc.add(fp1);
-		fpc.add(new FilePermission("/tmp/scratch/foo/*".replace('/',
-				File.separatorChar), "write"));
-		FilePermission fp2 = new FilePermission("/tmp/scratch/foo/file"
-				.replace('/', File.separatorChar), "read,write");
-		assertTrue("collection does not collate", fpc.implies(fp2));
-	}
-
-	/**
-	 * @tests java.io.FilePermission#hashCode()
-	 */
-	public void test_hashCode() {
-		// test method java.io.FilePermission.hasCode()
-		assertTrue(
-				"two equal filePermission instances returned different hashCode",
-				readAllFiles.hashCode() == alsoReadAllFiles.hashCode());
-		assertTrue(
-				"two filePermission instances with same permission name returned same hashCode",
-				readInCurrent.hashCode() != allInCurrent.hashCode());
-
-	}
-
-	/**
-	 * 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() {
-	}
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.luni.tests.java.io;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.security.PermissionCollection;
+
+public class FilePermissionTest extends junit.framework.TestCase {
+
+    FilePermission readAllFiles = new FilePermission("<<ALL FILES>>", "read");
+
+    FilePermission alsoReadAllFiles = new FilePermission("<<ALL FILES>>",
+            "read");
+
+    FilePermission allInCurrent = new FilePermission("*",
+            "read, write, execute,delete");
+
+    FilePermission readInCurrent = new FilePermission("*", "read");
+
+    FilePermission readInFile = new FilePermission("aFile.file", "read");
+
+    /**
+     * @tests java.io.FilePermission#FilePermission(java.lang.String,
+     *        java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+        assertTrue("Used to test", true);
+        FilePermission constructFile = new FilePermission("test constructor",
+                "write");
+        assertEquals(
+                "action given to the constructor did not correspond - constructor failed",
+                "write", constructFile.getActions());
+        assertTrue(
+                "name given to the constructor did not correspond - constructor failed",
+                constructFile.getName() == "test constructor");
+
+        // Regression test for HARMONY-1050
+        try {
+            new FilePermission(null, "drink");
+            fail("Expected IAE");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+
+        try {
+            new FilePermission(null, "read");
+            fail("Expected NPE");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        try {
+            new FilePermission(null, null);
+            fail("Expected IAE");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.io.FilePermission#getActions()
+     */
+    public void test_getActions() {
+        assertEquals("getActions should have returned only read", "read",
+                readAllFiles.getActions());
+        assertEquals("getActions should have returned all actions",
+                "read,write,execute,delete", allInCurrent.getActions());
+    }
+
+    /**
+     * @tests java.io.FilePermission#equals(java.lang.Object)
+     */
+    public void test_equalsLjava_lang_Object() {
+        assertTrue(
+                "returned false when two instance of FilePermission is equal",
+                readAllFiles.equals(alsoReadAllFiles));
+        assertTrue(
+                "returned true when two instance	of FilePermission is not equal",
+                !(readInCurrent.equals(readInFile)));
+    }
+
+    /**
+     * @tests java.io.FilePermission#implies(java.security.Permission)
+     */
+    public void test_impliesLjava_security_Permission() {
+        assertTrue("Returned true for non-subset of actions", !readAllFiles
+                .implies(allInCurrent));
+        assertTrue("Returned true for non-subset of files", !allInCurrent
+                .implies(readAllFiles));
+        assertTrue("Returned false for subset of actions", allInCurrent
+                .implies(readInCurrent));
+        assertTrue("Returned false for subset of files", readAllFiles
+                .implies(readInCurrent));
+        assertTrue("Returned false for subset of files and actions",
+                allInCurrent.implies(readInFile));
+        assertTrue("Returned false for equal FilePermissions", readAllFiles
+                .implies(alsoReadAllFiles));
+
+        FilePermission fp3 = new FilePermission("/bob/*".replace('/',
+                File.separatorChar), "read,write");
+        FilePermission fp4 = new FilePermission("/bob/".replace('/',
+                File.separatorChar), "write");
+        assertTrue("returned true for same dir using * and not *", !fp3
+                .implies(fp4));
+        FilePermission fp5 = new FilePermission("/bob/file".replace('/',
+                File.separatorChar), "write");
+        assertTrue("returned false for same dir using * and file", fp3
+                .implies(fp5));
+
+        FilePermission fp6 = new FilePermission("/bob/".replace('/',
+                File.separatorChar), "read,write");
+        FilePermission fp7 = new FilePermission("/bob/*".replace('/',
+                File.separatorChar), "write");
+        assertTrue("returned false for same dir using not * and *", !fp6
+                .implies(fp7));
+        assertTrue("returned false for same subdir", fp6.implies(fp4));
+
+        FilePermission fp8 = new FilePermission("/".replace('/',
+                File.separatorChar), "read,write");
+        FilePermission fp9 = new FilePermission("/".replace('/',
+                File.separatorChar), "write");
+        assertTrue("returned false for same dir", fp8.implies(fp9));
+
+        FilePermission fp10 = new FilePermission("/".replace('/',
+                File.separatorChar), "read,write");
+        FilePermission fp11 = new FilePermission("/".replace('/',
+                File.separatorChar), "write");
+        assertTrue("returned false for same dir", fp10.implies(fp11));
+
+        FilePermission fp12 = new FilePermission("/*".replace('/',
+                File.separatorChar), "read,write");
+        assertTrue("returned false for same dir using * and dir", !fp12
+                .implies(fp10));
+
+        // Regression for HARMONY-47
+        char separator = File.separatorChar;
+        char nonSeparator = (separator == '/') ? '\\' : '/';
+
+        FilePermission fp1 = new FilePermission(nonSeparator + "*", "read");
+        FilePermission fp2 = new FilePermission(separator + "a", "read");
+        assertFalse("Assert 0: non-separator worked", fp1.implies(fp2));
+        fp1 = new FilePermission(nonSeparator + "-", "read");
+        assertFalse("Assert 1: non-separator worked", fp1.implies(fp2));
+    }
+
+    /**
+     * @tests java.io.FilePermission#newPermissionCollection()
+     */
+    public void test_newPermissionCollection() {
+        char s = File.separatorChar;
+        FilePermission perm[] = new FilePermission[4];
+        perm[0] = readAllFiles;
+        perm[1] = allInCurrent;
+        perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
+                "read,write");
+        perm[3] = new FilePermission(s + "tmp" + s + "test" + s
+                + "collection.file", "read");
+
+        PermissionCollection collect = perm[0].newPermissionCollection();
+        for (int i = 0; i < perm.length; i++) {
+            collect.add(perm[i]);
+        }
+        assertTrue("returned false for subset of files", collect
+                .implies(new FilePermission("*", "write")));
+        assertTrue("returned false for subset of name and action", collect
+                .implies(new FilePermission(s + "tmp", "read")));
+        assertTrue("returned true for non subset of file and action", collect
+                .implies(readInFile));
+
+        FilePermission fp1 = new FilePermission("/tmp/-".replace('/',
+                File.separatorChar), "read");
+        PermissionCollection fpc = fp1.newPermissionCollection();
+        fpc.add(fp1);
+        fpc.add(new FilePermission("/tmp/scratch/foo/*".replace('/',
+                File.separatorChar), "write"));
+        FilePermission fp2 = new FilePermission("/tmp/scratch/foo/file"
+                .replace('/', File.separatorChar), "read,write");
+        assertTrue("collection does not collate", fpc.implies(fp2));
+    }
+
+    /**
+     * @tests java.io.FilePermission#hashCode()
+     */
+    public void test_hashCode() {
+        assertTrue(
+                "two equal filePermission instances returned different hashCode",
+                readAllFiles.hashCode() == alsoReadAllFiles.hashCode());
+        assertTrue(
+                "two filePermission instances with same permission name returned same hashCode",
+                readInCurrent.hashCode() != allInCurrent.hashCode());
+
+    }
+}