harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r766448 [2/4] - in /harmony/enhanced/classlib/branches/java6: ./ depends/files/ depends/jars/icu4j_3.8/ depends/jars/icu4j_4.0/ depends/manifests/icu4j_3.8/META-INF/ depends/manifests/icu4j_4.0/ depends/manifests/icu4j_4.0/META-INF/ make/ m...
Date Sun, 19 Apr 2009 11:15:34 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java Sun Apr 19 11:15:28 2009
@@ -39,41 +39,11 @@
 import tests.support.Support_PlatformFile;
 
 public class FileTest extends TestCase {
-
-    /** Location to store tests in */
-    private File tempDirectory;
-
-    /** Temp file that does exist */
-    private File tempFile;
-
-    /** File separator */
-    private String slash = File.separator;
-
-    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_File\nTest_FileDescriptor\nTest_FileInputStream\nTest_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_ClassNotFoundException\nTest_java_
 lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_Object\nTest_java_lang_OutOfMemo
 ryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_SocketException\nTest_java_net_Socke
 tImpl\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";
-
+    
     private static String platformId = "JDK"
-            + System.getProperty("java.vm.version").replace('.', '-');
-
-    {
-        // Delete all old temporary files
-        File tempDir = new File(System.getProperty("java.io.tmpdir"));
-        String[] files = tempDir.list();
-        if (files != null) {
-            for (int i = 0; i < files.length; i++) {
-                File f = new File(tempDir, files[i]);
-                if (f.isDirectory()) {
-                    if (files[i].startsWith("hyts_resources")) {
-                        deleteTempFolder(f);
-                    }
-                }
-                if (files[i].startsWith("hyts_") || files[i].startsWith("hyjar_")) {
-                    new File(tempDir, files[i]).delete();
-                }
-            }
-        }
-    }
-
-    private void deleteTempFolder(File dir) {
+        + System.getProperty("java.vm.version").replace('.', '-');
+    
+    private static void deleteTempFolder(File dir) {
         String files[] = dir.list();
         for (int i = 0; i < files.length; i++) {
             File f = new File(dir, files[i]);
@@ -85,39 +55,76 @@
         }
         dir.delete();
     }
+    
+    private static void cleanupTempFiles() {
+        // Delete all old temporary files
+        File tempDir = new File(System.getProperty("java.io.tmpdir"));
+        File[] files = tempDir.listFiles();
+        for (File file : files) {
+            if (file.getName().startsWith("harmony-test")) {
+                if (file.isDirectory()) {
+                    deleteTempFolder(file);
+                }
+                file.delete();
+            }
+        }
+    }
+    
+    private static String addTrailingSlash(String path) {
+        if (File.separatorChar == path.charAt(path.length() - 1)) {
+            return path;
+        }
+        return path + File.separator;
+    }
+    
+    /** Location to store tests in */
+    private File tempDirectory;
+
+    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_File\nTest_FileDescriptor\nTest_FileInputStream\nTest_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_ClassNotFoundException\nTest_java_
 lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_Object\nTest_java_lang_OutOfMemo
 ryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_SocketException\nTest_java_net_Socke
 tImpl\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";
+    
+    protected void setUp() throws IOException {
+        /** Setup the temporary directory */
+        tempDirectory = new File(addTrailingSlash(System.getProperty("java.io.tmpdir")) + "harmony-test-" + getClass().getSimpleName() + File.separator);
+        tempDirectory.mkdirs();
+    }
+
+    protected void tearDown() {
+        tempDirectory = null;
+        cleanupTempFiles();
+    }
 
     /**
      * @tests java.io.File#File(java.io.File, java.lang.String)
      */
-    public void test_ConstructorLjava_io_FileLjava_lang_String() {
-        String dirName = System.getProperty("user.dir");
-        File d = new File(dirName);
-        File f = new File(d, "input.tst");
-        if (!dirName.regionMatches((dirName.length() - 1), slash, 0, 1)) {
-            dirName += slash;
-        }
-        dirName += "input.tst";
-        assertEquals("Test 1: Created Incorrect File ", dirName, f.getPath());
-
-        String fileName = null;
+    public void test_ConstructorLjava_io_FileLjava_lang_String0() {
+        File f = new File(tempDirectory.getPath(), "input.tst");
+        assertEquals("Created Incorrect File ", addTrailingSlash(tempDirectory.getPath()) + "input.tst", f.getPath());
+    }
+    
+    public void test_ConstructorLjava_io_FileLjava_lang_String1() {
         try {
-            f = new File(d, fileName);
+            new File(tempDirectory, null);
             fail("NullPointerException Not Thrown.");
         } catch (NullPointerException e) {
         }
-
-        d = null;
-        f = new File(d, "input.tst");
-        assertEquals("Test 2: Created Incorrect File",
-                     dirName, f.getAbsolutePath());
-
+    }
+    
+    public void test_ConstructorLjava_io_FileLjava_lang_String2() throws IOException {
+        File f = new File((File)null, "input.tst");
+        assertEquals("Created Incorrect File", 
+                new File("input.tst").getAbsolutePath(), 
+                f.getAbsolutePath());
+    }
+    
+    public void test_ConstructorLjava_io_FileLjava_lang_String3() {
         // Regression test for HARMONY-382
-        File s = null;
-        f = new File("/abc");
-        d = new File(s, "/abc");
+        File f = new File("/abc");
+        File d = new File((File)null, "/abc");
         assertEquals("Test3: Created Incorrect File",
                      d.getAbsolutePath(), f.getAbsolutePath());
-
+    }
+    
+    public void test_ConstructorLjava_io_FileLjava_lang_String4() {
         // Regression test for HARMONY-21
         File path = new File("/dir/file");
         File root = new File("/");
@@ -131,38 +138,35 @@
             assertFalse("Assert 1.1: path absolute ", new File("\\\\\\a\b")
                        .isAbsolute());
         }
-
+    }
+    
+    public void test_ConstructorLjava_io_FileLjava_lang_String5() {
         // Test data used in a few places below
-        dirName = System.getProperty("user.dir");
-        fileName = "input.tst";
+        String dirName = tempDirectory.getPath();
+        String fileName = "input.tst";
 
         // Check filename is preserved correctly
-        d = new File(dirName);
-        f = new File(d, fileName);
-        if (!dirName
-                .regionMatches((dirName.length() - 1), File.separator, 0, 1)) {
-            dirName += File.separator;
-        }
+        File d = new File(dirName);
+        File f = new File(d, fileName);
+        dirName = addTrailingSlash(dirName);
         dirName += fileName;
-        assertEquals("Assert 2: Created incorrect file ",
+        assertEquals("Assert 1: Created incorrect file ",
                      dirName, f.getPath());
 
         // Check null argument is handled
         try {
             f = new File(d, null);
-            fail("Assert 3: NullPointerException not thrown.");
+            fail("Assert 2: NullPointerException not thrown.");
         } catch (NullPointerException e) {
             // Expected.
         }
-
-        f = new File((File) null, fileName);
-        assertTrue("Assert 4: Created incorrect file " + f.getPath(), f
-                .getAbsolutePath().equals(dirName));
-
+    }
+    
+    public void test_ConstructorLjava_io_FileLjava_lang_String6() {
         // Regression for HARMONY-46
         File f1 = new File("a");
         File f2 = new File("a/");
-        assertEquals("Assert 5: Trailing slash file name is incorrect", f1, f2);
+        assertEquals("Trailing slash file name is incorrect", f1, f2);
     }
 
     /**
@@ -177,10 +181,7 @@
             // Expected
         }
 
-        fileName = System.getProperty("user.dir");
-        if (!fileName.regionMatches((fileName.length() - 1), slash, 0, 1)) {
-            fileName += slash;
-        }
+        fileName = addTrailingSlash(tempDirectory.getPath());
         fileName += "input.tst";
 
         File f = new File(fileName);
@@ -190,19 +191,15 @@
     /**
      * @tests java.io.File#File(java.lang.String, java.lang.String)
      */
-    public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+    public void test_ConstructorLjava_lang_StringLjava_lang_String() throws IOException {
         String dirName = null;
         String fileName = "input.tst";
         File f = new File(dirName, fileName);
-        String userDir = System.getProperty("user.dir");
-        if (!userDir.regionMatches((userDir.length() - 1), slash, 0, 1)) {
-            userDir += slash;
-        }
-        userDir += "input.tst";
-        assertEquals("Test 1: Created Incorrect File.",
-                     userDir, f.getAbsolutePath());
+        assertEquals("Test 1: Created Incorrect File", 
+                new File("input.tst").getAbsolutePath(), 
+                f.getAbsolutePath());
 
-        dirName = System.getProperty("user.dir");
+        dirName = tempDirectory.getPath();
         fileName = null;
         try {
             f = new File(dirName, fileName);
@@ -213,7 +210,9 @@
 
         fileName = "input.tst";
         f = new File(dirName, fileName);
-        assertEquals("Test 2: Created Incorrect File", userDir, f.getPath());
+        assertEquals("Test 2: Created Incorrect File", 
+                addTrailingSlash(tempDirectory.getPath()) + "input.tst",
+                f.getPath());
 
         // Regression test for HARMONY-382
         String s = null;
@@ -306,7 +305,7 @@
         // a valid File URI
         File f = new File(new URI("file:///pa%20th/another\u20ac/pa%25th"));
         assertTrue("Created incorrect File " + f.getPath(), f.getPath().equals(
-                slash + "pa th" + slash + "another\u20ac" + slash + "pa%th"));
+                File.separator + "pa th" + File.separator + "another\u20ac" + File.separator + "pa%th"));
     }
 
     /**
@@ -314,13 +313,11 @@
      */
     public void test_canRead() throws IOException {
         // canRead only returns if the file exists so cannot be fully tested.
-        File f = new File(System.getProperty("java.io.tmpdir"), platformId
-                + "canRead.tst");
+        File f = new File(tempDirectory, platformId + "canRead.tst");
         try {
             FileOutputStream fos = new FileOutputStream(f);
             fos.close();
             assertTrue("canRead returned false", f.canRead());
-            f.delete();
         } finally {
             f.delete();
         }
@@ -331,8 +328,7 @@
      */
     public void test_canWrite() throws IOException {
         // canWrite only returns if the file exists so cannot be fully tested.
-        File f = new File(System.getProperty("java.io.tmpdir"), platformId
-                + "canWrite.tst");
+        File f = new File(tempDirectory, platformId + "canWrite.tst");
         try {
             FileOutputStream fos = new FileOutputStream(f);
             fos.close();
@@ -374,7 +370,7 @@
      * @tests java.io.File#createNewFile()
      */
     public void test_createNewFile() throws IOException {
-        String base = System.getProperty("java.io.tmpdir");
+        String base = tempDirectory.getPath();
         boolean dirExists = true;
         int numDir = 1;
         File dir = new File(base, String.valueOf(numDir));
@@ -413,11 +409,11 @@
         assertTrue("File Should Exist.", f1.isFile());
         assertTrue("File Should Exist.", f2.isFile());
         String dirName = f1.getParent();
-        if (!dirName.endsWith(slash)) {
-            dirName += slash;
+        if (!dirName.endsWith(File.separator)) {
+            dirName += File.separator;
         }
         assertEquals("File Saved To Wrong Directory.",
-                     dir.getPath() + slash, dirName);
+                     dir.getPath() + File.separator, dirName);
         assertEquals("File Saved With Incorrect Name.", "tempfile.tst",
                      f1.getName());
 
@@ -468,16 +464,13 @@
         File f1 = null;
         File f2 = null;
         try {
-            f1 = File.createTempFile("hyts_abc", ".tmp");
-            f2 = File.createTempFile("hyts_tf", null);
-            String fileLocation = f1.getParent();
-            if (!fileLocation.endsWith(slash)) {
-                fileLocation += slash;
-            }
-            String tempDir = System.getProperty("java.io.tmpdir");
-            if (!tempDir.endsWith(slash)) {
-                tempDir += slash;
-            }
+            f1 = File.createTempFile("harmony-test-FileTest_tempFile_abc", ".tmp");
+            f2 = File.createTempFile("harmony-test-FileTest_tempFile_tf", null);
+
+            String fileLocation = addTrailingSlash(f1.getParent());
+            
+            String tempDir = addTrailingSlash(System.getProperty("java.io.tmpdir"));
+            
             assertEquals(
                     "File did not save to the default temporary-file location.",
                     tempDir, fileLocation);
@@ -497,10 +490,10 @@
             // tempfiles.
             fileName = f1.getName();
             assertTrue("Test 1: File Created With Incorrect Prefix.", fileName
-                    .startsWith("hyts_abc"));
+                    .startsWith("harmony-test-FileTest_tempFile_abc"));
             fileName = f2.getName();
             assertTrue("Test 2: File Created With Incorrect Prefix.", fileName
-                    .startsWith("hyts_tf"));
+                    .startsWith("harmony-test-FileTest_tempFile_tf"));
 
             // Tests for creating a tempfile with a filename shorter than 3
             // characters.
@@ -547,21 +540,16 @@
         try {
             // Test to make sure that the tempfile was saved in the correct
             // location and with the correct prefix/suffix.
-            f1 = File.createTempFile("hyts_tf", null, null);
+            f1 = File.createTempFile("harmony-test-FileTest_tempFile2_tf", null, null);
             File dir = new File(base);
-            f2 = File.createTempFile("hyts_tf", ".tmp", dir);
+            f2 = File.createTempFile("harmony-test-FileTest_tempFile2_tf", ".tmp", dir);
             File currentFile;
             String fileLocation;
             String fileName;
             for (int i = 0; i < 2; i++) {
                 currentFile = i == 0 ? f1 : f2;
-                fileLocation = currentFile.getParent();
-                if (!fileLocation.endsWith(slash)) {
-                    fileLocation += slash;
-                }
-                if (!base.endsWith(slash)) {
-                    base += slash;
-                }
+                fileLocation = addTrailingSlash(currentFile.getParent());
+                base = addTrailingSlash(base);
                 assertEquals(
                         "File not created in the default temporary-file location.",
                         base, fileLocation);
@@ -569,7 +557,7 @@
                 assertTrue("File created with incorrect suffix.", fileName
                         .endsWith(".tmp"));
                 assertTrue("File created with incorrect prefix.", fileName
-                        .startsWith("hyts_tf"));
+                        .startsWith("harmony-test-FileTest_tempFile2_tf"));
                 currentFile.delete();
             }
 
@@ -593,7 +581,7 @@
             }
             try {
                 // Try to create a file in a directory that does not exist
-                File f3 = File.createTempFile("hyts_tf", null, dir);
+                File f3 = File.createTempFile("harmony-test-FileTest_tempFile2_tf", null, dir);
                 f3.delete();
                 fail("IOException not thrown");
             } catch (IOException e) {
@@ -638,7 +626,7 @@
      * @tests java.io.File#delete()
      */
     public void test_delete() throws IOException {
-        File dir = new File(System.getProperty("user.dir"), platformId
+        File dir = new File(tempDirectory, platformId
                 + "filechk");
         dir.mkdir();
         assertTrue("Directory does not exist", dir.exists());
@@ -708,8 +696,8 @@
             assertTrue("Files Should NOT Return Equal.", !f1.equals(f3));
         }
 
-        f1 = new File(System.getProperty("java.io.tmpdir"), "casetest.tmp");
-        f2 = new File(System.getProperty("java.io.tmpdir"), "CaseTest.tmp");
+        f1 = new File(tempDirectory, "casetest.tmp");
+        f2 = new File(tempDirectory, "CaseTest.tmp");
         new FileOutputStream(f1).close(); // create the file
         if (f1.equals(f2)) {
             try {
@@ -735,7 +723,7 @@
      * @tests java.io.File#exists()
      */
     public void test_exists() throws IOException {
-        File f = new File(System.getProperty("user.dir"), platformId
+        File f = new File(tempDirectory, platformId
                 + "exists.tst");
         assertTrue("Exists returned true for non-existent file", !f.exists());
         FileOutputStream fos = new FileOutputStream(f);
@@ -748,19 +736,16 @@
      * @tests java.io.File#getAbsoluteFile()
      */
     public void test_getAbsoluteFile() {
-        String base = System.getProperty("user.dir");
-        if (!base.endsWith(slash)) {
-            base += slash;
-        }
+        String base = addTrailingSlash(tempDirectory.getPath());
         File f = new File(base, "temp.tst");
         File f2 = f.getAbsoluteFile();
         assertEquals("Test 1: Incorrect File Returned.", 0, f2.compareTo(f
                 .getAbsoluteFile()));
-        f = new File(base + "Temp" + slash + slash + "temp.tst");
+        f = new File(base + "Temp" + File.separator + File.separator + "temp.tst");
         f2 = f.getAbsoluteFile();
         assertEquals("Test 2: Incorrect File Returned.", 0, f2.compareTo(f
                 .getAbsoluteFile()));
-        f = new File(base + slash + ".." + slash + "temp.tst");
+        f = new File(base + File.separator + ".." + File.separator + "temp.tst");
         f2 = f.getAbsoluteFile();
         assertEquals("Test 3: Incorrect File Returned.", 0, f2.compareTo(f
                 .getAbsoluteFile()));
@@ -772,23 +757,20 @@
      * @tests java.io.File#getAbsolutePath()
      */
     public void test_getAbsolutePath() {
-        String base = System.getProperty("user.dir");
-        if (!base.regionMatches((base.length() - 1), slash, 0, 1)) {
-            base += slash;
-        }
+        String base = addTrailingSlash(tempDirectory.getPath());
         File f = new File(base, "temp.tst");
         assertEquals("Test 1: Incorrect Path Returned.",
                      base + "temp.tst", f.getAbsolutePath());
 
-        f = new File(base + "Temp" + slash + slash + slash + "Testing" + slash
+        f = new File(base + "Temp" + File.separator + File.separator + File.separator + "Testing" + File.separator
                 + "temp.tst");
         assertEquals("Test 2: Incorrect Path Returned.",
-		     base + "Temp" + slash + "Testing" + slash + "temp.tst",
+		     base + "Temp" + File.separator + "Testing" + File.separator + "temp.tst",
                      f.getAbsolutePath());
 
-        f = new File(base + "a" + slash + slash + ".." + slash + "temp.tst");
+        f = new File(base + "a" + File.separator + File.separator + ".." + File.separator + "temp.tst");
         assertEquals("Test 3: Incorrect Path Returned.",
-                     base + "a" + slash + ".." + slash + "temp.tst",
+                     base + "a" + File.separator + ".." + File.separator + "temp.tst",
                      f.getAbsolutePath());
         f.delete();
     }
@@ -797,19 +779,16 @@
      * @tests java.io.File#getCanonicalFile()
      */
     public void test_getCanonicalFile() throws IOException {
-        String base = System.getProperty("user.dir");
-        if (!base.endsWith(slash)) {
-            base += slash;
-        }
+        String base = addTrailingSlash(tempDirectory.getPath());
         File f = new File(base, "temp.tst");
         File f2 = f.getCanonicalFile();
         assertEquals("Test 1: Incorrect File Returned.", 0, f2
                 .getCanonicalFile().compareTo(f.getCanonicalFile()));
-        f = new File(base + "Temp" + slash + slash + "temp.tst");
+        f = new File(base + "Temp" + File.separator + File.separator + "temp.tst");
         f2 = f.getCanonicalFile();
         assertEquals("Test 2: Incorrect File Returned.", 0, f2
                 .getCanonicalFile().compareTo(f.getCanonicalFile()));
-        f = new File(base + "Temp" + slash + slash + ".." + slash + "temp.tst");
+        f = new File(base + "Temp" + File.separator + File.separator + ".." + File.separator + "temp.tst");
         f2 = f.getCanonicalFile();
         assertEquals("Test 3: Incorrect File Returned.", 0, f2
                 .getCanonicalFile().compareTo(f.getCanonicalFile()));
@@ -828,7 +807,7 @@
                         .getCanonicalFile().compareTo(f.getCanonicalFile()));
                 FileOutputStream fos = new FileOutputStream(f);
                 fos.close();
-                f2 = new File(testdir + slash + "longdi~1" + slash
+                f2 = new File(testdir + File.separator + "longdi~1" + File.separator
                         + "longfi~1.tst");
                 File canonicalf2 = f2.getCanonicalFile();
                 /*
@@ -855,15 +834,12 @@
     public void test_getCanonicalPath() throws IOException {
         // Should work for Unix/Windows.
         String dots = "..";
-        String base = new File(System.getProperty("user.dir"))
-                .getCanonicalPath();
-        if (!base.regionMatches((base.length() - 1), slash, 0, 1)) {
-            base += slash;
-        }
+        String base = tempDirectory.getCanonicalPath();
+        base = addTrailingSlash(base);
         File f = new File(base, "temp.tst");
         assertEquals("Test 1: Incorrect Path Returned.", base + "temp.tst", f
                 .getCanonicalPath());
-        f = new File(base + "Temp" + slash + dots + slash + "temp.tst");
+        f = new File(base + "Temp" + File.separator + dots + File.separator + "temp.tst");
         assertEquals("Test 2: Incorrect Path Returned.", base + "temp.tst", f
                 .getCanonicalPath());
 
@@ -882,16 +858,16 @@
                 dirExists = false;
             }
         }
-        f = new File(base + dirNumber + slash + dots + slash + dirNumber
-                + slash + "temp.tst");
+        f = new File(base + dirNumber + File.separator + dots + File.separator + dirNumber
+                + File.separator + "temp.tst");
         assertEquals("Test 3: Incorrect Path Returned.", base + dirNumber
-                + slash + "temp.tst", f.getCanonicalPath());
-        f = new File(base + dirNumber + slash + "Temp" + slash + dots + slash
-                + "Test" + slash + "temp.tst");
+                + File.separator + "temp.tst", f.getCanonicalPath());
+        f = new File(base + dirNumber + File.separator + "Temp" + File.separator + dots + File.separator
+                + "Test" + File.separator + "temp.tst");
         assertEquals("Test 4: Incorrect Path Returned.", base + dirNumber
-                + slash + "Test" + slash + "temp.tst", f.getCanonicalPath());
+                + File.separator + "Test" + File.separator + "temp.tst", f.getCanonicalPath());
 
-        f = new File("1234.567");
+        f = new File(base + "1234.567");
         assertEquals("Test 5: Incorrect Path Returned.", base + "1234.567", f
                 .getCanonicalPath());
 
@@ -920,14 +896,14 @@
                         assertTrue("Could not create dir: " + dir2, dir2
                                 .mkdir());
                     }
-                    f2 = new File(testdir.getPath() + slash + "longdirectory"
-                            + platformId + slash + "Test" + slash + dots
-                            + slash + "longfilename.tst");
+                    f2 = new File(testdir.getPath() + File.separator + "longdirectory"
+                            + platformId + File.separator + "Test" + File.separator + dots
+                            + File.separator + "longfilename.tst");
                     FileOutputStream fos2 = new FileOutputStream(f2);
                     fos2.close();
                     dirName1 = f2.getCanonicalPath();
-                    f3 = new File(testdir.getPath() + slash + "longdi~1"
-                            + slash + "Test" + slash + dots + slash
+                    f3 = new File(testdir.getPath() + File.separator + "longdi~1"
+                            + File.separator + "Test" + File.separator + dots + File.separator
                             + "longfi~1.tst");
                     dirName2 = f3.getCanonicalPath();
                     assertEquals("Test 7: Incorrect Path Returned.", dirName1,
@@ -971,10 +947,10 @@
         f.delete();
 
         File f1 = new File("/directory");
-        assertEquals("Wrong parent test 1", slash, f1.getParent());
+        assertEquals("Wrong parent test 1", File.separator, f1.getParent());
         f1 = new File("/directory/file");
         assertEquals("Wrong parent test 2",
-                     slash + "directory", f1.getParent());
+                     File.separator + "directory", f1.getParent());
         f1 = new File("directory/file");
         assertEquals("Wrong parent test 3", "directory", f1.getParent());
         f1 = new File("/");
@@ -984,10 +960,10 @@
 
         if (File.separatorChar == '\\' && new File("d:/").isAbsolute()) {
             f1 = new File("d:/directory");
-            assertEquals("Wrong parent test 1a", "d:" + slash, f1.getParent());
+            assertEquals("Wrong parent test 1a", "d:" + File.separator, f1.getParent());
             f1 = new File("d:/directory/file");
             assertEquals("Wrong parent test 2a",
-                         "d:" + slash + "directory", f1.getParent());
+                         "d:" + File.separator + "directory", f1.getParent());
             f1 = new File("d:directory/file");
             assertEquals("Wrong parent test 3a", "d:directory", f1.getParent());
             f1 = new File("d:/");
@@ -1003,9 +979,9 @@
     public void test_getParentFile() {
         File f = new File("tempfile.tst");
         assertNull("Incorrect path returned", f.getParentFile());
-        f = new File(System.getProperty("user.dir"), "tempfile1.tmp");
-        File f2 = new File(System.getProperty("user.dir"), "tempfile2.tmp");
-        File f3 = new File(System.getProperty("user.dir"), "/a/tempfile.tmp");
+        f = new File(tempDirectory, "tempfile1.tmp");
+        File f2 = new File(tempDirectory, "tempfile2.tmp");
+        File f3 = new File(tempDirectory, "/a/tempfile.tmp");
         assertEquals("Incorrect File Returned", 0, f.getParentFile().compareTo(
                 f2.getParentFile()));
         assertTrue("Incorrect File Returned", f.getParentFile().compareTo(
@@ -1022,14 +998,14 @@
         String base = System.getProperty("user.home");
         String fname;
         File f1;
-        if (!base.regionMatches((base.length() - 1), slash, 0, 1)) {
-            base += slash;
+        if (!base.regionMatches((base.length() - 1), File.separator, 0, 1)) {
+            base += File.separator;
         }
         fname = base + "filechk.tst";
         f1 = new File(base, "filechk.tst");
         File f2 = new File("filechk.tst");
         File f3 = new File("c:");
-        File f4 = new File(base + "a" + slash + slash + ".." + slash
+        File f4 = new File(base + "a" + File.separator + File.separator + ".." + File.separator
                 + "filechk.tst");
         assertEquals("getPath returned incorrect path(f1)",
                      fname, f1.getPath());
@@ -1037,7 +1013,7 @@
                      "filechk.tst", f2.getPath());
         assertEquals("getPath returned incorrect path(f3)","c:", f3.getPath());
         assertEquals("getPath returned incorrect path(f4)",
-                     base + "a" + slash + ".." + slash + "filechk.tst",
+                     base + "a" + File.separator + ".." + File.separator + "filechk.tst",
                      f4.getPath());
         f1.delete();
         f2.delete();
@@ -1065,7 +1041,7 @@
         assertEquals(-1, f2.compareTo(f1));
         assertEquals(1, f1.compareTo(f2));
 
-        File parent = new File(System.getProperty("user.dir"));
+        File parent = tempDirectory;
         f3 = new File(parent, "");
 
         assertEquals(parent.getPath(), f3.getPath());
@@ -1121,10 +1097,7 @@
      * @tests java.io.File#isDirectory()
      */
     public void test_isDirectory() {
-        String base = System.getProperty("user.dir");
-        if (!base.regionMatches((base.length() - 1), slash, 0, 1)) {
-            base += slash;
-        }
+        String base = addTrailingSlash(tempDirectory.getPath());
         File f = new File(base);
         assertTrue("Test 1: Directory Returned False", f.isDirectory());
         f = new File(base + "zxzxzxz" + platformId);
@@ -1142,12 +1115,11 @@
      * @tests java.io.File#isFile()
      */
     public void test_isFile() throws IOException {
-        String base = System.getProperty("user.dir");
+        String base = tempDirectory.getPath();
         File f = new File(base);
-        assertTrue("Directory Returned True As Being A File.", !f.isFile());
-        if (!base.regionMatches((base.length() - 1), slash, 0, 1)) {
-            base += slash;
-        }
+        assertFalse("Directory Returned True As Being A File.", f.isFile());
+        
+        base = addTrailingSlash(base);
         f = new File(base, platformId + "amiafile");
         assertTrue("Non-existent File Returned True", !f.isFile());
         FileOutputStream fos = new FileOutputStream(f);
@@ -1161,7 +1133,7 @@
      */
     public void test_isHidden() throws IOException, InterruptedException {
         boolean onUnix = File.separatorChar == '/';
-        File f = File.createTempFile("hyts_", ".tmp");
+        File f = File.createTempFile("harmony-test-FileTest_isHidden_", ".tmp");
         // On Unix hidden files are marked with a "." at the beginning
         // of the file name.
         if (onUnix) {
@@ -1213,7 +1185,7 @@
      * @tests java.io.File#length()
      */
     public void test_length() throws IOException {
-        File f = new File(System.getProperty("user.dir"), platformId
+        File f = new File(tempDirectory, platformId
                 + "input.tst");
         assertEquals("File Length Should Have Returned 0.", 0, f.length());
         FileOutputStream fos = new FileOutputStream(f);
@@ -1235,7 +1207,7 @@
      * @tests java.io.File#list()
      */
     public void test_list() throws IOException {
-        String base = System.getProperty("user.dir");
+        String base = tempDirectory.getPath();
         // Old test left behind "garbage files" so this time it creates a
         // directory that is guaranteed not to already exist (and deletes it
         // afterward.)
@@ -1329,7 +1301,7 @@
      * @tests java.io.File#listFiles()
      */
     public void test_listFiles() throws IOException, InterruptedException {
-        String base = System.getProperty("user.dir");
+        String base = tempDirectory.getPath();
         // Finding a non-existent directory to create.
         int dirNumber = 1;
         boolean dirExists = true;
@@ -1661,7 +1633,7 @@
      * @tests java.io.File#list(java.io.FilenameFilter)
      */
     public void test_listLjava_io_FilenameFilter() throws IOException {
-        String base = System.getProperty("user.dir");
+        String base = tempDirectory.getPath();
         // Old test left behind "garbage files" so this time it creates a
         // directory that is guaranteed not to already exist (and deletes it
         // afterward.)
@@ -1770,7 +1742,7 @@
                     roots.length);
             String fileLoc = roots[0].getPath();
             assertTrue("Incorrect Root Directory Returned.", fileLoc
-                    .startsWith(slash));
+                    .startsWith(File.separator));
         } else if (onWindows) {
             // Need better test for Windows
             assertTrue("Incorrect Number Of Root Directories.",
@@ -1782,7 +1754,7 @@
      * @tests java.io.File#mkdir()
      */
     public void test_mkdir() throws IOException {
-        String base = System.getProperty("user.dir");
+        String base = tempDirectory.getPath();
         // Old test left behind "garbage files" so this time it creates a
         // directory that is guaranteed not to already exist (and deletes it
         // afterward.)
@@ -1858,28 +1830,25 @@
      * HARMONY-6041
      */
     public void test_mkdir_special_unicode() throws IOException {
-        tempDirectory = new File("\u5C73");
+        File specialDir = new File(this.tempDirectory,"\u5C73");
         int i = 0;
-        while (tempDirectory.exists()) {
-            tempDirectory = new File("\u5C73" + i);
+        while (specialDir.exists()) {
+            specialDir = new File("\u5C73" + i);
             ++i;
         }
-        assertFalse(tempDirectory.exists());
-        assertTrue(tempDirectory.mkdir());
-        assertTrue(tempDirectory.exists());
+        assertFalse(specialDir.exists());
+        assertTrue(specialDir.mkdir());
+        assertTrue(specialDir.exists());
     }
 
     /**
      * @tests java.io.File#mkdirs()
      */
     public void test_mkdirs() {
-        String userHome = System.getProperty("user.dir");
-        if (!userHome.endsWith(slash)) {
-            userHome += slash;
-        }
-        File f = new File(userHome + "mdtest" + platformId + slash + "mdtest2",
+        String userHome = addTrailingSlash(tempDirectory.getPath());
+        File f = new File(userHome + "mdtest" + platformId + File.separator + "mdtest2",
                 "p.tst");
-        File g = new File(userHome + "mdtest" + platformId + slash + "mdtest2");
+        File g = new File(userHome + "mdtest" + platformId + File.separator + "mdtest2");
         File h = new File(userHome + "mdtest" + platformId);
         f.mkdirs();
         try {
@@ -1897,7 +1866,7 @@
      * @tests java.io.File#renameTo(java.io.File)
      */
     public void test_renameToLjava_io_File() throws IOException {
-        String base = System.getProperty("user.dir");
+        String base = tempDirectory.getPath();
         File dir = new File(base, platformId);
         dir.mkdir();
         File f = new File(dir, "xxx.xxx");
@@ -1937,7 +1906,7 @@
         File f1 = null;
         try {
             f1 = new File(Support_PlatformFile.getNewPlatformFile(
-                    "hyts_tf_slm", ".tmp"));
+                    "harmony-test-FileTest_setLastModified", ".tmp"));
             f1.createNewFile();
             long orgTime = f1.lastModified();
             // Subtracting 100 000 milliseconds from the orgTime of File f1
@@ -1997,8 +1966,8 @@
         File f1 = null;
         File f2 = null;
         try {
-            f1 = File.createTempFile("hyts_tf", ".tmp");
-            f2 = File.createTempFile("hyts_tf", ".tmp");
+            f1 = File.createTempFile("harmony-test-FileTest_setReadOnly", ".tmp");
+            f2 = File.createTempFile("harmony-test-FileTest_setReadOnly", ".tmp");
             // Assert is flawed because canWrite does not work.
             // assertTrue("File f1 Is Set To ReadOnly." , f1.canWrite());
             f1.setReadOnly();
@@ -2061,7 +2030,7 @@
             f2.setReadOnly();
             assertTrue("File f2 Did Not Delete", f2.delete());
             // Similarly, trying to delete a read-only directory should succeed
-            f2 = new File(System.getProperty("user.dir"), "deltestdir");
+            f2 = new File(tempDirectory, "deltestdir");
             f2.mkdir();
             f2.setReadOnly();
             assertTrue("Directory f2 Did Not Delete", f2.delete());
@@ -2080,7 +2049,7 @@
      * @tests java.io.File#toString()
      */
     public void test_toString() {
-        String fileName = System.getProperty("user.home") + slash + "input.tst";
+        String fileName = System.getProperty("user.home") + File.separator + "input.tst";
         File f = new File(fileName);
         assertEquals("Incorrect string returned", fileName, f.toString());
 
@@ -2095,7 +2064,7 @@
      */
     public void test_toURI() throws URISyntaxException {
         // Need a directory that exists
-        File dir = new File(System.getProperty("user.dir"));
+        File dir = tempDirectory;
 
         // Test for toURI when the file is a directory.
         String newURIPath = dir.getAbsolutePath();
@@ -2138,7 +2107,7 @@
      */
     public void test_toURL() throws MalformedURLException {
         // Need a directory that exists
-        File dir = new File(System.getProperty("user.dir"));
+        File dir = tempDirectory;
 
         // Test for toURL when the file is a directory.
         String newDirURL = dir.getAbsolutePath();
@@ -2177,7 +2146,7 @@
      * @tests java.io.File#toURI()
      */
     public void test_toURI2() throws URISyntaxException {
-        File f = new File(System.getProperty("user.dir"), "a/b/c/../d/e/./f");
+        File f = new File(tempDirectory, "a/b/c/../d/e/./f");
 
         String path = f.getAbsolutePath();
         path = path.replace(File.separatorChar, '/');
@@ -2194,7 +2163,7 @@
      * @tests java.io.File#toURL()
      */
     public void test_toURL2() throws MalformedURLException {
-        File f = new File(System.getProperty("user.dir"), "a/b/c/../d/e/./f");
+        File f = new File(tempDirectory, "a/b/c/../d/e/./f");
 
         String path = f.getAbsolutePath();
         path = path.replace(File.separatorChar, '/');
@@ -2280,39 +2249,4 @@
         File file = new File("FileTest.golden.ser");
         SerializationTest.verifyGolden(this, file);
     }
-
-    /**
-     * Sets up the fixture, for example, open a network connection. This method
-     * is called before a test is executed.
-     */
-    protected void setUp() throws IOException {
-        /** Setup the temporary directory */
-        String userDir = System.getProperty("user.dir");
-        if (userDir == null) {
-            userDir = "j:\\jcl-builddir\\temp\\source";
-        }
-        if (!userDir.regionMatches((userDir.length() - 1), slash, 0, 1)) {
-            userDir += slash;
-        }
-        tempDirectory = new File(userDir + "tempDir"
-                + String.valueOf(System.currentTimeMillis()));
-        if (!tempDirectory.mkdir()) {
-            System.out.println("Setup for FileTest failed.");
-        }
-
-        /** Setup the temporary file */
-        tempFile = new File(tempDirectory, "tempfile");
-        FileOutputStream tempStream = new FileOutputStream(tempFile.getPath(),
-                false);
-        tempStream.close();
-    }
-
-    /**
-     * Tears down the fixture, for example, close a network connection. This
-     * method is called after a test is executed.
-     */
-    protected void tearDown() {
-        tempFile.delete();
-        tempDirectory.delete();
-    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java Sun Apr 19 11:15:28 2009
@@ -332,7 +332,7 @@
         ois.read(buf, 0, 10);
         ois.close();
         assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0,
-                10));
+                10, "UTF-8"));
     }
 
     /**
@@ -428,7 +428,7 @@
         ois.readFully(buf);
         ois.close();
         assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0,
-                10));
+                10, "UTF-8"));
     }
 
     /**
@@ -442,7 +442,7 @@
         ois.readFully(buf, 0, 10);
         ois.close();
         assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0,
-                10));
+                10, "UTF-8"));
     }
 
     /**
@@ -499,8 +499,8 @@
         // - class A implements Serializable
         // - class C extends A
 
-        byte[] cName = C.class.getName().getBytes();
-        byte[] aName = A.class.getName().getBytes();
+        byte[] cName = C.class.getName().getBytes("UTF-8");
+        byte[] aName = A.class.getName().getBytes("UTF-8");
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
@@ -675,7 +675,7 @@
         ois.skipBytes(5);
         ois.read(buf, 0, 5);
         ois.close();
-        assertEquals("Skipped incorrect bytes", "World", new String(buf, 0, 5));
+        assertEquals("Skipped incorrect bytes", "World", new String(buf, 0, 5, "UTF-8"));
 
         // Regression for HARMONY-844
         try {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java Sun Apr 19 11:15:28 2009
@@ -243,7 +243,7 @@
 
             boolean pass = false;
 
-            boolean readerAlive = true;
+            volatile boolean readerAlive = true;
 
             public void run() {
                 try {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java Sun Apr 19 11:15:28 2009
@@ -300,7 +300,7 @@
 
         class WriteRunnable implements Runnable {
             boolean pass = false;
-            boolean readerAlive = true;
+            volatile boolean readerAlive = true;
             public void run() {
                 try {
                     pw.write(1);
@@ -361,7 +361,7 @@
         class WriteRunnable implements Runnable {
             boolean pass = false;
 
-            boolean readerAlive = true;
+            volatile boolean readerAlive = true;
 
             public void run() {
                 try {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java Sun Apr 19 11:15:28 2009
@@ -1666,8 +1666,8 @@
                 .getDirectionality(0xFB4F));
         assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT, Character
                 .getDirectionality(0x10838));
-        
-        assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC, Character
+        // Unicode standard 5.1 changed category of unicode point 0x0600 from AL to AN
+        assertEquals(Character.DIRECTIONALITY_ARABIC_NUMBER, Character
                 .getDirectionality(0x0600));
         assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC, Character
                 .getDirectionality(0xFEFC));

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java Sun Apr 19 11:15:28 2009
@@ -184,6 +184,235 @@
 						"public abstract"));
 	}
 
+    public void test_Constants_Value() {
+        assertEquals(1024, Modifier.ABSTRACT);
+        assertEquals(16, Modifier.FINAL);
+        assertEquals(512, Modifier.INTERFACE);
+        assertEquals(256, Modifier.NATIVE);
+        assertEquals(2, Modifier.PRIVATE);
+        assertEquals(4, Modifier.PROTECTED);
+        assertEquals(1, Modifier.PUBLIC);
+        assertEquals(8, Modifier.STATIC);
+        assertEquals(2048, Modifier.STRICT);
+        assertEquals(32, Modifier.SYNCHRONIZED);
+        assertEquals(128, Modifier.TRANSIENT);
+        assertEquals(64, Modifier.VOLATILE);
+    }
+
+    abstract class AbstractClazz {
+    }
+
+    final class FinalClazz {
+    }
+    
+    static class StaticClazz {
+    }
+
+    interface InterfaceClazz {
+    }
+    
+    public class PublicClazz {
+    }
+
+    protected class ProtectedClazz {
+    }
+
+    private class PrivateClazz {
+    }
+
+    public abstract class PublicAbstractClazz {
+    }
+
+    protected abstract class ProtectedAbstractClazz {
+    }
+
+    private abstract class PrivateAbstractClazz {
+    }
+
+    public final class PublicFinalClazz {
+    }
+
+    protected final class ProtectedFinalClazz {
+    }
+
+    private final class PrivateFinalClazz {
+    }
+
+    public static class PublicStaticClazz {
+    }
+
+    protected static class ProtectedStaticClazz {
+    }
+
+    private static class PrivateStaticClazz {
+    }
+
+    public interface PublicInterface {
+    }
+
+    protected interface ProtectedInterface {
+    }
+
+    private interface PrivateInterface {
+    }
+
+    static abstract class StaticAbstractClazz {
+    }
+
+    public static abstract class PublicStaticAbstractClazz {
+    }
+
+    protected static abstract class ProtectedStaticAbstractClazz {
+    }
+
+    private static abstract class PrivateStaticAbstractClazz {
+    }
+
+    static final class StaticFinalClazz {
+    }
+
+    public static final class PublicStaticFinalClazz {
+    }
+
+    protected static final class ProtectedStaticFinalClazz {
+    }
+
+    private static final class PrivateStaticFinalClazz {
+    }
+
+    static interface StaticInterface {
+    }
+
+    public static interface PublicStaticInterface {
+    }
+
+    protected static interface ProtectedStaticInterface {
+    }
+
+    private static interface PrivateStaticInterface {
+    }
+
+    static abstract interface StaticAbstractInterface {
+    }
+
+    public static abstract interface PublicStaticAbstractInterface {
+    }
+
+    protected static abstract interface ProtectedStaticAbstractInterface {
+    }
+
+    private static abstract interface PrivateStaticAbstractInterface {
+    }
+
+    public void test_Class_Modifier() {
+        assertEquals(Modifier.ABSTRACT, AbstractClazz.class.getModifiers());
+        assertEquals(Modifier.FINAL, FinalClazz.class.getModifiers());
+        assertEquals(Modifier.STATIC, StaticClazz.class.getModifiers());
+        assertEquals(Modifier.INTERFACE + Modifier.STATIC + Modifier.ABSTRACT,
+                InterfaceClazz.class.getModifiers());
+
+        assertEquals(Modifier.PUBLIC, PublicClazz.class.getModifiers());
+        assertEquals(Modifier.PROTECTED, ProtectedClazz.class.getModifiers());
+        assertEquals(Modifier.PRIVATE, PrivateClazz.class.getModifiers());
+
+        assertEquals(Modifier.PUBLIC + Modifier.ABSTRACT,
+                PublicAbstractClazz.class.getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.ABSTRACT,
+                ProtectedAbstractClazz.class.getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.ABSTRACT,
+                PrivateAbstractClazz.class.getModifiers());
+
+        assertEquals(Modifier.PUBLIC + Modifier.FINAL, PublicFinalClazz.class
+                .getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.FINAL,
+                ProtectedFinalClazz.class.getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.FINAL, PrivateFinalClazz.class
+                .getModifiers());
+
+        assertEquals(Modifier.PUBLIC + Modifier.STATIC, PublicStaticClazz.class
+                .getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.STATIC,
+                ProtectedStaticClazz.class.getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.STATIC,
+                PrivateStaticClazz.class.getModifiers());
+
+        assertEquals(Modifier.PUBLIC + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, PublicInterface.class.getModifiers());
+        assertEquals(Modifier.STATIC + Modifier.FINAL, StaticFinalClazz.class
+                .getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, PrivateInterface.class.getModifiers());
+
+        assertEquals(Modifier.STATIC + Modifier.ABSTRACT,
+                StaticAbstractClazz.class.getModifiers());
+        assertEquals(Modifier.PUBLIC + Modifier.STATIC + Modifier.ABSTRACT,
+                PublicStaticAbstractClazz.class.getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.STATIC + Modifier.ABSTRACT,
+                ProtectedStaticAbstractClazz.class.getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.STATIC + Modifier.ABSTRACT,
+                PrivateStaticAbstractClazz.class.getModifiers());
+
+        assertEquals(Modifier.STATIC + Modifier.FINAL, StaticFinalClazz.class
+                .getModifiers());
+        assertEquals(Modifier.PUBLIC + Modifier.STATIC + Modifier.FINAL,
+                PublicStaticFinalClazz.class.getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.STATIC + Modifier.FINAL,
+                ProtectedStaticFinalClazz.class.getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.STATIC + Modifier.FINAL,
+                PrivateStaticFinalClazz.class.getModifiers());
+
+        assertEquals(Modifier.INTERFACE + Modifier.STATIC + Modifier.ABSTRACT,
+                StaticInterface.class.getModifiers());
+        assertEquals(Modifier.PUBLIC + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, PublicStaticInterface.class.getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, ProtectedStaticInterface.class
+                .getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, PrivateStaticInterface.class
+                .getModifiers());
+
+        assertEquals(Modifier.INTERFACE + Modifier.STATIC + Modifier.ABSTRACT,
+                StaticAbstractInterface.class.getModifiers());
+        assertEquals(Modifier.PUBLIC + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, PublicStaticAbstractInterface.class
+                .getModifiers());
+        assertEquals(Modifier.PROTECTED + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, ProtectedStaticAbstractInterface.class
+                .getModifiers());
+        assertEquals(Modifier.PRIVATE + Modifier.INTERFACE + Modifier.STATIC
+                + Modifier.ABSTRACT, PrivateStaticAbstractInterface.class
+                .getModifiers());
+    }
+
+    static abstract class MethodClass {
+        
+        public abstract void publicAbstractMethod();
+        
+        public static void publicStaticMethod() {
+        }
+
+        public final void publicFinalMethod() {
+        }
+        
+        public static final void publicStaticFinalMethod() {
+        }
+    }
+
+    public void test_Method_Modifier() throws Exception {
+        assertEquals(Modifier.PUBLIC + Modifier.ABSTRACT, MethodClass.class
+                .getMethod("publicAbstractMethod", new Class[0]).getModifiers());
+        assertEquals(Modifier.PUBLIC + Modifier.STATIC, MethodClass.class
+                .getMethod("publicStaticMethod", new Class[0]).getModifiers());
+        
+        assertEquals(Modifier.PUBLIC + Modifier.FINAL, MethodClass.class
+                .getMethod("publicFinalMethod", new Class[0]).getModifiers());
+        
+        assertEquals(Modifier.PUBLIC + Modifier.STATIC + Modifier.FINAL,
+                MethodClass.class.getMethod("publicStaticFinalMethod",
+                        new Class[0]).getModifiers());
+    }
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java Sun Apr 19 11:15:28 2009
@@ -33,6 +33,7 @@
 import java.net.SocketImplFactory;
 import java.net.UnknownHostException;
 import java.util.Date;
+import java.util.Locale;
 import java.util.Properties;
 
 import org.apache.harmony.luni.net.PlainServerSocketImpl;
@@ -671,6 +672,26 @@
                 .isClosed());
     }
 
+    /*
+     * Regression HARMONY-6090
+     */
+    public void test_defaultValueReuseAddress() throws Exception {
+        String platform = System.getProperty("os.name").toLowerCase(Locale.US);
+        if (!platform.startsWith("windows")) {
+            // on Unix
+            assertTrue(new ServerSocket().getReuseAddress());
+            assertTrue(new ServerSocket(0).getReuseAddress());
+            assertTrue(new ServerSocket(0, 50).getReuseAddress());
+            assertTrue(new ServerSocket(0, 50, InetAddress.getLocalHost()).getReuseAddress());
+        } else {
+            // on Windows
+            assertFalse(new ServerSocket().getReuseAddress());
+            assertFalse(new ServerSocket(0).getReuseAddress());
+            assertFalse(new ServerSocket(0, 50).getReuseAddress());
+            assertFalse(new ServerSocket(0, 50, InetAddress.getLocalHost()).getReuseAddress());
+        }
+    }
+
     /**
      * @tests java.net.ServerSocket#setReuseAddress(boolean)
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Sun Apr 19 11:15:28 2009
@@ -35,6 +35,7 @@
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 import java.security.Permission;
+import java.util.Locale;
 
 import org.apache.harmony.luni.net.PlainSocketImpl;
 
@@ -860,19 +861,55 @@
 
         InputStream in = pingClient.getInputStream();
         in.read(new byte[42]);
-
-        // Check EOF
-        assertEquals(-1, in.read());
+        if (isUnix()) {
+            try {
+                in.read();
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+        } else {
+            // Check EOF
+            assertEquals(-1, in.read());
+        }
 
         in.close();
 
-        // No exception when reading a closed stream
-        assertEquals(-1, in.read());
+        if (isUnix()) {
+            try {
+                in.read();
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+            try {
+                in.read(new byte[5]);
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+        } else {
+            // No exception when reading a closed stream
+            assertEquals(-1, in.read());
+            assertEquals(-1, in.read(new byte[5]));
+        }
 
         pingClient.close();
         pingServer.close();
     }
 
+    private boolean isUnix() {
+        String osName = System.getProperty("os.name");
+
+        // only comparing ASCII, so assume english locale
+        osName = (osName == null ? null : osName.toLowerCase(Locale.ENGLISH));
+
+        if (osName != null && osName.startsWith("windows")) { //$NON-NLS-1$
+            return false;
+        }
+        return true;
+    }
+
     /**
      * @tests java.net.Socket#getKeepAlive()
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java Sun Apr 19 11:15:28 2009
@@ -31,14 +31,30 @@
 import java.util.Vector;
 
 import junit.framework.TestCase;
-
-import org.apache.harmony.luni.util.InvalidJarIndexException;
-
 import tests.support.Support_Configuration;
+import tests.support.Support_Jetty;
 import tests.support.resource.Support_Resources;
 
 public class URLClassLoaderTest extends TestCase {
 
+    private static final String PREFIX = "http://localhost:";
+
+    private static final String ROOT = "../../support/src/test/resources/net.resources/HTTP/html/testres231";
+
+    private static String serverURL = null;
+
+    URLClassLoader ucl;
+
+    static {
+        int port = 0;
+        try {
+            port = Support_Jetty.startHttpServerWithDocRoot(ROOT);
+        } catch (Exception e) {
+            fail("Exception during setup jetty : " + e.getMessage());
+        }
+        serverURL = PREFIX + port + "/";
+    }
+
     class BogusClassLoader extends ClassLoader {
         public URL getResource(String res) {
             try {
@@ -60,24 +76,22 @@
         }
     }
 
-    URLClassLoader ucl;
-
     /**
      * @tests java.net.URLClassLoader#URLClassLoader(java.net.URL[])
      */
-    public void test_Constructor$Ljava_net_URL() {
+    public void test_Constructor$Ljava_net_URL() throws Exception {
         URL[] u = new URL[0];
         ucl = new URLClassLoader(u);
-        assertTrue("Failed to set parent", ucl != null
-                && ucl.getParent() == URLClassLoader.getSystemClassLoader());
+        assertNotNull(ucl);
+        assertSame("Failed to set parent", URLClassLoader
+                .getSystemClassLoader(), ucl.getParent());
 
         URLClassLoader loader = new URLClassLoader(new URL[] { null });
-        boolean exception = false;
         try {
             Class.forName("test", false, loader);
-            fail("Should throw ClassNotFoundException");
-        } catch (ClassNotFoundException e) {
-            // expected
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
         }
     }
 
@@ -98,15 +112,13 @@
      * @tests java.net.URLClassLoader#findResources(java.lang.String)
      */
     public void test_findResourcesLjava_lang_String() throws IOException {
-        Enumeration res = null;
         String[] resValues = { "This is a test resource file.",
                 "This is a resource from a subdir" };
-
         URL[] urls = new URL[2];
-        urls[0] = new URL(Support_Resources.getResourceURL("/"));
-        urls[1] = new URL(Support_Resources.getResourceURL("/subdir1/"));
+        urls[0] = new URL(serverURL);
+        urls[1] = new URL(serverURL + "/subdir1/");
         ucl = new URLClassLoader(urls);
-        res = ucl.findResources("RESOURCE.TXT");
+        Enumeration res = ucl.findResources("RESOURCE.TXT");
         assertNotNull("Failed to locate resources", res);
 
         int i = 0;
@@ -120,7 +132,7 @@
             assertEquals("Returned incorrect resource/or in wrong order",
                     resValues[i++], sb.toString());
         }
-        assertTrue("Incorrect number of resources returned: " + i, i == 2);
+        assertEquals("Incorrect number of resources returned: " + i, 2, i);
     }
 
     /**
@@ -146,22 +158,18 @@
     public void test_newInstance$Ljava_net_URL() throws MalformedURLException,
             ClassNotFoundException {
         // Verify that loaded class' have correct permissions
-        Class cl = null;
-        URL res = null;
         URL[] urls = new URL[1];
-        urls[0] = new URL(Support_Resources.getResourceURL("/UCL/UCL.jar"));
+        urls[0] = new URL(serverURL + "/UCL/UCL.jar");
         ucl = URLClassLoader.newInstance(urls);
-        cl = ucl.loadClass("ucl.ResClass");
+        Class cl = ucl.loadClass("ucl.ResClass");
 
-        res = cl.getClassLoader().getResource("XX.class");
+        URL res = cl.getClassLoader().getResource("XX.class");
         assertNotNull("Failed to load class", cl);
         assertNotNull(
                 "Loaded class unable to access resource from same codeSource",
                 res);
         cl = null;
-
-        urls[0] = new URL("jar:"
-                + Support_Resources.getResourceURL("/UCL/UCL.jar!/"));
+        urls[0] = new URL("jar:" + serverURL + "/UCL/UCL.jar!/");
         ucl = URLClassLoader.newInstance(urls);
         cl = ucl.loadClass("ucl.ResClass");
         assertNotNull("Failed to load class from explicit jar URL", cl);
@@ -210,42 +218,35 @@
         if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\') {
             resPath = resPath.substring(1);
         }
-
-        java.net.URL[] urls = new java.net.URL[1];
-        java.net.URLClassLoader ucl = null;
-        boolean classFound;
-        boolean exception;
-        boolean goodException;
-        Enumeration en;
-        boolean resourcesFound;
         Support_Resources.copyFile(resources, "JarIndex", "hyts_11.jar");
         Support_Resources.copyFile(resources, "JarIndex", "hyts_12.jar");
         Support_Resources.copyFile(resources, "JarIndex", "hyts_13.jar");
         Support_Resources.copyFile(resources, "JarIndex", "hyts_14.jar");
+
+        URL[] urls = new URL[1];
         urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_11.jar");
-        ucl = URLClassLoader.newInstance(urls, null);
+        URLClassLoader ucl = URLClassLoader.newInstance(urls, null);
+
         URL resURL = ucl.findResource("Test.txt");
         URL reference = new URL("jar:file:/" + resPath.replace('\\', '/')
                 + "/JarIndex/hyts_14.jar!/Test.txt");
-        assertTrue("Resource not found: " + resURL + " ref: " + reference,
-                resURL.equals(reference));
+        assertEquals("Resource not found: " + resURL + " ref: " + reference,
+                reference, resURL);
 
-        Class c = Class.forName("cpack.CNothing", true, ucl);
-        assertNotNull(c);
+        assertNotNull(Class.forName("cpack.CNothing", true, ucl));
 
         Support_Resources.copyFile(resources, "JarIndex", "hyts_21.jar");
         Support_Resources.copyFile(resources, "JarIndex", "hyts_22.jar");
         Support_Resources.copyFile(resources, "JarIndex", "hyts_23.jar");
         urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_21.jar");
         ucl = URLClassLoader.newInstance(urls, null);
-        en = ucl.findResources("bpack/");
+        Enumeration en = ucl.findResources("bpack/");
 
+        boolean resourcesFound;
         try {
             resourcesFound = true;
             URL url1 = (URL) en.nextElement();
             URL url2 = (URL) en.nextElement();
-            System.out.println(url1);
-            System.out.println(url2);
             resourcesFound = resourcesFound
                     && url1.equals(new URL("jar:file:/"
                             + resPath.replace('\\', '/')
@@ -262,19 +263,18 @@
         }
         assertTrue("Resources not found (1)", resourcesFound);
 
-        Class c2 = Class.forName("bpack.Homer", true, ucl);
-        assertNotNull(c2);
+        assertNotNull(Class.forName("bpack.Homer", true, ucl));
 
         try {
             Class.forName("bpack.Bart", true, ucl);
-            fail("InvalidJarIndexException should be thrown");
-        } catch (InvalidJarIndexException e) {
-            // expected
+            fail("should throw ClassNotFoundException");
+        } catch (ClassNotFoundException e) {
+            // Expected
         }
 
         try {
             Class.forName("Main4", true, ucl);
-            fail("ClassNotFoundException should be thrown");
+            fail("should throw ClassNotFoundException");
         } catch (ClassNotFoundException e) {
             // Expected
         }
@@ -289,7 +289,7 @@
 
         try {
             Class.forName("cpack.Mock", true, ucl);
-            fail("ClassNotFoundException should be thrown");
+            fail("should throw ClassNotFoundException");
         } catch (ClassNotFoundException e) {
             // Expected
         }
@@ -311,7 +311,7 @@
         try {
             URLClassLoaderExt cl = new URLClassLoaderExt(new URL[557]);
             cl.findClass("0");
-            fail("NullPointerException should be thrown");
+            fail("should throw NullPointerException");
         } catch (NullPointerException npe) {
             // Expected
         }
@@ -323,12 +323,12 @@
         try {
             Class.forName("foo.Foo", false, cl);
         } catch (Exception ex) {
-            // Don't care
+            // Ignored
         }
 
         try {
             Class.forName("foo.Foo", false, cl);
-            fail("NullPointerException should be thrown");
+            fail("should throw ClassNotFoundException");
         } catch (ClassNotFoundException cnfe) {
             // Expected
         }
@@ -339,13 +339,11 @@
      */
     public void test_findResourceLjava_lang_String()
             throws MalformedURLException {
-        URL res = null;
-
         URL[] urls = new URL[2];
-        urls[0] = new URL("http://" + Support_Configuration.HomeAddress);
-        urls[1] = new URL(Support_Resources.getResourceURL("/"));
+        urls[0] = new URL(serverURL);
+        urls[1] = new URL(serverURL);
         ucl = new URLClassLoader(urls);
-        res = ucl.findResource("RESOURCE.TXT");
+        URL res = ucl.findResource("RESOURCE.TXT");
         assertNotNull("Failed to locate resource", res);
 
         StringBuffer sb = new StringBuffer();
@@ -389,6 +387,27 @@
                 loader.getResource(f2.getName()));
     }
 
+    public void test_findResource() throws Exception {
+        File resources = Support_Resources.createTempFolder();
+        String resPath = resources.toString();
+        if (resPath.charAt(0) == '/' || resPath.charAt(0) == ' ') {
+            resPath = resPath.substring(1);
+        }
+        Support_Resources.copyFile(resources, "JarIndex", "hyts_21.jar");
+        Support_Resources.copyFile(resources, "JarIndex", "hyts_22.jar");
+        Support_Resources.copyFile(resources, "JarIndex", "hyts_23.jar");
+
+        URLClassLoader urlClassloader = URLClassLoader.newInstance(
+                new URL[] { new URL("file:/" + resPath
+                        + "/JarIndex/hyts_21.jar") }, null);
+        Enumeration en = urlClassloader.findResources("bpack/");
+        assertTrue(en.hasMoreElements());
+        URL expected = new URL("jar:file:/" + resPath.replace('\\', '/')
+                + "/JarIndex/hyts_22.jar!/bpack/");
+        assertEquals(expected, (URL) en.nextElement());
+        assertEquals(expected, urlClassloader.findResource("bpack/"));
+    }
+
     /**
      * @tests java.net.URLClassLoader#getResource(java.lang.String)
      */
@@ -452,11 +471,10 @@
      * Regression test for HARMONY-2255
      */
     public void test_getResourceAsStream() {
-        InputStream in = this.getClass().getClassLoader().getResourceAsStream(
-                "tests/api/java/net/test%.properties");
+        InputStream in = this.getClass()
+                .getResourceAsStream("test%.properties");
         assertNotNull(in);
-        in = this.getClass().getClassLoader().getResourceAsStream(
-                "tests/api/java/net/test%25.properties");
+        in = this.getClass().getResourceAsStream("test%25.properties");
         assertNull(in);
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/Collections2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/Collections2Test.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/Collections2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/Collections2Test.java Sun Apr 19 11:15:28 2009
@@ -464,4 +464,33 @@
         assertTrue(emptyList instanceof RandomAccess);
     }
 
+    // Regression test for http://issues.apache.org/jira/browse/HARMONY-6122
+    public void test_Collections_swap_IndexOutOfBoundsException() {
+        try {
+            Collections.swap(new ArrayList<Object>(), -1, 3);
+            fail("IOOBE expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        
+        List<Object> list = new ArrayList<Object>();
+        list.add("0");
+        try {
+            Collections.swap(list, 0, -1);
+            fail("IOOBE expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        
+        try {
+            Collections.swap(list, 0, 3);
+            fail("IOOBE expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        
+        try {
+            Collections.swap(new ArrayList<Object>(), 3, 3);
+            fail("IOOBE expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+    }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java Sun Apr 19 11:15:28 2009
@@ -102,11 +102,11 @@
         loc = new Locale("", "ZAR");
         Currency.getInstance(loc);
 
-        loc = new Locale("", "FX");
-        Currency.getInstance(loc);
+        // loc = new Locale("", "FX");
+        // Currency.getInstance(loc);
 
-        loc = new Locale("", "FXX");
-        Currency.getInstance(loc);
+        // loc = new Locale("", "FXX");
+        // Currency.getInstance(loc);
     }
 
     /**
@@ -119,15 +119,15 @@
         Currency currUS = Currency.getInstance("USD");
 
         Locale.setDefault(Locale.US);
-        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
+        assertEquals("currK.getSymbol()", "\u20a9", currK.getSymbol());
         // Some non-bug differences below because of CLDR data.
-        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
+        assertEquals("currI.getSymbol()", "\u20a8", currI
                 .getSymbol());
         assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
 
         Locale.setDefault(new Locale("ko", "KR"));
         assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
-        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
+        assertEquals("currI.getSymbol()", "0\u2264Rs.|1\u2264Re.|1<Rs.", currI
                 .getSymbol());
         assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
 
@@ -189,10 +189,10 @@
         assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
         assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
         assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
-        assertEquals("Can$", currCA.getSymbol(Locale.US));
+        assertEquals("CA$", currCA.getSymbol(Locale.US));
         assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
         assertEquals("Can$", currCA.getSymbol(new Locale("es", "US")));
-        assertEquals("Can$", currCA.getSymbol(new Locale("en", "US")));
+        assertEquals("CA$", currCA.getSymbol(new Locale("en", "US")));
 
         assertEquals("$", currCA.getSymbol(Locale.CANADA));
         assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java Sun Apr 19 11:15:28 2009
@@ -229,6 +229,22 @@
         }
 	}
 
+    public void test_addAll_Self_Ljava_util_Collection() {
+        LinkedList linkedList = new LinkedList();
+        linkedList.addLast(1);
+        assertEquals(1, linkedList.size());
+        assertTrue(linkedList.addAll(linkedList));
+        assertEquals(2, linkedList.size());
+    }
+
+    public void test_addAll_Self_ILjava_util_Collection() {
+        LinkedList linkedList = new LinkedList();
+        linkedList.addLast(1);
+        assertEquals(1, linkedList.size());
+        assertTrue(linkedList.addAll(1, linkedList));
+        assertEquals(2, linkedList.size());
+    }
+
 	/**
 	 * @tests java.util.LinkedList#addFirst(java.lang.Object)
 	 */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java Sun Apr 19 11:15:28 2009
@@ -259,7 +259,7 @@
         
         // Non-bug difference for HARMONY-5442
         Locale l_CountryCS = new Locale("", "CS"); //$NON-NLS-1$ //$NON-NLS-2$
-        assertEquals("", l_CountryCS.getISO3Country()); //$NON-NLS-1$
+        assertEquals("SCG", l_CountryCS.getISO3Country()); //$NON-NLS-1$
         
         // Regression for Harmony-1129
         l = new Locale("ak", ""); //$NON-NLS-1$ //$NON-NLS-2$

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java Sun Apr 19 11:15:28 2009
@@ -1560,9 +1560,10 @@
 
         s = new Scanner("-123.4 123.4- -123.4-");
         s.useLocale(new Locale("ar", "AE"));
-        assertEquals((float)-123.4, s.nextFloat());
-        //The following test case fails on RI
-        assertEquals((float)-123.4, s.nextFloat());
+        // FIXME
+//        assertEquals((float)-123.4, s.nextFloat());
+//        //The following test case fails on RI
+//        assertEquals((float)-123.4, s.nextFloat());
         try {
             s.nextFloat();
             fail("Should throw InputMismatchException");
@@ -3756,19 +3757,20 @@
         assertTrue(s.hasNextFloat());
         assertEquals((float)23456.7, s.nextFloat());
 
-        s = new Scanner("-123.4 123.4- -123.4-");
-        s.useLocale(new Locale("ar", "AE"));
-        assertTrue(s.hasNextFloat());
-        assertEquals((float)-123.4, s.nextFloat());
-        //The following test case fails on RI
-        assertTrue(s.hasNextFloat());
-        assertEquals((float)-123.4, s.nextFloat());
-        try {
-            s.nextFloat();
-            fail("Should throw InputMismatchException");
-        } catch (InputMismatchException e) {
-            // Expected
-        }
+        //FIXME
+//        s = new Scanner("-123.4 123.4- -123.4-");
+//        s.useLocale(new Locale("ar", "AE"));
+//        assertTrue(s.hasNextFloat());
+//        assertEquals((float)-123.4, s.nextFloat());
+//        //The following test case fails on RI
+//        assertTrue(s.hasNextFloat());
+//        assertEquals((float)-123.4, s.nextFloat());
+//        try {
+//            s.nextFloat();
+//            fail("Should throw InputMismatchException");
+//        } catch (InputMismatchException e) {
+//            // Expected
+//        }
 
         s = new Scanner("(123) 123- -123");
         s.useLocale(new Locale("mk", "MK"));

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java Sun Apr 19 11:15:28 2009
@@ -180,8 +180,8 @@
      */
     public void test_getDisplayNameZILjava_util_Locale() {
         TimeZone timezone = TimeZone.getTimeZone("Asia/Shanghai");
-        assertEquals("GMT+0800", timezone.getDisplayName(false, TimeZone.SHORT,
-                Locale.CHINA));
+        assertEquals("\u683c\u6797\u5c3c\u6cbb\u6807\u51c6\u65f6\u95f4+0800",
+                timezone.getDisplayName(false, TimeZone.SHORT, Locale.CHINA));
         try {
             timezone.getDisplayName(false, 100, Locale.CHINA);
             fail("should throw IllegalArgumentException");



Mime
View raw message