OSDN Git Service

auto import from //branches/cupcake/...@137873
authorThe Android Open Source Project <initial-contribution@android.com>
Wed, 11 Mar 2009 19:11:54 +0000 (12:11 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Wed, 11 Mar 2009 19:11:54 +0000 (12:11 -0700)
65 files changed:
libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java
libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java
libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
libcore/icu/src/main/java/com/ibm/icu4jni/math/BigDecimal.java [deleted file]
libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
libcore/luni/src/main/java/java/util/ComparableTimSort.java
libcore/luni/src/main/java/java/util/TimSort.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/EnumTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
libcore/luni/src/test/java/tests/api/java/io/AllTests.java
libcore/luni/src/test/java/tests/api/java/io/FileTest.java
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest.java
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest0.java [new file with mode: 0644]
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest1.java
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest2.java
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest3.java
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest4.java
libcore/luni/src/test/java/tests/api/java/lang/ProcessManagerTest.java
libcore/luni/src/test/java/tests/api/java/net/CookieHandlerTest.java
libcore/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java
libcore/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
libcore/luni/src/test/java/tests/api/java/net/ResponseCacheTest.java
libcore/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java
libcore/luni/src/test/java/tests/api/java/util/CurrencyTest.java
libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
libcore/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
libcore/luni/src/test/java/tests/api/java/util/PropertiesTest.java
libcore/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java
libcore/luni/src/test/java/tests/api/java/util/TimeZoneTest.java
libcore/luni/src/test/resources/tests/api/java/net/file1.cache [new file with mode: 0644]
libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalArithmeticTest.java
libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalCompareTest.java
libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalConstructorsTest.java
libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalScaleOperationsTest.java
libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_GB2312.java
libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_ISO_2022_JP.java
libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_x_windows_950.java
libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java
libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
libcore/sql/src/test/java/tests/SQLite/StmtTest.java
libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
libcore/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
libcore/support/src/test/java/tests/support/Support_SimpleDateFormat.java
libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java
libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h

index 1a8c753..64e0e1a 100644 (file)
@@ -180,7 +180,6 @@ public class JarInputStreamTest extends junit.framework.TestCase {
         args = {}
     )
     @KnownFailure("IOException not thrown when using getNextJarEntry() after close().")
-    // This is the original test_getNextJarEntry including the failing section.
     public void test_getNextJarEntry_Ex() throws Exception {
         final Set<String> desired = new HashSet<String>(Arrays
                 .asList(new String[] {
index 355fd27..0d72108 100644 (file)
@@ -25,6 +25,8 @@ import junit.framework.TestCase;
 
 import tests.support.resource.Support_Resources;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -128,9 +130,7 @@ public class Pack200PackerTest extends TestCase {
         assertTrue(packFile2.length()>packFile3.length());
     }
     
-/*
- * java.beans.* not implemented yet on android platform
- *     class MyPCL implements PropertyChangeListener {
+    class MyPCL implements PropertyChangeListener {
         boolean flag = false;
         
         public boolean isCalled() {
@@ -141,15 +141,14 @@ public class Pack200PackerTest extends TestCase {
             flag = true;
         }
     }
-@TestInfo(
-      level = TestLevel.COMPLETE,
-      
-      targets = {
-        @TestTarget(
-          methodName = "addPropertyChangeListener",
-          methodArgs = {java.beans.PropertyChangeListener.class}
-        )
-    })
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        notes = "",
+        method = "addPropertyChangeListener",
+        args = {java.beans.PropertyChangeListener.class}
+    )
+    @KnownFailure("No Implementation in Android!")
     public void testAddPropertyChangeListener() {
         MyPCL pcl = new MyPCL();
         packer.addPropertyChangeListener(pcl);
@@ -158,15 +157,13 @@ public class Pack200PackerTest extends TestCase {
         assertTrue(pcl.isCalled());
     }
 
-@TestInfo(
-      level = TestLevel.COMPLETE,
-      
-      targets = {
-        @TestTarget(
-          methodName = "removePropertyChangeListener",
-          methodArgs = {java.beans.PropertyChangeListener.class}
-        )
-    })
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        notes = "",
+        method = "removePropertyChangeListener",
+        args = {java.beans.PropertyChangeListener.class}
+    )
+    @KnownFailure("No Implementation in Android!")
     public void testRemovePropertyChangeListener() {
         MyPCL pcl = new MyPCL();
         packer.addPropertyChangeListener(pcl);
@@ -175,7 +172,7 @@ public class Pack200PackerTest extends TestCase {
         properties.put(Packer.EFFORT, "7");
         assertFalse(pcl.isCalled());
     }
-*/
+
     @Override
     protected void setUp() {
         packer = Pack200.newPacker();
index 4d5ede3..c1f9813 100644 (file)
@@ -25,6 +25,8 @@ import junit.framework.TestCase;
 
 import tests.support.resource.Support_Resources;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -176,9 +178,8 @@ public class Pack200UnpackerTest extends TestCase {
         assertEquals(jarEntries, new JarFile(jarFile2).size());
         assertEquals(jarEntries, new JarFile(jarFile3).size());
     }
-/*
- * java.beans.* not implemented yet on android platform
- *    class MyPCL implements PropertyChangeListener {
+
+    class MyPCL implements PropertyChangeListener {
         boolean flag = false;
         
         public boolean isCalled() {
@@ -190,15 +191,13 @@ public class Pack200UnpackerTest extends TestCase {
         }
     }
 
-@TestInfo(
-      level = TestLevel.COMPLETE,
-      
-      targets = {
-        @TestTarget(
-          methodName = "addPropertyChangeListener",
-          methodArgs = {java.beans.PropertyChangeListener.class}
-        )
-    })
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        notes = "",
+        method = "addPropertyChangeListener",
+        args = {java.beans.PropertyChangeListener.class}
+    )
+    @KnownFailure("No Implementation in Android!")
     public void testAddPropertyChangeListener() {
         MyPCL pcl = new MyPCL();
         unpacker.addPropertyChangeListener(pcl);
@@ -207,15 +206,13 @@ public class Pack200UnpackerTest extends TestCase {
         assertTrue(pcl.isCalled());
     }
 
-@TestInfo(
-      level = TestLevel.COMPLETE,
-      
-      targets = {
-        @TestTarget(
-          methodName = "removePropertyChangeListener",
-          methodArgs = {java.beans.PropertyChangeListener.class}
-        )
-    })
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        notes = "",
+        method = "removePropertyChangeListener",
+        args = {java.beans.PropertyChangeListener.class}
+    )
+    @KnownFailure("No Implementation in Android!")
     public void testRemovePropertyChangeListener() {
         MyPCL pcl = new MyPCL();
         unpacker.addPropertyChangeListener(pcl);
@@ -224,7 +221,7 @@ public class Pack200UnpackerTest extends TestCase {
         properties.put(Unpacker.PROGRESS, "7");
         assertFalse(pcl.isCalled());
     }
-*/
+
     @Override
     protected void setUp() {
         unpacker = Pack200.newUnpacker();
index 2e91510..2de996e 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.archive.tests.java.util.zip;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -36,7 +35,6 @@ import java.io.InputStream;
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.Inflater;
 import java.util.zip.InflaterInputStream;
-import java.util.zip.ZipException;
 
 @TestTargetClass(InflaterInputStream.class)
 public class InflaterInputStreamTest extends TestCase {
index 3fe23a7..468a803 100644 (file)
@@ -17,8 +17,8 @@
 
 package org.apache.harmony.archive.tests.java.util.zip;
 
-import dalvik.annotation.AndroidOnly;
 import dalvik.annotation.KnownFailure;
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -28,6 +28,7 @@ import tests.support.resource.Support_Resources;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FilePermission;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -40,10 +41,9 @@ import java.util.zip.ZipFile;
 @TestTargetClass(ZipFile.class)
 public class ZipFileTest extends junit.framework.TestCase {
 
-    // BEGIN android-added
     public byte[] getAllBytesFromStream(InputStream is) throws IOException {
         ByteArrayOutputStream bs = new ByteArrayOutputStream();
-        byte[] buf = new byte[666];
+        byte[] buf = new byte[512];
         int iRead;
         int off;
         while (is.available() > 0) {
@@ -53,8 +53,6 @@ public class ZipFileTest extends junit.framework.TestCase {
         return bs.toByteArray();
     }
 
-    // END android-added
-
     // the file hyts_zipFile.zip in setup must be included as a resource
     private String tempFileName;
 
@@ -67,7 +65,10 @@ public class ZipFileTest extends junit.framework.TestCase {
 
 
         public void checkPermission(Permission perm) {
-            if (perm.getActions().equals(forbidenPermissionAction)) {
+            // only check if it's a FilePermission because Locale checks
+            // for a PropertyPermission with action"read" to get system props.
+            if (perm instanceof FilePermission 
+                    && perm.getActions().equals(forbidenPermissionAction)) {
                 throw new SecurityException();
             }
         }
@@ -327,7 +328,7 @@ public class ZipFileTest extends junit.framework.TestCase {
         method = "getEntry",
         args = {java.lang.String.class}
     )
-    @AndroidOnly("God knows why!")
+    @BrokenTest("Needs investigation. AndroidOnly?")
     public void test_getEntryLjava_lang_String_AndroidOnly() throws IOException {
         java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
         assertNotNull("Could not obtain ZipEntry", zentry);
@@ -349,7 +350,8 @@ public class ZipFileTest extends junit.framework.TestCase {
         method = "getEntry",
         args = {java.lang.String.class}
     )
-    @KnownFailure("Android does not throw IllegalStateException when using getEntry() after close().")
+    @KnownFailure("Android does not throw IllegalStateException when using "
+            + "getEntry() after close().")
     public void test_getEntryLjava_lang_String_Ex() throws IOException {
         java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
         assertNotNull("Could not obtain ZipEntry", zentry);
@@ -434,7 +436,8 @@ public class ZipFileTest extends junit.framework.TestCase {
         method = "size",
         args = {}
     )
-    @KnownFailure("IllegalStateException not thrown when using ZipFile.size() after close().")
+    @KnownFailure("IllegalStateException not thrown when using ZipFile.size() "
+            + "after close().")
     public void test_size() throws IOException {
         assertEquals(6, zfile.size());
         zfile.close();
@@ -453,7 +456,6 @@ public class ZipFileTest extends junit.framework.TestCase {
     @Override
     protected void setUp() {
         try {
-            // BEGIN android-changed
             // Create a local copy of the file since some tests want to alter
             // information.
             tempFileName = System.getProperty("java.io.tmpdir");
@@ -471,7 +473,6 @@ public class ZipFileTest extends junit.framework.TestCase {
             f.delete();
             InputStream is = Support_Resources.getStream("hyts_ZipFile.zip");
             FileOutputStream fos = new FileOutputStream(f);
-            // END android-changed
             byte[] rbuf = getAllBytesFromStream(is);
             fos.write(rbuf, 0, rbuf.length);
             is.close();
index bdab74a..ac332fa 100644 (file)
@@ -174,7 +174,8 @@ public class ZipInputStreamTest extends TestCase {
         method = "close",
         args = {}
     )
-    @KnownFailure("The behaviour is different from RI, but not neccessarily wrong.")
+    @KnownFailure("after an exception has been thrown wile reading a "
+            + "call to close also throws an exception.")
     public void test_closeAfterException() throws Exception {
         File resources = Support_Resources.createTempFolder();
         Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
@@ -192,7 +193,7 @@ public class ZipInputStreamTest extends TestCase {
             // expected
         }
 
-        zis1.close();  // Android throws exception here, but RI only when getNextEntry/read/skip are called.
+        zis1.close();
         try {
             zis1.getNextEntry();
             fail("IOException expected");
@@ -346,31 +347,31 @@ public class ZipInputStreamTest extends TestCase {
         method = "available",
         args = {}
     )
-    @KnownFailure("Needs investigation!!!")
     public void test_available() throws Exception {
 
         File resources = Support_Resources.createTempFolder();
-        Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
-        File fl = new File(resources, "Broken_manifest.jar");
+        Support_Resources.copyFile(resources, null, "hyts_ZipFile.zip");
+        File fl = new File(resources, "hyts_ZipFile.zip");
         FileInputStream fis = new FileInputStream(fl);
 
         ZipInputStream zis1 = new ZipInputStream(fis);
+        ZipEntry entry = zis1.getNextEntry();
+        assertNotNull("No entry in the archive.", entry);
+        long entrySize = entry.getSize();
+        assertTrue("Entry size was < 1", entrySize > 0);
         int i = 0;
-System.out.println(fl.length());
-        for (i = 0; i < fl.length(); i++) {
-//System.out.println(i);
+        for (i = 0; i < entrySize; i++) {
             zis1.skip(1);
-//System.out.println("Skipped 1");
-int avail = zis1.available();
-//System.out.println(avail);
-            if (zis1.available() == 0) break; // RI breaks at i = 0 already; Android loops till the end!
-//System.out.println("Looping...");
+            if (zis1.available() == 0) break;
         }
-        if (i == fl.length()) {
-            fail("ZipInputStream.available or ZipInputStream.skip does not working properly");
+        if (i != entrySize) {
+            fail("ZipInputStream.available or ZipInputStream.skip does not " +
+                    "working properly. Only skipped " + i +
+                    " bytes instead of " + entrySize);
         }
-        assertTrue(zis1.available() == 0);
         zis1.skip(1);
+        assertTrue(zis1.available() == 0);
+        zis1.closeEntry();
         assertFalse(zis.available() == 0);
         zis1.close();
         try {
diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/math/BigDecimal.java b/libcore/icu/src/main/java/com/ibm/icu4jni/math/BigDecimal.java
deleted file mode 100644 (file)
index 4460b19..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.ibm.icu4jni.math;
-
-public class BigDecimal extends Number {
-
-    @Override
-    public double doubleValue() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    @Override
-    public float floatValue() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    @Override
-    public int intValue() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    @Override
-    public long longValue() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-    
-    @Override
-    public String toString() {
-        return "";
-    }
-
-}
index 4e8e034..0702d51 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.harmony.logging.tests.java.util.logging;
 
 
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -30,6 +29,8 @@ import junit.framework.TestCase;
 import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
 import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
@@ -58,7 +59,7 @@ public class LogManagerTest extends TestCase {
 
     LogManager manager = LogManager.getLogManager();
 
-    //    MockPropertyChangeListener listener;
+        MockPropertyChangeListener listener;
 
     Properties props;
 
@@ -79,6 +80,7 @@ public class LogManagerTest extends TestCase {
     /*
      * @see TestCase#setUp()
      */
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         mockManager = new MockLogManager();
@@ -102,6 +104,7 @@ public class LogManagerTest extends TestCase {
     /*
      * @see TestCase#tearDown()
      */
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         handler = null;
@@ -163,7 +166,7 @@ public class LogManagerTest extends TestCase {
         Enumeration<String> enumar = mockManager.getLoggerNames();
         int i = 0;
         while (enumar.hasMoreElements()) {
-            String name = (String)enumar.nextElement();
+            String name = enumar.nextElement();
             i++;
             assertEquals(FOO, name);
         }
@@ -381,7 +384,7 @@ public class LogManagerTest extends TestCase {
             args = {java.lang.String.class}
         )
     })
-    public void testAddGetLogger_addRoot() throws IOException {
+    public void testAddGetLogger_addRoot() {
         Logger foo = new MockLogger(FOO, null);
         Logger fooChild = new MockLogger(FOO + ".child", null);
         Logger other = new MockLogger("other", null);
@@ -524,7 +527,7 @@ public class LogManagerTest extends TestCase {
         Enumeration<String> enumar = mockManager.getLoggerNames();
         int i = 0;
         while (enumar.hasMoreElements()) {
-            String name = (String)enumar.nextElement();
+            String name = enumar.nextElement();
             i++;
             assertEquals("name logger should be equal to foreseen name", FOO, name);
         }
@@ -680,6 +683,12 @@ public class LogManagerTest extends TestCase {
             notes = "Verifies SecurityException.",
             method = "getLogManager",
             args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL_COMPLETE,
+            notes = "Verifies SecurityException.",
+            method = "addPropertyChangeListener",
+            args = {java.beans.PropertyChangeListener.class}
         )
     })
     public void testLoggingPermission() throws IOException {
@@ -709,22 +718,22 @@ public class LogManagerTest extends TestCase {
             fail("should throw SecurityException");
         } catch (SecurityException e) {
         }
-        //        try {
-        //            mockManager
-        //                    .addPropertyChangeListener(new MockPropertyChangeListener());
-        //            fail("should throw SecurityException");
-        //        } catch (SecurityException e) {
-        //        }
-        //        try {
-        //            mockManager.addPropertyChangeListener(null);
-        //            fail("should throw NPE");
-        //        } catch (NullPointerException e) {
-        //        }
-        //        try {
-        //            mockManager.removePropertyChangeListener(null);
-        //            fail("should throw SecurityException");
-        //        } catch (SecurityException e) {
-        //        }
+        try {
+            mockManager
+                    .addPropertyChangeListener(new MockPropertyChangeListener());
+            fail("should throw SecurityException");
+        } catch (SecurityException e) {
+        }
+        try {
+            mockManager.addPropertyChangeListener(null);
+            fail("should throw NPE");
+        } catch (NullPointerException e) {
+        }
+        try {
+            mockManager.removePropertyChangeListener(null);
+            fail("should throw SecurityException");
+        } catch (SecurityException e) {
+        }
         try {
             mockManager.reset();
             fail("should throw SecurityException");
@@ -963,61 +972,89 @@ public class LogManagerTest extends TestCase {
         manager.reset();
     }
 
-    //    public void testAddRemovePropertyChangeListener() throws Exception {
-    //        MockPropertyChangeListener listener1 = new MockPropertyChangeListener();
-    //        MockPropertyChangeListener listener2 = new MockPropertyChangeListener();
-    //        // add same listener1 two times
-    //        mockManager.addPropertyChangeListener(listener1);
-    //        mockManager.addPropertyChangeListener(listener1);
-    //        mockManager.addPropertyChangeListener(listener2);
-    //
-    //        assertNull(listener1.getEvent());
-    //        assertNull(listener2.getEvent());
-    //        mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props));
-    //        // if (!hasConfigClass) {
-    //        assertNotNull(listener1.getEvent());
-    //        assertNotNull(listener2.getEvent());
-    //        // }
-    //
-    //        listener1.reset();
-    //        listener2.reset();
-    //
-    //        // remove listener1, no effect
-    //        mockManager.removePropertyChangeListener(listener1);
-    //        mockManager.readConfiguration(EnvironmentHelper
-    //                .PropertiesToInputStream(props));
-    //        assertNotNull(listener1.getEvent());
-    //        assertNotNull(listener2.getEvent());
-    //        listener1.reset();
-    //        listener2.reset();
-    //
-    //        // remove listener1 again and it works
-    //        mockManager.removePropertyChangeListener(listener1);
-    //        mockManager.readConfiguration(EnvironmentHelper
-    //                .PropertiesToInputStream(props));
-    //        assertNull(listener1.getEvent());
-    //        assertNotNull(listener2.getEvent());
-    //        listener2.reset();
-    //
-    //        // reset don't produce event
-    //        mockManager.reset();
-    //        assertNull(listener2.getEvent());
-    //
-    //        mockManager.removePropertyChangeListener(listener2);
-    //        mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props));
-    //        assertNull(listener1.getEvent());
-    //        assertNull(listener2.getEvent());
-    //    }
-    //
-    //    public void testAddRemovePropertyChangeListener_null() {
-    //        // seems nothing happened
-    //        try{
-    //            mockManager.addPropertyChangeListener(null);
-    //            fail("Should throw NPE");
-    //        }catch(NullPointerException e){
-    //        }
-    //        mockManager.removePropertyChangeListener(null);
-    //    }
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.PARTIAL_COMPLETE,
+            notes = "",
+            method = "addPropertyChangeListener",
+            args = {java.beans.PropertyChangeListener.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL_COMPLETE,
+            notes = "",
+            method = "removePropertyChangeListener",
+            args = {java.beans.PropertyChangeListener.class}
+        )
+    })
+    public void testAddRemovePropertyChangeListener() throws Exception {
+        MockPropertyChangeListener listener1 = new MockPropertyChangeListener();
+        MockPropertyChangeListener listener2 = new MockPropertyChangeListener();
+        // add same listener1 two times
+        mockManager.addPropertyChangeListener(listener1);
+        mockManager.addPropertyChangeListener(listener1);
+        mockManager.addPropertyChangeListener(listener2);
+
+        assertNull(listener1.getEvent());
+        assertNull(listener2.getEvent());
+        mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props));
+        // if (!hasConfigClass) {
+        assertNotNull(listener1.getEvent());
+        assertNotNull(listener2.getEvent());
+        // }
+
+        listener1.reset();
+        listener2.reset();
+
+        // remove listener1, no effect
+        mockManager.removePropertyChangeListener(listener1);
+        mockManager.readConfiguration(EnvironmentHelper
+                .PropertiesToInputStream(props));
+        assertNotNull(listener1.getEvent());
+        assertNotNull(listener2.getEvent());
+        listener1.reset();
+        listener2.reset();
+
+        // remove listener1 again and it works
+        mockManager.removePropertyChangeListener(listener1);
+        mockManager.readConfiguration(EnvironmentHelper
+                .PropertiesToInputStream(props));
+        assertNull(listener1.getEvent());
+        assertNotNull(listener2.getEvent());
+        listener2.reset();
+
+        // reset don't produce event
+        mockManager.reset();
+        assertNull(listener2.getEvent());
+
+        mockManager.removePropertyChangeListener(listener2);
+        mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props));
+        assertNull(listener1.getEvent());
+        assertNull(listener2.getEvent());
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.PARTIAL_COMPLETE,
+            notes = "",
+            method = "addPropertyChangeListener",
+            args = {java.beans.PropertyChangeListener.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL_COMPLETE,
+            notes = "",
+            method = "removePropertyChangeListener",
+            args = {java.beans.PropertyChangeListener.class}
+        )
+    })
+    public void testAddRemovePropertyChangeListener_null() {
+        // seems nothing happened
+        try{
+            mockManager.addPropertyChangeListener(null);
+            fail("Should throw NPE");
+        }catch(NullPointerException e){
+        }
+        mockManager.removePropertyChangeListener(null);
+    }
 
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
@@ -1410,24 +1447,24 @@ public class LogManagerTest extends TestCase {
         }
     }
 
-    //    public static class MockPropertyChangeListener implements
-    //            IPropertyChangeListener {
-    //
-    //        IPropertyChangeEvent event = null;
-    //
-    //        public void propertyChange(IPropertyChangeEvent event) {
-    //            this.event = event;
-    //        }
-    //
-    //        public IPropertyChangeEvent getEvent() {
-    //            return event;
-    //        }
-    //
-    //        public void reset() {
-    //            event = null;
-    //        }
-    //
-    //    }
+    public static class MockPropertyChangeListener implements
+            PropertyChangeListener {
+
+        PropertyChangeEvent event = null;
+
+        public void propertyChange(PropertyChangeEvent event) {
+            this.event = event;
+        }
+
+        public PropertyChangeEvent getEvent() {
+            return event;
+        }
+
+        public void reset() {
+            event = null;
+        }
+
+    }
 
     public static class MockSecurityManagerLogPermission extends SecurityManager {
 
index 4ec01ed..ca288dd 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.logging.tests.java.util.logging;
 
-import dalvik.annotation.AndroidOnly;
 import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargets;
index b9f7145..882add1 100644 (file)
@@ -105,7 +105,7 @@ class ComparableTimSort {
      *
      * @param a the array to be sorted
      */
-  private ComparableTimSort(Object[] a) {
+    private ComparableTimSort(Object[] a) {
         this.a = a;
 
         // Allocate temp storage (which may be increased later if necessary)
@@ -675,7 +675,7 @@ class ComparableTimSort {
                     dest += count1;
                     cursor1 += count1;
                     len1 -= count1;
-                    if (len1 == 1)
+                    if (len1 <= 1)  // len1 == 1 || len1 == 0
                         break outer;
                 }
                 a[dest++] = a[cursor2++];
@@ -706,6 +706,9 @@ class ComparableTimSort {
             if (DEBUG) assert len2 > 0;
             System.arraycopy(a, cursor2, a, dest, len2);
             a[dest + len2] = tmp[cursor1]; //  Last elt of run 1 to end of merge
+        } else if (len1 == 0) {
+            throw new IllegalArgumentException(
+                "Comparison method violates its general contract!");
         } else {
             if (DEBUG) assert len2 == 0;
             if (DEBUG) assert len1 > 1;
@@ -804,8 +807,8 @@ class ComparableTimSort {
                     cursor2 -= count2;
                     len2 -= count2;
                     System.arraycopy(tmp, cursor2 + 1, a, dest + 1, count2);
-                    if (len2 == 1)
-                        break outer;
+                    if (len2 <= 1)
+                        break outer; // len2 == 1 || len2 == 0
                 }
                 a[dest--] = a[cursor1--];
                 if (--len1 == 0)
@@ -824,6 +827,9 @@ class ComparableTimSort {
             cursor1 -= len1;
             System.arraycopy(a, cursor1 + 1, a, dest + 1, len1);
             a[dest] = tmp[cursor2];  // Move first elt of run2 to front of merge
+        } else if (len2 == 0) {
+            throw new IllegalArgumentException(
+                "Comparison method violates its general contract!");
         } else {
             if (DEBUG) assert len1 == 0;
             if (DEBUG) assert len2 > 0;
index 3c73a2c..9c27ddc 100644 (file)
@@ -708,7 +708,7 @@ class TimSort<T> {
                     dest += count1;
                     cursor1 += count1;
                     len1 -= count1;
-                    if (len1 == 1)
+                    if (len1 <= 1) // len1 == 1 || len1 == 0
                         break outer;
                 }
                 a[dest++] = a[cursor2++];
@@ -739,6 +739,9 @@ class TimSort<T> {
             if (DEBUG) assert len2 > 0;
             System.arraycopy(a, cursor2, a, dest, len2);
             a[dest + len2] = tmp[cursor1]; //  Last elt of run 1 to end of merge
+        } else if (len1 == 0) {
+            throw new IllegalArgumentException(
+                "Comparison method violates its general contract!");
         } else {
             if (DEBUG) assert len2 == 0;
             if (DEBUG) assert len1 > 1;
@@ -837,7 +840,7 @@ class TimSort<T> {
                     cursor2 -= count2;
                     len2 -= count2;
                     System.arraycopy(tmp, cursor2 + 1, a, dest + 1, count2);
-                    if (len2 == 1)
+                    if (len2 <= 1)  // len2 == 1 || len2 == 0
                         break outer;
                 }
                 a[dest--] = a[cursor1--];
@@ -857,6 +860,9 @@ class TimSort<T> {
             cursor1 -= len1;
             System.arraycopy(a, cursor1 + 1, a, dest + 1, len1);
             a[dest] = tmp[cursor2];  // Move first elt of run2 to front of merge
+        } else if (len2 == 0) {
+            throw new IllegalArgumentException(
+                "Comparison method violates its general contract!");
         } else {
             if (DEBUG) assert len1 == 0;
             if (DEBUG) assert len2 > 0;
index fd68f66..9d9a086 100644 (file)
@@ -124,9 +124,8 @@ public class ClassLoaderTest extends TestCase {
         method = "clearAssertionStatus",
         args = {}
     )
-    @AndroidOnly("clearAssertionStatus method is not supported.")
-    @BrokenTest("Android doesn't support assertions to be activated through " +
-            "the api")
+    @KnownFailure("Android doesn't support assertions to be activated " +
+            "through the api")
     public void test_clearAssertionStatus() {
         String className = getClass().getPackage().getName() + ".TestAssertions";
         String className1 = getClass().getPackage().getName() + ".TestAssertions1";
@@ -805,9 +804,9 @@ public class ClassLoaderTest extends TestCase {
         method = "getPackages",
         args = {}
     )
-    @KnownFailure("The package canot be found. Seems like the cache is not"
-            + "shared between the class loaders. But this test seems to"
-            "expect exactly that. this tests works on the RI.")
+    @KnownFailure("The package canot be found. Seems like the cache is not " +
+            "shared between the class loaders. But this test seems to " +
+            "expect exactly that. this tests works on the RI.")
     public void test_getPackages() {
         
         PackageClassLoader pcl = new PackageClassLoader();
index ccaddeb..94b495f 100644 (file)
@@ -275,10 +275,10 @@ public class EnumTest extends TestCase {
         method = "!SerializationGolden",
         args = {}
     )
-    public void _test_compatibilitySerialization_inClass_Complex_Harmony() throws Exception{
+    public void test_compatibilitySerialization_inClass_Complex_Harmony() throws Exception{
         // TODO migrate to the new testing framework 
         assertTrue(SerializationTester.assertCompabilityEquals(new MockEnum2(),
-            "serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.harmony.ser"));
+            "/serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.harmony.ser"));
     }
     
     /**
index 4d5f04d..02bed3c 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.apache.harmony.luni.tests.java.lang;
 
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
@@ -796,9 +794,6 @@ public class MathTest extends junit.framework.TestCase {
         method = "pow",
         args = {double.class, double.class}
     )
-    @KnownFailure("Math.pow(double a, double b) returns 1.0 if " +
-            "the absolute value of the first argument equals 1 and " +
-            "the second argument is infinite. It should return NaN.")         
     public void test_powDD() {
         // Test for method double java.lang.Math.pow(double, double)
         assertTrue("pow returned incorrect value",
@@ -825,9 +820,9 @@ public class MathTest extends junit.framework.TestCase {
                                        Math.pow(0.9, Double.POSITIVE_INFINITY));   
         
         assertEquals("pow returned incorrect value", Double.NaN, 
-                                         Math.pow(1.0, Double.NEGATIVE_INFINITY));
+                                       Math.pow(1.0, Double.NEGATIVE_INFINITY));
         assertEquals("pow returned incorrect value", Double.NaN, 
-                                         Math.pow(1.0, Double.POSITIVE_INFINITY)); 
+                                       Math.pow(1.0, Double.POSITIVE_INFINITY)); 
 
         assertEquals("pow returned incorrect value", 0.0, Math.pow(0, 1));
         assertEquals("pow returned incorrect value", 0.0, 
index e38ee63..b1b7408 100644 (file)
@@ -259,7 +259,7 @@ public class PackageTest extends junit.framework.TestCase {
         method = "getPackage",
         args = {java.lang.String.class}
     )
-    @KnownFailure("Package information missing on android")
+    @KnownFailure("Real package information missing on android.")
     public void test_getPackageLjava_lang_String() throws Exception {
         assertSame("Package getPackage failed for java.lang", Package
                 .getPackage("java.lang"), Package.getPackage("java.lang"));
@@ -302,7 +302,6 @@ public class PackageTest extends junit.framework.TestCase {
         method = "hashCode",
         args = {}
     )
-    @KnownFailure("Package information missing on android")
     public void test_hashCode() {
         Package p1 = Package.getPackage("java.lang");
         if (p1 != null) {
index 30510c2..4ad0c52 100644 (file)
@@ -705,7 +705,7 @@ public class StringTest extends TestCase {
         level = TestLevel.ADDITIONAL,
         notes = "Regression test for some existing bugs and crashes",
         method = "format",
-        args = { String.class, Object.class }
+        args = { String.class, Object[].class }
     )
     public void testProblemCases() {
         BigDecimal[] input = new BigDecimal[] {
index 7e8030a..39bc92d 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.apache.harmony.luni.tests.java.lang;
 
-import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
@@ -999,7 +998,7 @@ public class ThreadGroupTest extends junit.framework.TestCase implements Thread.
         args = {}
     )
    @SuppressWarnings("deprecation")
-   @AndroidOnly("Thread.resume is implemented on some RI")
+   @BrokenTest("Thread.resume is implemented on some RI")
     public void test_resume() throws OutOfMemoryError {
         // Test for method void java.lang.ThreadGroup.resume()
         final ThreadGroup originalCurrent = getInitialThreadGroup();
@@ -1236,7 +1235,7 @@ public class ThreadGroupTest extends junit.framework.TestCase implements Thread.
         method = "stop",
         args = {}
     )
-    @AndroidOnly("stop() method not implemented. throws UnsupportedOperationException.")
+    @BrokenTest("stop() method not implemented.")
     @SuppressWarnings("deprecation")
     public void test_stop() throws OutOfMemoryError {
         // Test for method void java.lang.ThreadGroup.stop()
@@ -1305,7 +1304,7 @@ public class ThreadGroupTest extends junit.framework.TestCase implements Thread.
         method = "suspend",
         args = {}
     )
-    @AndroidOnly("suspend() method not implemented. throws UnsupportedOperationException.")
+    @BrokenTest("suspend() method not implemented.")
     @SuppressWarnings("deprecation")
     public void test_suspend() throws OutOfMemoryError {
         // Test for method void java.lang.ThreadGroup.suspend()
index 29d26da..968a056 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
@@ -28,12 +27,10 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.CacheRequest;
 import java.net.CacheResponse;
-import java.net.DatagramSocket;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.ProtocolException;
 import java.net.ResponseCache;
-import java.net.SocketException;
 import java.net.SocketPermission;
 import java.net.URI;
 import java.net.URL;
@@ -592,7 +589,6 @@ public class HttpURLConnectionTest extends junit.framework.TestCase {
       method = "setUseCaches",
       args = {boolean.class}
     )
-    @KnownFailure("getInputStream doesn't call get method of cache")
     public void test_UseCache_HttpURLConnection_NonCached() throws IOException {
         ResponseCache.setDefault(new MockNonCachedResponseCache());
         uc = (HttpURLConnection) url.openConnection();
@@ -600,7 +596,6 @@ public class HttpURLConnectionTest extends junit.framework.TestCase {
         // default useCaches is true
         assertTrue(uc.getUseCaches());
         uc.setDoInput(true);
-        uc.connect();
 
         // make sure ResponseCache.get/put is called
         isGetCalled = false;
index 1b2aa22..498c486 100644 (file)
 package org.apache.harmony.luni.tests.java.net;
 
 import dalvik.annotation.TestTargetClass; 
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 
 import java.io.Serializable;
-import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
@@ -1173,23 +1171,57 @@ public class Inet6AddressTest extends junit.framework.TestCase {
         args = {}
     )
     public void test_getHostAddress() throws Exception {
-        InetAddress addr = Inet6Address.getByName("localhost");
-        assertEquals("127.0.0.1", addr.getHostAddress());
-        
-        addr = Inet6Address.getByName("127.0.0.1");
-        assertEquals("127.0.0.1", addr.getHostAddress());
-        
-        addr = Inet6Address.getByName("224.0.0.0");
-        assertEquals("224.0.0.0", addr.getHostAddress());
-        
-        addr = Inet6Address.getByName("1");
-        assertEquals("0.0.0.1", addr.getHostAddress());   
-        
-        addr = Inet6Address.getByName("1.1");
-        assertEquals("1.0.0.1", addr.getHostAddress());  
-        
-        addr = Inet6Address.getByName("1.1.1");
-        assertEquals("1.1.0.1", addr.getHostAddress());           
+        InetAddress aAddr = Inet6Address.getByName("localhost");
+        assertEquals("127.0.0.1", aAddr.getHostAddress());
+
+        aAddr = Inet6Address.getByName("127.0.0.1");
+        assertEquals("127.0.0.1", aAddr.getHostAddress());
+
+        aAddr = Inet6Address.getByName("224.0.0.0");
+        assertEquals("224.0.0.0", aAddr.getHostAddress());
+
+        aAddr = Inet6Address.getByName("1");
+        assertEquals("0.0.0.1", aAddr.getHostAddress());
+
+        aAddr = Inet6Address.getByName("1.1");
+        assertEquals("1.0.0.1", aAddr.getHostAddress());
+
+        aAddr = Inet6Address.getByName("1.1.1");
+        assertEquals("1.1.0.1", aAddr.getHostAddress());
+
+        byte[] bAddr = { (byte) 0xFE, (byte) 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x11,
+                0x25, (byte) 0xFF, (byte) 0xFE, (byte) 0xF8, (byte) 0x7C,
+                (byte) 0xB2 };
+        aAddr = Inet6Address.getByAddress(bAddr);
+        assertEquals("fe80:0:0:0:211:25ff:fef8:7cb2", aAddr.getHostAddress());
+
+        byte[] cAddr = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+        aAddr = Inet6Address.getByAddress(cAddr);
+        assertEquals("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", aAddr.getHostAddress());
+
+        byte[] dAddr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+        aAddr = Inet6Address.getByAddress(dAddr);
+        assertEquals("0:0:0:0:0:0:0:0", aAddr.getHostAddress());
+
+        byte[] eAddr = { (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
+                (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
+                (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b,
+                (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f};
+        aAddr = Inet6Address.getByAddress(eAddr);
+        assertEquals("1:203:405:607:809:a0b:c0d:e0f", aAddr.getHostAddress());
+
+        byte[] fAddr = { (byte) 0x00, (byte) 0x10, (byte) 0x20, (byte) 0x30,
+                (byte) 0x40, (byte) 0x50, (byte) 0x60, (byte) 0x70,
+                (byte) 0x80, (byte) 0x90, (byte) 0xa0, (byte) 0xb0,
+                (byte) 0xc0, (byte) 0xd0, (byte) 0xe0, (byte) 0xf0};
+        aAddr = Inet6Address.getByAddress(fAddr);
+        assertEquals("10:2030:4050:6070:8090:a0b0:c0d0:e0f0", aAddr.getHostAddress());
     }
     
     @TestTargetNew(
index 15f3a5a..b979628 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.apache.harmony.luni.tests.java.net;
 
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargetClass; 
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
@@ -323,7 +324,8 @@ public class InetSocketAddressTest extends TestCase {
         method = "!SerializationGolden",
         args = {}
     )
-    public void _testSerializationCompatibility() throws Exception {
+    @KnownFailure("Problem with deserialization of Localhost vs. localhost")
+    public void testSerializationCompatibility() throws Exception {
 
         Object[] testCases = {
                 InetSocketAddress.createUnresolved("badhost", 1000), // unresolved
index 295d4d8..2747ab2 100644 (file)
@@ -90,13 +90,11 @@ public class AllTests {
         suite.addTestSuite(RandomAccessFileTest.class);
         suite.addTestSuite(SequenceInputStreamTest.class);
         suite.addTestSuite(SerializablePermissionTest.class);
-        suite.addTestSuite(SerializationStressTest.class);
+        suite.addTestSuite(SerializationStressTest0.class);
         suite.addTestSuite(SerializationStressTest1.class);
         suite.addTestSuite(SerializationStressTest2.class);
         suite.addTestSuite(SerializationStressTest3.class);
         suite.addTestSuite(SerializationStressTest4.class);
-        suite.addTestSuite(SerializationStressTest4.class);
-        suite.addTestSuite(SerializationStressTest5.class);
         suite.addTestSuite(StreamCorruptedExceptionTest.class);
         suite.addTestSuite(StreamTokenizerTest.class);
         suite.addTestSuite(StringBufferInputStreamTest.class);
index 865717e..85c4bc4 100644 (file)
@@ -1097,8 +1097,9 @@ public class FileTest extends junit.framework.TestCase {
         args = {}
     )    
     public void test_getPath() {
-        System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
-        String base = System.getProperty("user.home");
+        String oldUserDir = System.getProperty("java.io.tmpdir");
+        System.setProperty("user.dir", System.getProperty("java.io.tmpdir"));
+        String base = System.getProperty("user.dir");
         String fname;
         File f1;
         if (!base.regionMatches((base.length() - 1), slash, 0, 1))
@@ -1122,6 +1123,7 @@ public class FileTest extends junit.framework.TestCase {
         f2.delete();
         f3.delete();
         f4.delete();
+        System.setProperty("user.dir", oldUserDir);
     }
 
     /**
@@ -2099,27 +2101,27 @@ public class FileTest extends junit.framework.TestCase {
             f1.createNewFile();
             long orgTime = f1.lastModified();
             // Subtracting 100 000 milliseconds from the orgTime of File f1
-            f1.setLastModified(orgTime - 100000);
+            assertTrue(f1.setLastModified(orgTime - 100000));
             long lastModified = f1.lastModified();
             assertTrue("Test 1: LastModifed time incorrect: " + lastModified,
                     lastModified == (orgTime - 100000));
             // Subtracting 10 000 000 milliseconds from the orgTime of File f1
-            f1.setLastModified(orgTime - 10000000);
+            assertTrue(f1.setLastModified(orgTime - 10000000));
             lastModified = f1.lastModified();
             assertTrue("Test 2: LastModifed time incorrect: " + lastModified,
                     lastModified == (orgTime - 10000000));
             // Adding 100 000 milliseconds to the orgTime of File f1
-            f1.setLastModified(orgTime + 100000);
+            assertTrue(f1.setLastModified(orgTime + 100000));
             lastModified = f1.lastModified();
             assertTrue("Test 3: LastModifed time incorrect: " + lastModified,
                     lastModified == (orgTime + 100000));
             // Adding 10 000 000 milliseconds from the orgTime of File f1
-            f1.setLastModified(orgTime + 10000000);
+            assertTrue(f1.setLastModified(orgTime + 10000000));
             lastModified = f1.lastModified();
             assertTrue("Test 4: LastModifed time incorrect: " + lastModified,
                     lastModified == (orgTime + 10000000));
             // Trying to set time to an exact number
-            f1.setLastModified(315550800000L);
+            assertTrue(f1.setLastModified(315550800000L));
             lastModified = f1.lastModified();
             assertTrue("Test 5: LastModified time incorrect: " + lastModified,
                     lastModified == 315550800000L);
@@ -2139,6 +2141,9 @@ public class FileTest extends junit.framework.TestCase {
                 fail("IllegalArgumentException not thrown.");
             } catch (IllegalArgumentException e) {
             }
+            
+            File f2 = new File("/does not exist.txt");
+            assertFalse(f2.setLastModified(42));
         } catch (IOException e) {
             fail("Unexpected IOException during test : " + e.getMessage());
         } finally {
index 7c4d0b1..45d92bd 100644 (file)
@@ -17,7 +17,7 @@
 
 package tests.api.java.io;
 
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass; 
@@ -95,29 +95,40 @@ public class SerializationStressTest extends junit.framework.TestCase implements
 
     protected transient ByteArrayOutputStream bao;
 
-    // -----------------------------------------------------------------------------------
+    protected void t_MixPrimitivesAndObjects() throws IOException,
+            ClassNotFoundException {
+        int i = 7;
+        String s1 = "string 1";
+        String s2 = "string 2";
+        byte[] bytes = { 1, 2, 3 };
 
-    private static class ObjectInputStreamSubclass extends ObjectInputStream {
-        private Vector resolvedClasses = new Vector();
+        oos.writeInt(i);
+        oos.writeObject(s1);
+        oos.writeUTF(s2);
+        oos.writeObject(bytes);
+        oos.close();
+        try {
+            ois = new ObjectInputStream(loadStream());
 
-        public ObjectInputStreamSubclass(InputStream in) throws IOException,
-                StreamCorruptedException {
-            super(in);
-        }
+            int j = ois.readInt();
+            assertTrue("Wrong int :" + j, i == j);
 
-        public Class resolveClass(ObjectStreamClass osClass)
-                throws IOException, ClassNotFoundException {
-            Class result = super.resolveClass(osClass);
-            resolvedClasses.addElement(result);
-            return result;
-        }
+            String l1 = (String) ois.readObject();
+            assertTrue("Wrong obj String :" + l1, s1.equals(l1));
+
+            String l2 = (String) ois.readUTF();
+            assertTrue("Wrong UTF String :" + l2, s2.equals(l2));
+
+            byte[] bytes2 = (byte[]) ois.readObject();
+            assertTrue("Wrong byte[]", Arrays.equals(bytes, bytes2));
 
-        public Class[] resolvedClasses() {
-            return (Class[]) resolvedClasses.toArray(new Class[resolvedClasses
-                    .size()]);
+        } finally {
+            ois.close();
         }
     }
 
+    // -----------------------------------------------------------------------------------
+
     static final Map TABLE = new Hashtable();
 
     static final Map MAP = new HashMap();
@@ -290,965 +301,5 @@ public class SerializationStressTest extends junit.framework.TestCase implements
         }
     }
 
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_1_Constructor() {
-        // Test for method java.io.ObjectOutputStream(java.io.OutputStream)
-
-        try {
-            oos.close();
-            oos = new ObjectOutputStream(new ByteArrayOutputStream());
-            oos.close();
-        } catch (Exception e) {
-            fail("Failed to create ObjectOutputStream : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_2_close() {
-        // Test for method void java.io.ObjectOutputStream.close()
-        try {
-            oos.close();
-            oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
-            oos.close();
-            oos.writeChar('T');
-            oos.writeObject(FOO);
-            // Writing to a closed stream does not cause problems. This is
-            // the expected behavior
-        } catch (IOException e) {
-            fail("Operation on closed stream threw IOException : "
-                    + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_3_defaultWriteObject() {
-        // Test for method void java.io.ObjectOutputStream.defaultWriteObject()
-
-        try {
-            oos.defaultWriteObject();
-        } catch (NotActiveException e) {
-            // Correct
-            return;
-        } catch (IOException e) {
-        }
-        fail(
-                "Failed to throw NotActiveException when invoked outside readObject");
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_4_flush() {
-        // Test for method void java.io.ObjectOutputStream.flush()
-        try {
-            oos.close();
-            oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
-            int size = bao.size();
-            oos.writeByte(127);
-            assertTrue("Data flushed already", bao.size() == size);
-            oos.flush();
-            assertTrue("Failed to flush data", bao.size() > size);
-            // we don't know how many bytes are actually written for 1 byte,
-            // so we test > <before>
-            oos.close();
-            oos = null;
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_5_reset() {
-        // Test for method void java.io.ObjectOutputStream.reset()
-        try {
-            String o = "HelloWorld";
-            oos.writeObject(o);
-            oos.writeObject(o);
-            oos.reset();
-            oos.writeObject(o);
-            ois = new ObjectInputStream(loadStream());
-            ois.close();
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_6_write() {
-        // Test for method void java.io.ObjectOutputStream.write(byte [], int,
-        // int)
-        try {
-            byte[] buf = new byte[255];
-            byte[] output = new byte[255];
-            for (int i = 0; i < output.length; i++)
-                output[i] = (byte) i;
-            oos.write(output, 0, output.length);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            ois.readFully(buf);
-            ois.close();
-            for (int i = 0; i < output.length; i++)
-                if (buf[i] != output[i])
-                    fail("Read incorrect byte: " + i);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_6a_write() {
-        // Test for method void java.io.ObjectOutputStream.write(byte [], int,
-        // int)
-        try {
-            byte[] buf = new byte[256];
-            byte[] output = new byte[256];
-            for (int i = 0; i < output.length; i++)
-                output[i] = (byte) (i & 0xff);
-            oos.write(output, 0, output.length);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            ois.readFully(buf);
-            ois.close();
-            for (int i = 0; i < output.length; i++)
-                if (buf[i] != output[i])
-                    fail("Read incorrect byte: " + i);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_7_write() {
-        // Test for method void java.io.ObjectOutputStream.write(int)
-        try {
-            byte[] buf = new byte[10];
-            oos.write('T');
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertEquals("Read incorrect byte", 'T', ois.read());
-            ois.close();
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_8_write() {
-        // Test for method void java.io.ObjectOutputStream.write(byte [])
-        try {
-            byte[] buf = new byte[10];
-            oos.write("HelloWorld".getBytes());
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            ois.read(buf, 0, 10);
-            ois.close();
-            assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10)
-                    );
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_9_writeBoolean() {
-        // Test for method void java.io.ObjectOutputStream.writeBoolean(boolean)
-        try {
-            oos.writeBoolean(true);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertTrue("Wrote incorrect byte value", ois.readBoolean());
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_10_writeByte() {
-        // Test for method void java.io.ObjectOutputStream.writeByte(int)
-        try {
-            oos.writeByte(127);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertEquals("Wrote incorrect byte value", 127, ois.readByte());
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_11_writeBytes() {
-        // Test for method void
-        // java.io.ObjectOutputStream.writeBytes(java.lang.String)
-        try {
-            byte[] buf = new byte[10];
-            oos.writeBytes("HelloWorld");
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            ois.readFully(buf);
-            ois.close();
-            assertEquals("Wrote incorrect bytes value", "HelloWorld", new String(buf, 0, 10)
-                    );
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_12_writeChar() {
-        // Test for method void java.io.ObjectOutputStream.writeChar(int)
-        try {
-            oos.writeChar('T');
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertEquals("Wrote incorrect char value", 'T', ois.readChar());
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_13_writeChars() {
-        // Test for method void
-        // java.io.ObjectOutputStream.writeChars(java.lang.String)
-        try {
-            int avail = 0;
-            char[] buf = new char[10];
-            oos.writeChars("HelloWorld");
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            // Number of prim data bytes in stream / 2 to give char index
-            avail = ois.available() / 2;
-            for (int i = 0; i < avail; ++i)
-                buf[i] = ois.readChar();
-            ois.close();
-            assertEquals("Wrote incorrect chars", "HelloWorld", new String(buf, 0, 10)
-                    );
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_14_writeDouble() {
-        // Test for method void java.io.ObjectOutputStream.writeDouble(double)
-        try {
-            oos.writeDouble(Double.MAX_VALUE);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertTrue("Wrote incorrect double value",
-                    ois.readDouble() == Double.MAX_VALUE);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_15_writeFloat() {
-        // Test for method void java.io.ObjectOutputStream.writeFloat(float)
-        try {
-            oos.writeFloat(Float.MAX_VALUE);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertTrue("Wrote incorrect double value",
-                    ois.readFloat() == Float.MAX_VALUE);
-            ois.close();
-            ois = null;
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_16_writeInt() {
-        // Test for method void java.io.ObjectOutputStream.writeInt(int)
-        try {
-            oos.writeInt(Integer.MAX_VALUE);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertTrue("Wrote incorrect double value",
-                    ois.readInt() == Integer.MAX_VALUE);
-            ois.close();
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_17_writeLong() {
-        // Test for method void java.io.ObjectOutputStream.writeLong(long)
-        try {
-            oos.writeLong(Long.MAX_VALUE);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertTrue("Wrote incorrect double value",
-                    ois.readLong() == Long.MAX_VALUE);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_19_writeShort() {
-        // Test for method void java.io.ObjectOutputStream.writeShort(int)
-        try {
-            oos.writeShort(127);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertEquals("Wrote incorrect short value", 127, ois.readShort());
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_20_writeUTF() {
-        // Test for method void
-        // java.io.ObjectOutputStream.writeUTF(java.lang.String)
-        try {
-            oos.writeUTF("HelloWorld");
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            assertEquals("Wrote incorrect UTF value", 
-                    "HelloWorld", ois.readUTF());
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_25_available() {
-        try {
-            oos.writeObject(FOO);
-            oos.writeObject(FOO);
-            oos.flush();
-            int available1 = 0;
-            int available2 = 0;
-            Object obj1 = null;
-            Object obj2 = null;
-            ObjectInputStream ois = new ObjectInputStream(loadStream());
-            available1 = ois.available();
-            obj1 = ois.readObject();
-            available2 = ois.available();
-            obj2 = ois.readObject();
-
-            assertEquals("available returned incorrect value", 0, available1);
-            assertEquals("available returned incorrect value", 0, available2);
-
-            assertTrue("available caused incorrect reading", FOO.equals(obj1));
-            assertTrue("available returned incorrect value", FOO.equals(obj2));
-
-        } catch (IOException e) {
-            fail("IOException serializing object : " + e.getMessage());
-        } catch (ClassNotFoundException e) {
-            fail("Unable to read Object type : " + e.toString());
-        } catch (Error err) {
-            System.out.println("Error " + err);
-            throw err;
-        }
 
-    }
-
-    protected void t_MixPrimitivesAndObjects() throws IOException,
-            ClassNotFoundException {
-        int i = 7;
-        String s1 = "string 1";
-        String s2 = "string 2";
-        byte[] bytes = { 1, 2, 3 };
-
-        oos.writeInt(i);
-        oos.writeObject(s1);
-        oos.writeUTF(s2);
-        oos.writeObject(bytes);
-        oos.close();
-        try {
-            ois = new ObjectInputStream(loadStream());
-
-            int j = ois.readInt();
-            assertTrue("Wrong int :" + j, i == j);
-
-            String l1 = (String) ois.readObject();
-            assertTrue("Wrong obj String :" + l1, s1.equals(l1));
-
-            String l2 = (String) ois.readUTF();
-            assertTrue("Wrong UTF String :" + l2, s2.equals(l2));
-
-            byte[] bytes2 = (byte[]) ois.readObject();
-            assertTrue("Wrong byte[]", Arrays.equals(bytes, bytes2));
-
-        } finally {
-            ois.close();
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_resolveClass() {
-        try {
-            oos.writeObject(new Object[] { Integer.class, new Integer(1) });
-            oos.close();
-
-            ois = new ObjectInputStreamSubclass(loadStream());
-            ois.readObject();
-            ois.close();
-        } catch (IOException e1) {
-            fail("IOException : " + e1.getMessage());
-        } catch (ClassNotFoundException e2) {
-            fail("ClassNotFoundException : " + e2.getMessage());
-        }
-
-        Class[] resolvedClasses = ((ObjectInputStreamSubclass) ois)
-                .resolvedClasses();
-        assertEquals("missing resolved", 3, resolvedClasses.length);
-        assertTrue("resolved class 1", resolvedClasses[0] == Object[].class);
-        assertTrue("resolved class 2", resolvedClasses[1] == Integer.class);
-        assertTrue("resolved class 3", resolvedClasses[2] == Number.class);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_reset() {
-        try {
-            oos.reset();
-            oos.writeObject("R");
-            oos.reset();
-            oos.writeByte(24);
-            oos.close();
-
-            DataInputStream dis = new DataInputStream(loadStream());
-            byte[] input = new byte[dis.available()];
-            dis.readFully(input);
-            byte[] result = new byte[] { (byte) 0xac, (byte) 0xed, (byte) 0,
-                    (byte) 5, (byte) 0x79, (byte) 0x74, (byte) 0, (byte) 1,
-                    (byte) 'R', (byte) 0x79, (byte) 0x77, (byte) 1, (byte) 24 };
-            assertTrue("incorrect output", Arrays.equals(input, result));
-
-            ois = new ObjectInputStreamSubclass(loadStream());
-            assertEquals("Wrong result from readObject()", "R", ois.readObject()
-                    );
-            assertEquals("Wrong result from readByte()", 24, ois.readByte());
-            ois.close();
-        } catch (IOException e1) {
-            fail("IOException : " + e1.getMessage());
-        } catch (ClassNotFoundException e2) {
-            fail("ClassNotFoundException : " + e2.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_serialVersionUID(Class clazz, long svUID) {
-        final String idWrong = "serialVersionUID is wrong for: ";
-        long reflectedSvUID = 0L;
-        try {
-            reflectedSvUID = clazz.getField("serialVersionUID").getLong(null);
-        } catch (Exception e) {
-            fail("Unable to determine serialVersionUID of " + clazz);
-        }
-        assertTrue(idWrong + clazz + ": " + reflectedSvUID + " does not equal "
-                + svUID, reflectedSvUID == svUID);
-    }
-
-    private static class ResolveObjectTest implements Serializable {
-        Object field1, field2;
-    }
-
-    private static class ResolveObjectInputStream extends ObjectInputStream {
-        ResolveObjectInputStream(InputStream in)
-                throws StreamCorruptedException, IOException {
-            super(in);
-        }
-
-        public void enableResolve() {
-            enableResolveObject(true);
-        }
-
-        public Object resolveObject(Object obj) {
-            if (obj instanceof Vector) // test_1_resolveObject()
-                return new Hashtable();
-            else if ("abc".equals(obj)) // test_2_resolveObject()
-                return "ABC";
-            else if (obj instanceof String) // test_3_resolveObject()
-                return String.valueOf(((String) obj).length());
-            else if (obj instanceof int[]) // test_4_resolveObject()
-                return new Object[1];
-            else if (obj instanceof Object[] && ((Object[]) obj).length == 2) // test_5_resolveObject()
-                return new char[1];
-            return obj;
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_1_resolveObject() {
-        try {
-            ResolveObjectTest obj = new ResolveObjectTest();
-            obj.field1 = new Vector();
-            obj.field2 = obj.field1;
-            oos.writeObject(obj);
-            oos.close();
-            ois = new ResolveObjectInputStream(loadStream());
-            ((ResolveObjectInputStream) ois).enableResolve();
-            ResolveObjectTest result = null;
-            try {
-                result = (ResolveObjectTest) ois.readObject();
-            } catch (ClassNotFoundException e) {
-                fail(e.toString());
-            }
-            assertTrue("Object not resolved",
-                    result.field1 instanceof Hashtable);
-            assertTrue("Second reference not resolved",
-                    result.field1 == result.field2);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_2_resolveObject() {
-        try {
-            ResolveObjectTest obj = new ResolveObjectTest();
-            obj.field1 = "abc";
-            obj.field2 = obj.field1;
-            oos.writeObject(obj);
-            oos.close();
-            ois = new ResolveObjectInputStream(loadStream());
-            ((ResolveObjectInputStream) ois).enableResolve();
-            ResolveObjectTest result = null;
-            try {
-                result = (ResolveObjectTest) ois.readObject();
-            } catch (ClassNotFoundException e) {
-                fail(e.toString());
-            }
-            assertEquals("String not resolved", "ABC", result.field1);
-            assertTrue("Second reference not resolved",
-                    result.field1 == result.field2);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_3_resolveObject() {
-        try {
-            ResolveObjectTest obj = new ResolveObjectTest();
-            char[] lchars = new char[70000];
-            obj.field1 = new String(lchars);
-            obj.field2 = obj.field1;
-            oos.writeObject(obj);
-            oos.close();
-            ois = new ResolveObjectInputStream(loadStream());
-            ((ResolveObjectInputStream) ois).enableResolve();
-            ResolveObjectTest result = null;
-            try {
-                result = (ResolveObjectTest) ois.readObject();
-            } catch (ClassNotFoundException e) {
-                fail(e.toString());
-            }
-            assertTrue("Long String not resolved", "70000"
-                    .equals(result.field1));
-            assertTrue("Second reference not resolved",
-                    result.field1 == result.field2);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_4_resolveObject() {
-        try {
-            ResolveObjectTest obj = new ResolveObjectTest();
-            obj.field1 = new int[5];
-            obj.field2 = obj.field1;
-            oos.writeObject(obj);
-            oos.close();
-            ois = new ResolveObjectInputStream(loadStream());
-            ((ResolveObjectInputStream) ois).enableResolve();
-            ResolveObjectTest result = null;
-            try {
-                result = (ResolveObjectTest) ois.readObject();
-            } catch (ClassNotFoundException e) {
-                fail(e.toString());
-            }
-            Class cl = new Object[0].getClass();
-            assertTrue("int[] not resolved", result.field1.getClass() == cl);
-            assertTrue("Second reference not resolved",
-                    result.field1 == result.field2);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_5_resolveObject() {
-        try {
-            ResolveObjectTest obj = new ResolveObjectTest();
-            obj.field1 = new Object[2];
-            obj.field2 = obj.field1;
-            oos.writeObject(obj);
-            oos.close();
-            ois = new ResolveObjectInputStream(loadStream());
-            ((ResolveObjectInputStream) ois).enableResolve();
-            ResolveObjectTest result = null;
-            try {
-                result = (ResolveObjectTest) ois.readObject();
-            } catch (ClassNotFoundException e) {
-                fail(e.toString());
-            }
-            Class cl = new char[0].getClass();
-            assertTrue("int[] not resolved", result.field1.getClass() == cl);
-            assertTrue("Second reference not resolved",
-                    result.field1 == result.field2);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        }
-    }
-
-    static class WriteReplaceTestA implements Serializable {
-        public Object writeReplace() throws ObjectStreamException {
-            return new ReadResolveTestB();
-        }
-    }
-
-    static class WriteReplaceTestB extends WriteReplaceTestA {
-    }
-
-    static class WriteReplaceTestC extends WriteReplaceTestA {
-        public Object writeReplace() throws ObjectStreamException {
-            return new ReadResolveTestC();
-        }
-    }
-
-    static class WriteReplaceTestD implements Serializable {
-        private Object writeReplace() throws ObjectStreamException {
-            return new ReadResolveTestD();
-        }
-    }
-
-    static class WriteReplaceTestE extends WriteReplaceTestD {
-    }
-
-    static class WriteReplaceTestF implements Serializable {
-        int type, readType;
-
-        public WriteReplaceTestF(int type, int readType) {
-            this.type = type;
-            this.readType = readType;
-        }
-
-        public Object writeReplace() throws ObjectStreamException {
-            switch (type) {
-            case 0:
-                throw new InvalidObjectException("invalid");
-            case 1:
-                throw new RuntimeException("runtime");
-            case 2:
-                throw new Error("error");
-            default:
-                return new ReadResolveTestE(readType);
-            }
-        }
-    }
-
-    static class ReadResolveTestA implements Serializable {
-        public Object readResolve() throws ObjectStreamException {
-            return new ReadResolveTestA();
-        }
-    }
-
-    static class ReadResolveTestB extends ReadResolveTestA {
-    }
-
-    static class ReadResolveTestC implements Serializable {
-        private Object readResolve() throws ObjectStreamException {
-            return new ReadResolveTestB();
-        }
-    }
-
-    static class ReadResolveTestD extends ReadResolveTestC {
-    }
-
-    static class ReadResolveTestE implements Serializable {
-        int type;
-
-        public ReadResolveTestE(int type) {
-            this.type = type;
-        }
-
-        public Object readResolve() throws ObjectStreamException {
-            switch (type) {
-            case 0:
-                throw new InvalidObjectException("invalid");
-            case 1:
-                throw new RuntimeException("runtime");
-            case 2:
-                throw new Error("error");
-            case 3:
-                return this;
-            default:
-                return new ReadResolveTestF();
-            }
-        }
-    }
-
-    static class ReadResolveTestF implements Serializable {
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_1_writeReplace() {
-        try {
-            Vector v = new Vector();
-            v.addElement(new WriteReplaceTestA());
-            v.addElement(new WriteReplaceTestB());
-            v.addElement(new WriteReplaceTestB());
-            v.addElement(new WriteReplaceTestC());
-            v.addElement(new WriteReplaceTestD());
-            v.addElement(new WriteReplaceTestE());
-            oos.writeObject(v);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            Vector result = (Vector) ois.readObject();
-            assertTrue("invalid 0 : " + result.elementAt(0), result
-                    .elementAt(0).getClass() == ReadResolveTestA.class);
-            assertTrue("invalid 1 : " + result.elementAt(1), result
-                    .elementAt(1).getClass() == ReadResolveTestA.class);
-            assertTrue("invalid 2 : " + result.elementAt(2), result
-                    .elementAt(2).getClass() == ReadResolveTestA.class);
-            assertTrue("invalid 3 : " + result.elementAt(3), result
-                    .elementAt(3).getClass() == ReadResolveTestB.class);
-            assertTrue("invalid 4 : " + result.elementAt(4), result
-                    .elementAt(4).getClass() == ReadResolveTestD.class);
-            assertTrue("invalid 5 : " + result.elementAt(5), result
-                    .elementAt(5).getClass() == WriteReplaceTestE.class);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        } catch (ClassNotFoundException e) {
-            fail("ClassNotFoundException serializing data : " + e.getMessage());
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Verifies serialization.",
-        method = "!Serialization",
-        args = {}
-    )
-    public void test_2_writeReplace() {
-        try {
-            boolean exception = false;
-            try {
-                oos.writeObject(new WriteReplaceTestF(0, -1));
-            } catch (ObjectStreamException e) {
-                exception = true;
-            }
-            assertTrue("Should throw ObjectStreamException", exception);
-            exception = false;
-            try {
-                oos.writeObject(new WriteReplaceTestF(1, -1));
-            } catch (RuntimeException e) {
-                exception = true;
-            }
-            assertTrue("Should throw RuntimeException", exception);
-            exception = false;
-            try {
-                oos.writeObject(new WriteReplaceTestF(2, -1));
-            } catch (Error e) {
-                exception = true;
-            }
-            assertTrue("Should throw Error", exception);
-
-            oos.writeObject(new WriteReplaceTestF(3, 0));
-            oos.writeObject(new WriteReplaceTestF(3, 1));
-            oos.writeObject(new WriteReplaceTestF(3, 2));
-            WriteReplaceTestF test = new WriteReplaceTestF(3, 3);
-            oos.writeObject(test);
-            oos.writeObject(test);
-            WriteReplaceTestF test2 = new WriteReplaceTestF(3, 4);
-            oos.writeObject(test2);
-            oos.writeObject(test2);
-            oos.close();
-            ois = new ObjectInputStream(loadStream());
-            try {
-                ois.readObject();
-            } catch (WriteAbortedException e) {
-            }
-
-            exception = false;
-            try {
-                ois.readObject();
-            } catch (ObjectStreamException e) {
-                exception = true;
-            }
-            assertTrue("Expected ObjectStreamException", exception);
-            exception = false;
-            try {
-                ois.readObject();
-            } catch (RuntimeException e) {
-                exception = true;
-            }
-            assertTrue("Expected RuntimeException", exception);
-            exception = false;
-            try {
-                ois.readObject();
-            } catch (Error e) {
-                exception = true;
-            }
-            assertTrue("Expected Error", exception);
-
-            Object readE1 = ois.readObject();
-            Object readE2 = ois.readObject();
-            assertTrue("Replaced objects should be identical", readE1 == readE2);
-            Object readF1 = ois.readObject();
-            Object readF2 = ois.readObject();
-            assertTrue("Replaced resolved objects should be identical: "
-                    + readF1 + " " + readF2, readF1 == readF2);
-        } catch (IOException e) {
-            fail("IOException serializing data : " + e.getMessage());
-        } catch (ClassNotFoundException e) {
-            fail("ClassNotFoundException serializing data : " + e.getMessage());
-        }
-    }
 }
diff --git a/libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest0.java b/libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest0.java
new file mode 100644 (file)
index 0000000..b9d7eb6
--- /dev/null
@@ -0,0 +1,1000 @@
+/*
+ *  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 tests.api.java.io;
+
+import dalvik.annotation.BrokenTest;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InvalidObjectException;
+import java.io.NotActiveException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.io.StreamCorruptedException;
+import java.io.WriteAbortedException;
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * Automated Test Suite for class java.io.ObjectOutputStream
+ * 
+ */
+@TestTargetClass(Serializable.class) 
+public class SerializationStressTest0 extends SerializationStressTest {
+
+    private static class ObjectInputStreamSubclass extends ObjectInputStream {
+        private Vector resolvedClasses = new Vector();
+
+        public ObjectInputStreamSubclass(InputStream in) throws IOException,
+                StreamCorruptedException {
+            super(in);
+        }
+
+        public Class resolveClass(ObjectStreamClass osClass)
+                throws IOException, ClassNotFoundException {
+            Class result = super.resolveClass(osClass);
+            resolvedClasses.addElement(result);
+            return result;
+        }
+
+        public Class[] resolvedClasses() {
+            return (Class[]) resolvedClasses.toArray(new Class[resolvedClasses
+                    .size()]);
+        }
+    }
+
+    @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_1_Constructor() {
+            // Test for method java.io.ObjectOutputStream(java.io.OutputStream)
+
+            try {
+                oos.close();
+                oos = new ObjectOutputStream(new ByteArrayOutputStream());
+                oos.close();
+            } catch (Exception e) {
+                fail("Failed to create ObjectOutputStream : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_2_close() {
+            // Test for method void java.io.ObjectOutputStream.close()
+            try {
+                oos.close();
+                oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
+                oos.close();
+                oos.writeChar('T');
+                oos.writeObject(FOO);
+                // Writing to a closed stream does not cause problems. This is
+                // the expected behavior
+            } catch (IOException e) {
+                fail("Operation on closed stream threw IOException : "
+                        + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_3_defaultWriteObject() {
+            // Test for method void java.io.ObjectOutputStream.defaultWriteObject()
+
+            try {
+                oos.defaultWriteObject();
+            } catch (NotActiveException e) {
+                // Correct
+                return;
+            } catch (IOException e) {
+            }
+            fail(
+                    "Failed to throw NotActiveException when invoked outside readObject");
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_4_flush() {
+            // Test for method void java.io.ObjectOutputStream.flush()
+            try {
+                oos.close();
+                oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
+                int size = bao.size();
+                oos.writeByte(127);
+                assertTrue("Data flushed already", bao.size() == size);
+                oos.flush();
+                assertTrue("Failed to flush data", bao.size() > size);
+                // we don't know how many bytes are actually written for 1 byte,
+                // so we test > <before>
+                oos.close();
+                oos = null;
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_5_reset() {
+            // Test for method void java.io.ObjectOutputStream.reset()
+            try {
+                String o = "HelloWorld";
+                oos.writeObject(o);
+                oos.writeObject(o);
+                oos.reset();
+                oos.writeObject(o);
+                ois = new ObjectInputStream(loadStream());
+                ois.close();
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_6_write() {
+            // Test for method void java.io.ObjectOutputStream.write(byte [], int,
+            // int)
+            try {
+                byte[] buf = new byte[255];
+                byte[] output = new byte[255];
+                for (int i = 0; i < output.length; i++)
+                    output[i] = (byte) i;
+                oos.write(output, 0, output.length);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                ois.readFully(buf);
+                ois.close();
+                for (int i = 0; i < output.length; i++)
+                    if (buf[i] != output[i])
+                        fail("Read incorrect byte: " + i);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_6a_write() {
+            // Test for method void java.io.ObjectOutputStream.write(byte [], int,
+            // int)
+            try {
+                byte[] buf = new byte[256];
+                byte[] output = new byte[256];
+                for (int i = 0; i < output.length; i++)
+                    output[i] = (byte) (i & 0xff);
+                oos.write(output, 0, output.length);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                ois.readFully(buf);
+                ois.close();
+                for (int i = 0; i < output.length; i++)
+                    if (buf[i] != output[i])
+                        fail("Read incorrect byte: " + i);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_7_write() {
+            // Test for method void java.io.ObjectOutputStream.write(int)
+            try {
+                byte[] buf = new byte[10];
+                oos.write('T');
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertEquals("Read incorrect byte", 'T', ois.read());
+                ois.close();
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_8_write() {
+            // Test for method void java.io.ObjectOutputStream.write(byte [])
+            try {
+                byte[] buf = new byte[10];
+                oos.write("HelloWorld".getBytes());
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                ois.read(buf, 0, 10);
+                ois.close();
+                assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10)
+                        );
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_9_writeBoolean() {
+            // Test for method void java.io.ObjectOutputStream.writeBoolean(boolean)
+            try {
+                oos.writeBoolean(true);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertTrue("Wrote incorrect byte value", ois.readBoolean());
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_10_writeByte() {
+            // Test for method void java.io.ObjectOutputStream.writeByte(int)
+            try {
+                oos.writeByte(127);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertEquals("Wrote incorrect byte value", 127, ois.readByte());
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_11_writeBytes() {
+            // Test for method void
+            // java.io.ObjectOutputStream.writeBytes(java.lang.String)
+            try {
+                byte[] buf = new byte[10];
+                oos.writeBytes("HelloWorld");
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                ois.readFully(buf);
+                ois.close();
+                assertEquals("Wrote incorrect bytes value", "HelloWorld", new String(buf, 0, 10)
+                        );
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_12_writeChar() {
+            // Test for method void java.io.ObjectOutputStream.writeChar(int)
+            try {
+                oos.writeChar('T');
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertEquals("Wrote incorrect char value", 'T', ois.readChar());
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_13_writeChars() {
+            // Test for method void
+            // java.io.ObjectOutputStream.writeChars(java.lang.String)
+            try {
+                int avail = 0;
+                char[] buf = new char[10];
+                oos.writeChars("HelloWorld");
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                // Number of prim data bytes in stream / 2 to give char index
+                avail = ois.available() / 2;
+                for (int i = 0; i < avail; ++i)
+                    buf[i] = ois.readChar();
+                ois.close();
+                assertEquals("Wrote incorrect chars", "HelloWorld", new String(buf, 0, 10)
+                        );
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_14_writeDouble() {
+            // Test for method void java.io.ObjectOutputStream.writeDouble(double)
+            try {
+                oos.writeDouble(Double.MAX_VALUE);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertTrue("Wrote incorrect double value",
+                        ois.readDouble() == Double.MAX_VALUE);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_15_writeFloat() {
+            // Test for method void java.io.ObjectOutputStream.writeFloat(float)
+            try {
+                oos.writeFloat(Float.MAX_VALUE);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertTrue("Wrote incorrect double value",
+                        ois.readFloat() == Float.MAX_VALUE);
+                ois.close();
+                ois = null;
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_16_writeInt() {
+            // Test for method void java.io.ObjectOutputStream.writeInt(int)
+            try {
+                oos.writeInt(Integer.MAX_VALUE);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertTrue("Wrote incorrect double value",
+                        ois.readInt() == Integer.MAX_VALUE);
+                ois.close();
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_17_writeLong() {
+            // Test for method void java.io.ObjectOutputStream.writeLong(long)
+            try {
+                oos.writeLong(Long.MAX_VALUE);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertTrue("Wrote incorrect double value",
+                        ois.readLong() == Long.MAX_VALUE);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_19_writeShort() {
+            // Test for method void java.io.ObjectOutputStream.writeShort(int)
+            try {
+                oos.writeShort(127);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertEquals("Wrote incorrect short value", 127, ois.readShort());
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_20_writeUTF() {
+            // Test for method void
+            // java.io.ObjectOutputStream.writeUTF(java.lang.String)
+            try {
+                oos.writeUTF("HelloWorld");
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                assertEquals("Wrote incorrect UTF value", 
+                        "HelloWorld", ois.readUTF());
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_25_available() {
+            try {
+                oos.writeObject(FOO);
+                oos.writeObject(FOO);
+                oos.flush();
+                int available1 = 0;
+                int available2 = 0;
+                Object obj1 = null;
+                Object obj2 = null;
+                ObjectInputStream ois = new ObjectInputStream(loadStream());
+                available1 = ois.available();
+                obj1 = ois.readObject();
+                available2 = ois.available();
+                obj2 = ois.readObject();
+
+                assertEquals("available returned incorrect value", 0, available1);
+                assertEquals("available returned incorrect value", 0, available2);
+
+                assertTrue("available caused incorrect reading", FOO.equals(obj1));
+                assertTrue("available returned incorrect value", FOO.equals(obj2));
+
+            } catch (IOException e) {
+                fail("IOException serializing object : " + e.getMessage());
+            } catch (ClassNotFoundException e) {
+                fail("Unable to read Object type : " + e.toString());
+            } catch (Error err) {
+                System.out.println("Error " + err);
+                throw err;
+            }
+
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_resolveClass() {
+            try {
+                oos.writeObject(new Object[] { Integer.class, new Integer(1) });
+                oos.close();
+
+                ois = new ObjectInputStreamSubclass(loadStream());
+                ois.readObject();
+                ois.close();
+            } catch (IOException e1) {
+                fail("IOException : " + e1.getMessage());
+            } catch (ClassNotFoundException e2) {
+                fail("ClassNotFoundException : " + e2.getMessage());
+            }
+
+            Class[] resolvedClasses = ((ObjectInputStreamSubclass) ois)
+                    .resolvedClasses();
+            assertEquals("missing resolved", 3, resolvedClasses.length);
+            assertTrue("resolved class 1", resolvedClasses[0] == Object[].class);
+            assertTrue("resolved class 2", resolvedClasses[1] == Integer.class);
+            assertTrue("resolved class 3", resolvedClasses[2] == Number.class);
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_reset() {
+            try {
+                oos.reset();
+                oos.writeObject("R");
+                oos.reset();
+                oos.writeByte(24);
+                oos.close();
+
+                DataInputStream dis = new DataInputStream(loadStream());
+                byte[] input = new byte[dis.available()];
+                dis.readFully(input);
+                byte[] result = new byte[] { (byte) 0xac, (byte) 0xed, (byte) 0,
+                        (byte) 5, (byte) 0x79, (byte) 0x74, (byte) 0, (byte) 1,
+                        (byte) 'R', (byte) 0x79, (byte) 0x77, (byte) 1, (byte) 24 };
+                assertTrue("incorrect output", Arrays.equals(input, result));
+
+                ois = new ObjectInputStreamSubclass(loadStream());
+                assertEquals("Wrong result from readObject()", "R", ois.readObject()
+                        );
+                assertEquals("Wrong result from readByte()", 24, ois.readByte());
+                ois.close();
+            } catch (IOException e1) {
+                fail("IOException : " + e1.getMessage());
+            } catch (ClassNotFoundException e2) {
+                fail("ClassNotFoundException : " + e2.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_serialVersionUID(Class clazz, long svUID) {
+            final String idWrong = "serialVersionUID is wrong for: ";
+            long reflectedSvUID = 0L;
+            try {
+                reflectedSvUID = clazz.getField("serialVersionUID").getLong(null);
+            } catch (Exception e) {
+                fail("Unable to determine serialVersionUID of " + clazz);
+            }
+            assertTrue(idWrong + clazz + ": " + reflectedSvUID + " does not equal "
+                    + svUID, reflectedSvUID == svUID);
+        }
+
+        private static class ResolveObjectTest implements Serializable {
+            Object field1, field2;
+        }
+
+        private static class ResolveObjectInputStream extends ObjectInputStream {
+            ResolveObjectInputStream(InputStream in)
+                    throws StreamCorruptedException, IOException {
+                super(in);
+            }
+
+            public void enableResolve() {
+                enableResolveObject(true);
+            }
+
+            public Object resolveObject(Object obj) {
+                if (obj instanceof Vector) // test_1_resolveObject()
+                    return new Hashtable();
+                else if ("abc".equals(obj)) // test_2_resolveObject()
+                    return "ABC";
+                else if (obj instanceof String) // test_3_resolveObject()
+                    return String.valueOf(((String) obj).length());
+                else if (obj instanceof int[]) // test_4_resolveObject()
+                    return new Object[1];
+                else if (obj instanceof Object[] && ((Object[]) obj).length == 2) // test_5_resolveObject()
+                    return new char[1];
+                return obj;
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_1_resolveObject() {
+            try {
+                ResolveObjectTest obj = new ResolveObjectTest();
+                obj.field1 = new Vector();
+                obj.field2 = obj.field1;
+                oos.writeObject(obj);
+                oos.close();
+                ois = new ResolveObjectInputStream(loadStream());
+                ((ResolveObjectInputStream) ois).enableResolve();
+                ResolveObjectTest result = null;
+                try {
+                    result = (ResolveObjectTest) ois.readObject();
+                } catch (ClassNotFoundException e) {
+                    fail(e.toString());
+                }
+                assertTrue("Object not resolved",
+                        result.field1 instanceof Hashtable);
+                assertTrue("Second reference not resolved",
+                        result.field1 == result.field2);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_2_resolveObject() {
+            try {
+                ResolveObjectTest obj = new ResolveObjectTest();
+                obj.field1 = "abc";
+                obj.field2 = obj.field1;
+                oos.writeObject(obj);
+                oos.close();
+                ois = new ResolveObjectInputStream(loadStream());
+                ((ResolveObjectInputStream) ois).enableResolve();
+                ResolveObjectTest result = null;
+                try {
+                    result = (ResolveObjectTest) ois.readObject();
+                } catch (ClassNotFoundException e) {
+                    fail(e.toString());
+                }
+                assertEquals("String not resolved", "ABC", result.field1);
+                assertTrue("Second reference not resolved",
+                        result.field1 == result.field2);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_3_resolveObject() {
+            try {
+                ResolveObjectTest obj = new ResolveObjectTest();
+                char[] lchars = new char[70000];
+                obj.field1 = new String(lchars);
+                obj.field2 = obj.field1;
+                oos.writeObject(obj);
+                oos.close();
+                ois = new ResolveObjectInputStream(loadStream());
+                ((ResolveObjectInputStream) ois).enableResolve();
+                ResolveObjectTest result = null;
+                try {
+                    result = (ResolveObjectTest) ois.readObject();
+                } catch (ClassNotFoundException e) {
+                    fail(e.toString());
+                }
+                assertTrue("Long String not resolved", "70000"
+                        .equals(result.field1));
+                assertTrue("Second reference not resolved",
+                        result.field1 == result.field2);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_4_resolveObject() {
+            try {
+                ResolveObjectTest obj = new ResolveObjectTest();
+                obj.field1 = new int[5];
+                obj.field2 = obj.field1;
+                oos.writeObject(obj);
+                oos.close();
+                ois = new ResolveObjectInputStream(loadStream());
+                ((ResolveObjectInputStream) ois).enableResolve();
+                ResolveObjectTest result = null;
+                try {
+                    result = (ResolveObjectTest) ois.readObject();
+                } catch (ClassNotFoundException e) {
+                    fail(e.toString());
+                }
+                Class cl = new Object[0].getClass();
+                assertTrue("int[] not resolved", result.field1.getClass() == cl);
+                assertTrue("Second reference not resolved",
+                        result.field1 == result.field2);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_5_resolveObject() {
+            try {
+                ResolveObjectTest obj = new ResolveObjectTest();
+                obj.field1 = new Object[2];
+                obj.field2 = obj.field1;
+                oos.writeObject(obj);
+                oos.close();
+                ois = new ResolveObjectInputStream(loadStream());
+                ((ResolveObjectInputStream) ois).enableResolve();
+                ResolveObjectTest result = null;
+                try {
+                    result = (ResolveObjectTest) ois.readObject();
+                } catch (ClassNotFoundException e) {
+                    fail(e.toString());
+                }
+                Class cl = new char[0].getClass();
+                assertTrue("int[] not resolved", result.field1.getClass() == cl);
+                assertTrue("Second reference not resolved",
+                        result.field1 == result.field2);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            }
+        }
+
+        static class WriteReplaceTestA implements Serializable {
+            public Object writeReplace() throws ObjectStreamException {
+                return new ReadResolveTestB();
+            }
+        }
+
+        static class WriteReplaceTestB extends WriteReplaceTestA {
+        }
+
+        static class WriteReplaceTestC extends WriteReplaceTestA {
+            public Object writeReplace() throws ObjectStreamException {
+                return new ReadResolveTestC();
+            }
+        }
+
+        static class WriteReplaceTestD implements Serializable {
+            private Object writeReplace() throws ObjectStreamException {
+                return new ReadResolveTestD();
+            }
+        }
+
+        static class WriteReplaceTestE extends WriteReplaceTestD {
+        }
+
+        static class WriteReplaceTestF implements Serializable {
+            int type, readType;
+
+            public WriteReplaceTestF(int type, int readType) {
+                this.type = type;
+                this.readType = readType;
+            }
+
+            public Object writeReplace() throws ObjectStreamException {
+                switch (type) {
+                case 0:
+                    throw new InvalidObjectException("invalid");
+                case 1:
+                    throw new RuntimeException("runtime");
+                case 2:
+                    throw new Error("error");
+                default:
+                    return new ReadResolveTestE(readType);
+                }
+            }
+        }
+
+        static class ReadResolveTestA implements Serializable {
+            public Object readResolve() throws ObjectStreamException {
+                return new ReadResolveTestA();
+            }
+        }
+
+        static class ReadResolveTestB extends ReadResolveTestA {
+        }
+
+        static class ReadResolveTestC implements Serializable {
+            private Object readResolve() throws ObjectStreamException {
+                return new ReadResolveTestB();
+            }
+        }
+
+        static class ReadResolveTestD extends ReadResolveTestC {
+        }
+
+        static class ReadResolveTestE implements Serializable {
+            int type;
+
+            public ReadResolveTestE(int type) {
+                this.type = type;
+            }
+
+            public Object readResolve() throws ObjectStreamException {
+                switch (type) {
+                case 0:
+                    throw new InvalidObjectException("invalid");
+                case 1:
+                    throw new RuntimeException("runtime");
+                case 2:
+                    throw new Error("error");
+                case 3:
+                    return this;
+                default:
+                    return new ReadResolveTestF();
+                }
+            }
+        }
+
+        static class ReadResolveTestF implements Serializable {
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        public void test_1_writeReplace() {
+            try {
+                Vector v = new Vector();
+                v.addElement(new WriteReplaceTestA());
+                v.addElement(new WriteReplaceTestB());
+                v.addElement(new WriteReplaceTestB());
+                v.addElement(new WriteReplaceTestC());
+                v.addElement(new WriteReplaceTestD());
+                v.addElement(new WriteReplaceTestE());
+                oos.writeObject(v);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                Vector result = (Vector) ois.readObject();
+                assertTrue("invalid 0 : " + result.elementAt(0), result
+                        .elementAt(0).getClass() == ReadResolveTestA.class);
+                assertTrue("invalid 1 : " + result.elementAt(1), result
+                        .elementAt(1).getClass() == ReadResolveTestA.class);
+                assertTrue("invalid 2 : " + result.elementAt(2), result
+                        .elementAt(2).getClass() == ReadResolveTestA.class);
+                assertTrue("invalid 3 : " + result.elementAt(3), result
+                        .elementAt(3).getClass() == ReadResolveTestB.class);
+                assertTrue("invalid 4 : " + result.elementAt(4), result
+                        .elementAt(4).getClass() == ReadResolveTestD.class);
+                assertTrue("invalid 5 : " + result.elementAt(5), result
+                        .elementAt(5).getClass() == WriteReplaceTestE.class);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            } catch (ClassNotFoundException e) {
+                fail("ClassNotFoundException serializing data : " + e.getMessage());
+            }
+        }
+
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Verifies serialization.",
+            method = "!Serialization",
+            args = {}
+        )
+        @BrokenTest("Needs investigation. succeeds on android, fails on RI")
+        public void test_2_writeReplace() {
+            try {
+                boolean exception = false;
+                try {
+                    oos.writeObject(new WriteReplaceTestF(0, -1));
+                } catch (ObjectStreamException e) {
+                    exception = true;
+                }
+                assertTrue("Should throw ObjectStreamException", exception);
+                exception = false;
+                try {
+                    oos.writeObject(new WriteReplaceTestF(1, -1));
+                } catch (RuntimeException e) {
+                    exception = true;
+                }
+                assertTrue("Should throw RuntimeException", exception);
+                exception = false;
+                try {
+                    oos.writeObject(new WriteReplaceTestF(2, -1));
+                } catch (Error e) {
+                    exception = true;
+                }
+                assertTrue("Should throw Error", exception);
+
+                oos.writeObject(new WriteReplaceTestF(3, 0));
+                oos.writeObject(new WriteReplaceTestF(3, 1));
+                oos.writeObject(new WriteReplaceTestF(3, 2));
+                WriteReplaceTestF test = new WriteReplaceTestF(3, 3);
+                oos.writeObject(test);
+                oos.writeObject(test);
+                WriteReplaceTestF test2 = new WriteReplaceTestF(3, 4);
+                oos.writeObject(test2);
+                oos.writeObject(test2);
+                oos.close();
+                ois = new ObjectInputStream(loadStream());
+                try {
+                    ois.readObject();
+                } catch (WriteAbortedException e) {
+                }
+
+                exception = false;
+                try {
+                    ois.readObject();
+                } catch (ObjectStreamException e) {
+                    exception = true;
+                }
+                assertTrue("Expected ObjectStreamException", exception);
+                exception = false;
+                try {
+                    ois.readObject();
+                } catch (RuntimeException e) {
+                    exception = true;
+                }
+                assertTrue("Expected RuntimeException", exception);
+                exception = false;
+                try {
+                    ois.readObject();
+                } catch (Error e) {
+                    exception = true;
+                }
+                assertTrue("Expected Error", exception);
+
+                Object readE1 = ois.readObject();
+                Object readE2 = ois.readObject();
+                assertTrue("Replaced objects should be identical", readE1 == readE2);
+                Object readF1 = ois.readObject();
+                Object readF2 = ois.readObject();
+                assertTrue("Replaced resolved objects should be identical: "
+                        + readF1 + " " + readF2, readF1 == readF2);
+            } catch (IOException e) {
+                fail("IOException serializing data : " + e.getMessage());
+            } catch (ClassNotFoundException e) {
+                fail("ClassNotFoundException serializing data : " + e.getMessage());
+            }
+        }
+}
index b4d8677..d097d67 100644 (file)
@@ -16,7 +16,7 @@
  */
 package tests.api.java.io;
 
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass; 
@@ -812,7 +812,8 @@ public class SerializationStressTest1 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_14_writeObject() {
+    @BrokenTest("throws IllegalAccessException on Android and InvalidClassException on RI")
+    public void test_18_14_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -857,7 +858,8 @@ public class SerializationStressTest1 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_15_writeObject() {
+    @BrokenTest("throws IllegalAccessException on Android and InvalidClassException on RI")
+    public void test_18_15_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1345,6 +1347,7 @@ public class SerializationStressTest1 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
+    @BrokenTest("Needs investigation. fails on RI, succeeds on Android. Maybe a bug in the RI.")
     public void test_18_28_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
@@ -1612,6 +1615,7 @@ public class SerializationStressTest1 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
+    @BrokenTest("succeeds on Android, but fails on RI with MyException being thrown.")
     public void test_18_33_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
index 989469c..899cd8f 100644 (file)
@@ -17,7 +17,7 @@
 
 package tests.api.java.io;
 
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass; 
@@ -1419,7 +1419,8 @@ public class SerializationStressTest2 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_57_writeObject() {
+    @KnownFailure("Executed replacement when it should not: class java.lang.String")
+    public void test_18_57_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1457,7 +1458,8 @@ public class SerializationStressTest2 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_58_writeObject() {
+    @KnownFailure("Executed replacement when it should not: class java.lang.String")
+    public void test_18_58_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1898,7 +1900,8 @@ public class SerializationStressTest2 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_DeepNestingWithWriteObject() {
+    @KnownFailure("Maybe the stack gets too deep for android. Change the test?")
+    public void test_DeepNestingWithWriteObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
index f3617a3..3674418 100644 (file)
@@ -16,6 +16,8 @@
  */
 package tests.api.java.io;
 
+import dalvik.annotation.BrokenTest;
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
@@ -510,7 +512,8 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_85_writeObject() {
+    @BrokenTest("Needs investigation.Fails on Android with IlegalAccessException and RI with IOException: no valid constructor")
+    public void test_18_85_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1343,7 +1346,7 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_109_writeObject() {
+    public void test_18_109_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1377,7 +1380,7 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_110_writeObject() {
+    public void test_18_110_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1412,7 +1415,7 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_111_writeObject() {
+    public void test_18_111_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1447,7 +1450,7 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_112_writeObject() {
+    public void test_18_112_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1482,7 +1485,8 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_113_writeObject() {
+    @KnownFailure("Serialization of SimpleDateFormat object fails")
+    public void test_18_113_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
@@ -1550,7 +1554,8 @@ public class SerializationStressTest3 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_18_115_writeObject() {
+    @KnownFailure("Serialization of NumberFormat object fails")
+    public void test_18_115_writeObject() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
index 1ec1211..6cd919a 100644 (file)
@@ -17,7 +17,8 @@
 
 package tests.api.java.io;
 
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.BrokenTest;
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass; 
@@ -717,7 +718,7 @@ public class SerializationStressTest4 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_writeObject_Calendar() {
+    public void test_writeObject_Calendar() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.util.Calendar)
 
@@ -1198,7 +1199,8 @@ public class SerializationStressTest4 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_writeObject_Collections_UnmodifiableMap_UnmodifiableEntrySet() {
+    @BrokenTest("Needs investigation. Fails on RI and on Android with the same IOException.")
+    public void test_writeObject_Collections_UnmodifiableMap_UnmodifiableEntrySet() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet)
 
@@ -2677,7 +2679,7 @@ public class SerializationStressTest4 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
-    public void _test_writeObject_Proxy() {
+    public void test_writeObject_Proxy() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.security.GuardedObject)
 
@@ -2881,6 +2883,7 @@ public class SerializationStressTest4 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
+    @KnownFailure("deserialization of a date fomat field seems to fail")
     public void test_writeObject_DateFormat_Field() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.text.DateFormat.Field)
@@ -2925,6 +2928,7 @@ public class SerializationStressTest4 extends SerializationStressTest {
         method = "!Serialization",
         args = {}
     )
+    @KnownFailure("deserialization of a number fomat field seems to fail")
     public void test_writeObject_NumberFormat_Field() {
         // Test for method void
         // java.io.ObjectOutputStream.writeObject(java.text.NumberFormat.Field)
index 8a6da3b..7129cdc 100644 (file)
@@ -210,6 +210,13 @@ public class ProcessManagerTest extends TestCase {
 
     InputStream in;
 
+    @TestTargetNew(
+        level = TestLevel.ADDITIONAL,
+        notes = "Check non standard fd behavior",
+        clazz = Runtime.class,
+        method = "exec",
+        args = {String[].class, String[].class, java.io.File.class}
+    )
     public void testCloseNonStandardFds()
             throws IOException, InterruptedException {
         String[] commands = { "ls", "/proc/self/fd" };
@@ -245,6 +252,13 @@ public class ProcessManagerTest extends TestCase {
         return count;
     }
 
+    @TestTargetNew(
+        level = TestLevel.ADDITIONAL,
+        notes = "Check non standard fd behavior",
+        clazz = Runtime.class,
+        method = "exec",
+        args = {String[].class, String[].class, java.io.File.class}
+    )
     public void testInvalidCommand()
             throws IOException, InterruptedException {
         try {
index 3d43205..256c5ba 100644 (file)
@@ -23,7 +23,6 @@ import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.CookieHandler;
 import java.net.MalformedURLException;
 import java.net.NetPermission;
index 1930f53..b422761 100644 (file)
@@ -19,7 +19,6 @@ package tests.api.java.net;
 
 import dalvik.annotation.KnownFailure; 
 import dalvik.annotation.TestTargetClass; 
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 
@@ -38,7 +37,6 @@ import java.net.NetworkInterface;
 import java.net.PortUnreachableException;
 import java.net.SocketAddress;
 import java.net.SocketException;
-import java.net.SocketPermission;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 import java.nio.channels.DatagramChannel;
@@ -300,7 +298,6 @@ public class DatagramSocketTest extends SocketTestCase {
         method = "connect",
         args = {java.net.InetAddress.class, int.class}
     )
-    @KnownFailure("An unexpected Exception was thrown in the last part of the test")
     public void test_connectLjava_net_InetAddressI() {
         try {
             ds = new java.net.DatagramSocket();
index 46c7e98..f6957e2 100644 (file)
@@ -19,14 +19,12 @@ package tests.api.java.net;
 
 import dalvik.annotation.KnownFailure; 
 import dalvik.annotation.TestTargetClass; 
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 
 import java.io.IOException;
 import java.net.BindException;
 import java.net.DatagramPacket;
-import java.net.DatagramSocket;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -273,13 +271,13 @@ public class MulticastSocketTest extends SocketTestCase {
                     groupPort = Support_PortManager.getNextPortForUDP();
                     mss = new MulticastSocket(groupPort);
                     mss.setNetworkInterface(networkInterface1);
-                    assertTrue(
+                    InetAddress addr = mss.getInterface();
+                    NetworkInterface if1 = NetworkInterface.getByInetAddress(addr);
+                    assertEquals(
                             "getInterface did not return interface set by " +
-                            "setNeworkInterface Expected: "
-                                    + firstAddress + "Got:"
-                                    + mss.getInterface(), NetworkInterface
-                                    .getByInetAddress(mss.getInterface())
-                                    .equals(networkInterface1));
+                            "setNeworkInterface Expected: " + firstAddress
+                                    + "Got:" + mss.getInterface(),
+                                    networkInterface1, if1);
                 }
                 mss.close();
                 try {
index 449fbba..c64fd82 100644 (file)
@@ -22,13 +22,8 @@ import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.net.CacheRequest;
 import java.net.CacheResponse;
@@ -40,7 +35,6 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.security.Permission;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -168,7 +162,8 @@ public class ResponseCacheTest extends TestCase {
         method = "get",
         args = {java.net.URI.class, java.lang.String.class, java.util.Map.class}
     )
-    @BrokenTest("cache seems not to be used")
+    @BrokenTest("This test fails on both RI and android. Also only getting " +
+            "from the cache is tested. The put method is not tested.")
     public void test_get_put() throws Exception {
         
         URL url  = new URL("http://" + 
index fecf50c..f600ef4 100644 (file)
@@ -17,6 +17,8 @@
 
 package tests.api.java.net;
 
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
 import dalvik.annotation.TestTargetClass; 
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
@@ -273,6 +275,56 @@ public class SocketPermissionTest extends junit.framework.TestCase {
     }
 
     /**
+     * @tests serialization/deserialization.
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        notes = "Verifies serialization/deserialization compatibility.",
+        method = "!SerializationSelf",
+        args = {}
+    )
+    public void testSerializationSelf() throws Exception {
+        SocketPermission permission = new SocketPermission("harmony.apache.org", "connect");;
+
+        SerializationTest.verifySelf(permission);
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        notes = "",
+        method = "SocketPermission",
+        args = {java.lang.String.class, java.lang.String.class}
+    )
+    public void test_ConstructorLjava_lang_StringLjava_lang_String_subtestIPv6() {
+        String[] goodTestStrings = { 
+                "12334.0.0.01", "[fe80::1]",
+                "[FE80:0000:0000:0000:0000:0000:0000:0001]:80",
+                "[::ffff]:80-82", "[ffff::]:80-82", "[fe80::1]:80",
+                "FE80:0000:0000:0000:0000:0000:0000:0001",
+                "FE80:0000:0000:0000:0000:0000:0000:0001:80"
+        };
+        String[] badTestStrings = {"someName:withColonInit:80", "fg80::1", "[ffff:::80-82]",
+                ":[:fff]:80", "FE80:0000:0000:0000:0000:0000:0000:0001:80:82", "FE80::1"
+        };
+
+        for (int i=0; i < goodTestStrings.length; i++) {
+            try {
+                SocketPermission sp = new SocketPermission(goodTestStrings[i], "connect");
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+                fail("SocketPermission named: " + goodTestStrings[i] + " failed construction: " + e.getMessage());
+            }
+        }
+
+        for (int i=0; i < badTestStrings.length; i++) {
+            try {
+                SocketPermission sp = new SocketPermission(badTestStrings[i], "connect");
+                fail("SocketPermission named: " + badTestStrings[i] + " should have thrown an IllegalArgumentException on construction");
+            } catch (IllegalArgumentException e) {}
+        }
+    }
+
+    /**
      * Sets up the fixture, for example, open a network connection. This method
      * is called before a test is executed.
      */
index 04c92ee..d41f719 100644 (file)
 package tests.api.java.util;
 
 import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass; 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.AndroidOnly;
 
-import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Currency;
@@ -58,7 +55,6 @@ public class CurrencyTest extends junit.framework.TestCase {
         method = "getInstance",
         args = {java.util.Locale.class}
     )
-    @KnownFailure("getInstance instead of returning null value for region without currency throws exception which should be thrown only in case of locale does not support country code.")
     public void test_getInstanceLjava_util_Locale() {
         /*
          * the behaviour in all these three cases should be the same since this
@@ -150,30 +146,32 @@ public class CurrencyTest extends junit.framework.TestCase {
         method = "getSymbol",
         args = {}
     )
-    @KnownFailure("getSymbol() returns wrong value for currency symbol")
+    @AndroidOnly("icu and the RI have different data. Because Android"
+            + "only defines a few locales as a must have, it was not possible"
+            + "to find a set of combinations where no differences between"
+            + "the RI and Android exist.")
     public void test_getSymbol() {
-
+        
         Currency currK = Currency.getInstance("KRW");
-        Currency currI = Currency.getInstance("INR");
+        Currency currI = Currency.getInstance("IEP");
         Currency currUS = Currency.getInstance("USD");
 
         Locale.setDefault(Locale.US);
         assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
-        assertEquals("currI.getSymbol()", "INR", currI.getSymbol());
+        assertEquals("currI.getSymbol()", "IR\u00a3", currI.getSymbol());
         assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
 
-        Locale.setDefault(new Locale("ko", "KR"));
-        assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
-        assertEquals("currI.getSymbol()", "INR", currI.getSymbol());
+        Locale.setDefault(new Locale("en", "IE"));
+        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
+        assertEquals("currI.getSymbol()", "\u00a3", currI.getSymbol());
         assertEquals("currUS.getSymbol()", "USD", currUS.getSymbol());
 
         // test what happens if this is an invalid locale,
         // one with Korean country but an India language
-        // this method should return the currency codes in that case
         Locale.setDefault(new Locale("kr", "KR"));
         assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
-        assertEquals("currI.getSymbol()", "INR", currI.getSymbol());
-        assertEquals("currUS.getSymbol()", "USD", currUS.getSymbol());
+        assertEquals("currI.getSymbol()", "IR\u00a3", currI.getSymbol());
+        assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
     }
 
     /**
@@ -220,24 +218,20 @@ public class CurrencyTest extends junit.framework.TestCase {
                 new Locale("en", "")};
                 
         String[] euro    = new String[] {"EUR", "\u20ac"};
-        String[] yen     = new String[] {"JPY", "\uffe5", "\uffe5JP", "JP\uffe5"};
+        // \u00a5 and \uffe5 are actually the same symbol, just different code points.
+        // But the RI returns the \uffe5 and Android returns those with \u00a5 
+        String[] yen     = new String[] {"JPY", "\u00a5", "\u00a5JP", "JP\u00a5", "\uffe5", "\uffe5JP", "JP\uffe5"};
         String[] dollar  = new String[] {"USD", "$", "US$", "$US"};
         String[] cDollar = new String[] {"CAD", "$", "Can$", "$Ca"};
-        String[] crone   = new String[] {"DKK", "kr", "CrD"};
 
         Currency currE   = Currency.getInstance("EUR");
         Currency currJ   = Currency.getInstance("JPY");
         Currency currUS  = Currency.getInstance("USD");
         Currency currCA  = Currency.getInstance("CAD");
-        Currency currDKK = Currency.getInstance("DKK");
 
         int i, j, k;
         boolean flag;
         
-        Locale.setDefault(Locale.US);
-        Locale.setDefault(new Locale("ja", "JP"));
-        Locale.setDefault(new Locale("da", "DK"));
-        
         for(k = 0; k < loc1.length; k++) {
             Locale.setDefault(loc1[k]);
             
@@ -249,7 +243,12 @@ public class CurrencyTest extends junit.framework.TestCase {
                         break;
                     }
                 }
-                assertTrue(flag);
+                assertTrue("Default Locale is: " + Locale.getDefault()
+                        + ". For locale " + loc1[i]
+                        + " the Euro currency returned "
+                        + currE.getSymbol(loc1[i])
+                        + ". Expected was one of these: "
+                        + Arrays.toString(euro), flag);
             }
             
             for (i = 0; i < loc1.length; i++) {
@@ -262,7 +261,12 @@ public class CurrencyTest extends junit.framework.TestCase {
                         break;
                     }
                 }
-                assertTrue(flag);
+                assertTrue("Default Locale is: " + Locale.getDefault()
+                        + ". For locale " + loc1[i]
+                        + " the Yen currency returned "
+                        + currJ.getSymbol(loc1[i])
+                        + ". Expected was one of these: "
+                        + Arrays.toString(yen), flag);
             }
             
             for (i = 0; i < loc1.length; i++) {
@@ -273,7 +277,12 @@ public class CurrencyTest extends junit.framework.TestCase {
                         break;
                     }
                 }
-                assertTrue(flag);
+                assertTrue("Default Locale is: " + Locale.getDefault()
+                        + ". For locale " + loc1[i]
+                        + " the Dollar currency returned "
+                        + currUS.getSymbol(loc1[i])
+                        + ". Expected was one of these: "
+                        + Arrays.toString(dollar), flag);
             }
             
             for (i = 0; i < loc1.length; i++) {
@@ -284,18 +293,12 @@ public class CurrencyTest extends junit.framework.TestCase {
                         break;
                     }
                 }
-                assertTrue(flag);
-            }
-            
-            for (i = 0; i < loc1.length; i++) {
-                flag = false;
-                for  (j = 0; j < dollar.length; j++) {
-                    if (currCA.getSymbol(loc1[i]).equals(cDollar[j])) {
-                        flag = true;
-                        break;
-                    }
-                }
-                assertTrue(flag);
+                assertTrue("Default Locale is: " + Locale.getDefault()
+                        + ". For locale " + loc1[i]
+                        + " the Canadian Dollar currency returned "
+                        + currCA.getSymbol(loc1[i])
+                        + ". Expected was one of these: "
+                        + Arrays.toString(cDollar), flag);
             }
         }
     }
@@ -309,26 +312,31 @@ public class CurrencyTest extends junit.framework.TestCase {
         method = "getDefaultFractionDigits",
         args = {}
     )
-    @KnownFailure("method return wrong number of digits for pseudo-currency")
     public void test_getDefaultFractionDigits() {
-        Currency c1 = Currency.getInstance("EUR");
+
+        Currency c1 = Currency.getInstance("TND");
         c1.getDefaultFractionDigits();
         assertEquals(" Currency.getInstance(\"" + c1
-                + "\") returned incorrect number of digits. ", 2, c1
+                + "\") returned incorrect number of digits. ", 3, c1
                 .getDefaultFractionDigits());
 
-        Currency c2 = Currency.getInstance("JPY");
+        Currency c2 = Currency.getInstance("EUR");
         c2.getDefaultFractionDigits();
         assertEquals(" Currency.getInstance(\"" + c2
-                + "\") returned incorrect number of digits. ", 0, c2
+                + "\") returned incorrect number of digits. ", 2, c2
                 .getDefaultFractionDigits());
 
-        Currency c3 = Currency.getInstance("XBD");
+        Currency c3 = Currency.getInstance("JPY");
         c3.getDefaultFractionDigits();
         assertEquals(" Currency.getInstance(\"" + c3
-                + "\") returned incorrect number of digits. ", -1, c3
+                + "\") returned incorrect number of digits. ", 0, c3
                 .getDefaultFractionDigits());
 
+        Currency c4 = Currency.getInstance("XXX");
+        c4.getDefaultFractionDigits();
+        assertEquals(" Currency.getInstance(\"" + c4
+                + "\") returned incorrect number of digits. ", -1, c4
+                .getDefaultFractionDigits());
     }
 
     /**
index 6e1c86e..06a7797 100644 (file)
@@ -16,7 +16,6 @@
 package tests.api.java.util;
 
 import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass; 
 import dalvik.annotation.KnownFailure;
@@ -194,6 +193,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.lang.Appendable.class}
     )
+    @AndroidOnly("the RI trows an exception that makes no sense. See comment.")
     public void test_ConstructorLjava_lang_Appendable() {
         MockAppendable ma = new MockAppendable();
         Formatter f1 = new Formatter(ma);
@@ -267,6 +267,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.lang.String.class}
     )
+    @KnownFailure("The Exception is not thrown on linux if the user is root")
     public void test_ConstructorLjava_lang_String() throws IOException {
         Formatter f = null;
         try {
@@ -284,7 +285,7 @@ public class FormatterTest extends TestCase {
         assertEquals(0, fileWithContent.length());
         f.close();
 
-        // FIXME This exception will not be thrown out on linux.
+        // FIXME This exception will not be thrown on linux if the user is root.
         try {
             f = new Formatter(readOnly.getPath());
             fail("should throw FileNotFoundException");
@@ -313,6 +314,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.lang.String.class, java.lang.String.class}
     )
+    @KnownFailure("The Exception is not thrown on linux if the user is root")
     public void test_ConstructorLjava_lang_StringLjava_lang_String()
             throws IOException {
         Formatter f = null;
@@ -345,7 +347,7 @@ public class FormatterTest extends TestCase {
         assertEquals(0, fileWithContent.length());
         f.close();
 
-        // FIXME This exception will not be thrown out on linux.
+        // FIXME This exception will not be thrown on linux if the user is root.
         try {
             f = new Formatter(readOnly.getPath(), "UTF-16BE");
             fail("should throw FileNotFoundException");
@@ -374,6 +376,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.lang.String.class, java.lang.String.class, java.util.Locale.class}
     )
+    @KnownFailure("The Exception is not thrown on linux if the user is root")
     public void test_ConstructorLjava_lang_StringLjava_lang_StringLjava_util_Locale()
             throws IOException {
         Formatter f = null;
@@ -414,6 +417,7 @@ public class FormatterTest extends TestCase {
         assertEquals(0, fileWithContent.length());
         f.close();
 
+        // FIXME This exception will not be thrown on linux if the user is root.
         try {
             f = new Formatter(readOnly.getPath(), Charset.defaultCharset()
                     .name(), Locale.ITALY);
@@ -444,6 +448,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.io.File.class}
     )
+    @KnownFailure("The Exception is not thrown on linux if the user is root")
     public void test_ConstructorLjava_io_File() throws IOException {
         Formatter f = null;
         try {
@@ -461,7 +466,7 @@ public class FormatterTest extends TestCase {
         assertEquals(0, fileWithContent.length());
         f.close();
 
-        // FIXME This exception will not be thrown out on linux.
+        // FIXME This exception will not be thrown on linux if the user is root.
         try {
             f = new Formatter(readOnly);
             fail("should throw FileNotFoundException");
@@ -490,6 +495,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.io.File.class, java.lang.String.class}
     )
+    @KnownFailure("The Exception is not thrown on linux if the user is root")
     public void test_ConstructorLjava_io_FileLjava_lang_String()
             throws IOException {
         Formatter f = null;
@@ -508,7 +514,7 @@ public class FormatterTest extends TestCase {
         assertEquals(0, fileWithContent.length());
         f.close();
 
-        // FIXME This exception will not be thrown out on linux.
+        // FIXME This exception will not be thrown on linux if the user is root.
         try {
             f = new Formatter(readOnly, Charset.defaultCharset().name());
             fail("should throw FileNotFoundException");
@@ -563,6 +569,7 @@ public class FormatterTest extends TestCase {
         method = "Formatter",
         args = {java.io.File.class, java.lang.String.class, java.util.Locale.class}
     )
+    @KnownFailure("The Exception is not thrown on linux if the user is root")
     public void test_ConstructorLjava_io_FileLjava_lang_StringLjava_util_Locale()
             throws IOException {
         Formatter f = null;
@@ -601,7 +608,7 @@ public class FormatterTest extends TestCase {
         assertEquals(0, fileWithContent.length());
         f.close();
 
-        // FIXME This exception will not be thrown out on linux.
+        // FIXME This exception will not be thrown on linux if the user is root.
         try {
             f = new Formatter(readOnly.getPath(), Charset.defaultCharset()
                     .name(), Locale.ITALY);
@@ -2021,7 +2028,7 @@ public class FormatterTest extends TestCase {
         method = "format",
         args = {java.lang.String.class, java.lang.Object[].class}
     )
-    @KnownFailure("Conversion for japanese locale works improperly")
+    @AndroidOnly("Icu data for Czech locale differs a bit from the RI")
     public void test_formatLjava_lang_String$Ljava_lang_Object_DateTimeConversion() {
         Formatter f = null;
         Date now = new Date(1147327147578L);
@@ -2223,25 +2230,25 @@ public class FormatterTest extends TestCase {
                 
         };
         
-        final Object[][] lowerCaseJapanTriple = {
-                {0L,                        'a', "\u6728"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'a', "\u65e5"}, //$NON-NLS-2$
-                {-1000L,                    'a', "\u6728"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'a', "\u6728"}, //$NON-NLS-2$
-                {paris,                     'a', "\u6708"}, //$NON-NLS-2$
-                {china,                     'a', "\u6708"}, //$NON-NLS-2$
+        final Object[][] lowerCaseCzechTriple = {
+                {0L,                        'a', "\u010dt"}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'a', "ne"}, //$NON-NLS-2$
+                {-1000L,                    'a', "\u010dt"}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'a', "\u010dt"}, //$NON-NLS-2$
+                {paris,                     'a', "po"}, //$NON-NLS-2$
+                {china,                     'a', "po"}, //$NON-NLS-2$
                 {0L,                        'b', "1"}, //$NON-NLS-2$
                 {Long.MAX_VALUE,            'b', "8"}, //$NON-NLS-2$
                 {-1000L,                    'b', "1"}, //$NON-NLS-2$
                 {new Date(1147327147578L),  'b', "5"}, //$NON-NLS-2$
                 {paris,                     'b', "5"}, //$NON-NLS-2$
                 {china,                     'b', "5"}, //$NON-NLS-2$
-                {0L,                        'c', "\u6728 1 01 08:00:00 CST 1970"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'c', "\u65e5 8 17 15:12:55 CST 292278994"}, //$NON-NLS-2$
-                {-1000L,                    'c', "\u6728 1 01 07:59:59 CST 1970"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'c', "\u6728 5 11 13:59:07 CST 2006"}, //$NON-NLS-2$
-                {paris,                     'c', "\u6708 5 08 12:00:00 CEST 2006"}, //$NON-NLS-2$
-                {china,                     'c', "\u6708 5 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
+                {0L,                        'c', "\u010dt I 01 08:00:00 CST 1970"}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'c', "ne VIII 17 15:12:55 CST 292278994"}, //$NON-NLS-2$
+                {-1000L,                    'c', "\u010dt I 01 07:59:59 CST 1970"}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'c', "\u010dt V 11 13:59:07 CST 2006"}, //$NON-NLS-2$
+                {paris,                     'c', "po V 08 12:00:00 CEST 2006"}, //$NON-NLS-2$
+                {china,                     'c', "po V 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
                 {0L,                        'd', "01"}, //$NON-NLS-2$
                 {Long.MAX_VALUE,            'd', "17"}, //$NON-NLS-2$
                 {-1000L,                    'd', "01"}, //$NON-NLS-2$
@@ -2254,12 +2261,12 @@ public class FormatterTest extends TestCase {
                 {new Date(1147327147578L),  'e', "11"}, //$NON-NLS-2$
                 {paris,                     'e', "8"}, //$NON-NLS-2$
                 {china,                     'e', "8"}, //$NON-NLS-2$
-                {0L,                        'h', "1"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'h', "8"}, //$NON-NLS-2$
-                {-1000L,                    'h', "1"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'h', "5"}, //$NON-NLS-2$
-                {paris,                     'h', "5"}, //$NON-NLS-2$
-                {china,                     'h', "5"}, //$NON-NLS-2$
+                {0L,                        'h', "I"}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'h', "VIII"}, //$NON-NLS-2$
+                {-1000L,                    'h', "I"}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'h', "V"}, //$NON-NLS-2$
+                {paris,                     'h', "V"}, //$NON-NLS-2$
+                {china,                     'h', "V"}, //$NON-NLS-2$
                 {0L,                        'j', "001"}, //$NON-NLS-2$
                 {Long.MAX_VALUE,            'j', "229"}, //$NON-NLS-2$
                 {-1000L,                    'j', "001"}, //$NON-NLS-2$
@@ -2284,18 +2291,18 @@ public class FormatterTest extends TestCase {
                 {new Date(1147327147578L),  'm', "05"}, //$NON-NLS-2$
                 {paris,                     'm', "05"}, //$NON-NLS-2$
                 {china,                     'm', "05"}, //$NON-NLS-2$
-                {0L,                        'p', "\u5348\u524d"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'p', "\u5348\u5f8c"}, //$NON-NLS-2$
-                {-1000L,                    'p', "\u5348\u524d"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'p', "\u5348\u5f8c"}, //$NON-NLS-2$
-                {paris,                     'p', "\u5348\u5f8c"}, //$NON-NLS-2$
-                {china,                     'p', "\u5348\u5f8c"}, //$NON-NLS-2$
-                {0L,                        'r', "08:00:00 \u5348\u524d"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'r', "03:12:55 \u5348\u5f8c"}, //$NON-NLS-2$
-                {-1000L,                    'r', "07:59:59 \u5348\u524d"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'r', "01:59:07 \u5348\u5f8c"}, //$NON-NLS-2$
-                {paris,                     'r', "12:00:00 \u5348\u5f8c"}, //$NON-NLS-2$
-                {china,                     'r', "12:00:00 \u5348\u5f8c"}, //$NON-NLS-2$
+                {0L,                        'p', "dop."}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'p', "odp."}, //$NON-NLS-2$
+                {-1000L,                    'p', "dop."}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'p', "odp."}, //$NON-NLS-2$
+                {paris,                     'p', "odp."}, //$NON-NLS-2$
+                {china,                     'p', "odp."}, //$NON-NLS-2$
+                {0L,                        'r', "08:00:00 DOP."}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'r', "03:12:55 ODP."}, //$NON-NLS-2$
+                {-1000L,                    'r', "07:59:59 DOP."}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'r', "01:59:07 ODP."}, //$NON-NLS-2$
+                {paris,                     'r', "12:00:00 ODP."}, //$NON-NLS-2$
+                {china,                     'r', "12:00:00 ODP."}, //$NON-NLS-2$
                 {0L,                        's', "0"}, //$NON-NLS-2$
                 {Long.MAX_VALUE,            's', "9223372036854775"}, //$NON-NLS-2$
                 {-1000L,                    's', "-1"}, //$NON-NLS-2$
@@ -2337,10 +2344,10 @@ public class FormatterTest extends TestCase {
                             lowerCaseFranceTriple[i][output], f.toString());
 
             f = new Formatter(Locale.GERMAN);
-            f.format(Locale.JAPAN, formatSpecifier, lowerCaseJapanTriple[i][input]);
+            f.format(new Locale("cs", "CZ"), formatSpecifier, lowerCaseCzechTriple[i][input]);
             assertEquals("Format pattern: " + formatSpecifier //$NON-NLS-2$
-                            + " Argument: " + lowerCaseJapanTriple[i][input], //$NON-NLS-2$
-                            lowerCaseJapanTriple[i][output], f.toString());
+                            + " Argument: " + lowerCaseCzechTriple[i][input], //$NON-NLS-2$
+                            lowerCaseCzechTriple[i][output], f.toString());
 
             // test '%T'
             f = new Formatter(Locale.GERMAN);
@@ -2358,10 +2365,10 @@ public class FormatterTest extends TestCase {
                                     .toUpperCase(Locale.US), f.toString());
 
             f = new Formatter(Locale.GERMAN);
-            f.format(Locale.JAPAN, formatSpecifierUpper, lowerCaseJapanTriple[i][input]);
+            f.format(new Locale("cs", "CZ"), formatSpecifierUpper, lowerCaseCzechTriple[i][input]);
             assertEquals("Format pattern: " + formatSpecifierUpper //$NON-NLS-2$
-                            + " Argument: " + lowerCaseJapanTriple[i][input], //$NON-NLS-2$
-                            ((String)lowerCaseJapanTriple[i][output])
+                            + " Argument: " + lowerCaseCzechTriple[i][input], //$NON-NLS-2$
+                            ((String)lowerCaseCzechTriple[i][output])
                                     .toUpperCase(Locale.US), f.toString());
         }
 
@@ -2565,19 +2572,19 @@ public class FormatterTest extends TestCase {
                 
         };
 
-        final Object[][] upperCaseJapanTriple = {
-                {0L,                        'A', "\u6728\u66dc\u65e5"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'A', "\u65e5\u66dc\u65e5"}, //$NON-NLS-2$
-                {-1000L,                    'A', "\u6728\u66dc\u65e5"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'A', "\u6728\u66dc\u65e5"}, //$NON-NLS-2$
-                {paris,                     'A', "\u6708\u66dc\u65e5"}, //$NON-NLS-2$
-                {china,                     'A', "\u6708\u66dc\u65e5"}, //$NON-NLS-2$
-                {0L,                        'B', "1\u6708"}, //$NON-NLS-2$
-                {Long.MAX_VALUE,            'B', "8\u6708"}, //$NON-NLS-2$
-                {-1000L,                    'B', "1\u6708"}, //$NON-NLS-2$
-                {new Date(1147327147578L),  'B', "5\u6708"}, //$NON-NLS-2$
-                {paris,                     'B', "5\u6708"}, //$NON-NLS-2$
-                {china,                     'B', "5\u6708"}, //$NON-NLS-2$
+        final Object[][] upperCaseCzechTriple = {
+                {0L,                        'A', "\u010ctvrtek"}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'A', "Ned\u011ble"}, //$NON-NLS-2$
+                {-1000L,                    'A', "\u010ctvrtek"}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'A', "\u010ctvrtek"}, //$NON-NLS-2$
+                {paris,                     'A', "Pond\u011bl\u00ed"}, //$NON-NLS-2$
+                {china,                     'A', "Pond\u011bl\u00ed"}, //$NON-NLS-2$
+                {0L,                        'B', "leden"}, //$NON-NLS-2$
+                {Long.MAX_VALUE,            'B', "srpen"}, //$NON-NLS-2$
+                {-1000L,                    'B', "leden"}, //$NON-NLS-2$
+                {new Date(1147327147578L),  'B', "kv\u011bten"}, //$NON-NLS-2$
+                {paris,                     'B', "kv\u011bten"}, //$NON-NLS-2$
+                {china,                     'B', "kv\u011bten"}, //$NON-NLS-2$
                 {0L,                        'C', "19"}, //$NON-NLS-2$
                 {Long.MAX_VALUE,            'C', "2922789"}, //$NON-NLS-2$
                 {-1000L,                    'C', "19"}, //$NON-NLS-2$
@@ -2673,19 +2680,19 @@ public class FormatterTest extends TestCase {
                         continue;
                     }
                     // test '%t'
-                    f = new Formatter(Locale.JAPAN);
-                    f.format(formatSpecifier, upperCaseJapanTriple[i][input]);
+                    f = new Formatter(new Locale("cs", "CZ"));
+                    f.format(formatSpecifier, upperCaseCzechTriple[i][input]);
                     assertEquals("Format pattern: " + formatSpecifier //$NON-NLS-2$
-                            + " Argument: " + upperCaseJapanTriple[i][input], //$NON-NLS-2$
-                            upperCaseJapanTriple[i][output], f.toString());
+                            + " Argument: " + upperCaseCzechTriple[i][input], //$NON-NLS-2$
+                            upperCaseCzechTriple[i][output], f.toString());
 
-                    f = new Formatter(Locale.JAPAN);
+                    f = new Formatter(new Locale("cs", "CZ"));
                     f.format(Locale.GERMAN, formatSpecifier, upperCaseGermanTriple[i][input]);
                     assertEquals("Format pattern: " + formatSpecifier //$NON-NLS-2$
                             + " Argument: " + upperCaseGermanTriple[i][input], //$NON-NLS-2$
                             upperCaseGermanTriple[i][output], f.toString());
 
-                    f = new Formatter(Locale.JAPAN);
+                    f = new Formatter(new Locale("cs", "CZ"));
                     f.format(Locale.FRANCE, formatSpecifier, upperCaseFranceTriple[i][input]);
                     assertEquals("Format pattern: " + formatSpecifier //$NON-NLS-2$
                             + " Argument: " + upperCaseFranceTriple[i][input], //$NON-NLS-2$
@@ -2700,10 +2707,10 @@ public class FormatterTest extends TestCase {
                                     .toUpperCase(Locale.US), f.toString());
 
                     f = new Formatter(Locale.GERMAN);
-                    f.format(Locale.JAPAN, formatSpecifierUpper, upperCaseJapanTriple[i][input]);
+                    f.format(new Locale("cs", "CZ"), formatSpecifierUpper, upperCaseCzechTriple[i][input]);
                     assertEquals("Format pattern: " + formatSpecifierUpper //$NON-NLS-2$
-                            + " Argument: " + upperCaseJapanTriple[i][input], //$NON-NLS-2$
-                            ((String)upperCaseJapanTriple[i][output])
+                            + " Argument: " + upperCaseCzechTriple[i][input], //$NON-NLS-2$
+                            ((String)upperCaseCzechTriple[i][output])
                                     .toUpperCase(Locale.US), f.toString());
 
                     f = new Formatter(Locale.GERMAN);
@@ -2766,6 +2773,7 @@ public class FormatterTest extends TestCase {
         method = "format",
         args = {java.lang.String.class, java.lang.Object[].class}
     )
+    @KnownFailure("flaky! results. differs if debugger is attached.")
     public void test_formatLjava_lang_String$LBigInteger() {
         final Object[][] tripleD = {
                 {new BigInteger("123456789012345678901234567890"),          "%d",       "123456789012345678901234567890"}, //$NON-NLS-2$
index 76026bf..6d2ef74 100644 (file)
@@ -17,8 +17,8 @@
 
 package tests.api.java.util;
 
+import dalvik.annotation.AndroidOnly;
 import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass; 
 import dalvik.annotation.KnownFailure;
@@ -208,7 +208,6 @@ public class GregorianCalendarTest extends junit.framework.TestCase {
         method = "GregorianCalendar",
         args = {java.util.TimeZone.class, java.util.Locale.class}
     )
-    @KnownFailure("same objects for different locales are not considered equal")
     public void test_ConstructorLjava_util_TimeZoneLjava_util_Locale() {
         // Test for method java.util.GregorianCalendar(java.util.TimeZone,
         // java.util.Locale)
@@ -248,6 +247,8 @@ public class GregorianCalendarTest extends junit.framework.TestCase {
         method = "add",
         args = {int.class, int.class}
     )
+    @AndroidOnly("This test fails on the RI with version 1.5 but succeeds"
+            + "on the RI with version 1.6")
     public void test_addII() {
         // Test for method void java.util.GregorianCalendar.add(int, int)
         GregorianCalendar gc1 = new GregorianCalendar(1998, 11, 6);
@@ -763,7 +764,8 @@ public class GregorianCalendarTest extends junit.framework.TestCase {
         method = "getMinimalDaysInFirstWeek",
         args = {}
     )
-    @KnownFailure("Looks like there're some mistakes in timezones and/or locales data")
+    @KnownFailure("Some difference in timezones and/or locales data"
+            + "Who is right, the CLDR or the RI?")
     public void test_getMinimalDaysInFirstWeek() {
         // Regression for Harmony-1037
         GregorianCalendar g = new GregorianCalendar(TimeZone
@@ -772,7 +774,7 @@ public class GregorianCalendarTest extends junit.framework.TestCase {
         assertEquals(4, minimalDaysInFirstWeek);
 
         g = new GregorianCalendar(TimeZone.getTimeZone("Paris/France"),
-                new Locale("fr"));
+                new Locale("fr", "FR"));
         minimalDaysInFirstWeek = g.getMinimalDaysInFirstWeek();
         assertEquals(4, minimalDaysInFirstWeek);
         
index 61d7c35..ddf9994 100644 (file)
@@ -387,14 +387,14 @@ public class PropertiesTest extends junit.framework.TestCase {
         method = "loadFromXML",
         args = {java.io.InputStream.class}
     )
-    @KnownFailure("ToT fixed?")
+    @KnownFailure("Expected Exception is not thrown.")
     public void test_loadFromXMLLjava_io_InputStream() throws IOException {
         Properties myProps = new Properties();
         myProps.put("Property A", " aye\\\f\t\n\r\b");
         myProps.put("Property B", "b ee#!=:");
         myProps.put("Property C", "see");
-        
         Properties myProps2 = new Properties();
+
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         myProps.storeToXML(out, "A Header");
         out.close();
index 8fecc7e..480c998 100644 (file)
@@ -17,6 +17,7 @@
 
 package tests.api.java.util;
 
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
@@ -138,6 +139,9 @@ public class ResourceBundleTest extends junit.framework.TestCase {
         method = "getBundle",
         args = {java.lang.String.class, java.util.Locale.class, java.lang.ClassLoader.class}
     )
+    @KnownFailure("It's not allowed to pass null as parent class loader to"
+            + " a new ClassLoader anymore. Maybe we need to change"
+            + " URLClassLoader to allow this? It's not specified.")
     public void test_getBundleLjava_lang_StringLjava_util_LocaleLjava_lang_ClassLoader() {
         String classPath = System.getProperty("java.class.path");
         StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
index 87a5e87..4637f10 100644 (file)
@@ -61,7 +61,7 @@ public class TimeZoneTest extends junit.framework.TestCase {
         method = "getDSTSavings",
         args = {}
     )
-    @KnownFailure("method returns wrong time shift")
+    @KnownFailure("Might be a difference in data.")
     public void test_getDSTSavings() {
         // Test for method int java.util.TimeZone.getDSTSavings()
 
@@ -136,6 +136,7 @@ public class TimeZoneTest extends junit.framework.TestCase {
         method = "getTimeZone",
         args = {java.lang.String.class}
     )
+    @KnownFailure("Android fails the last test.")
     public void test_getTimeZoneLjava_lang_String() {
         assertEquals("Must return GMT when given an invalid TimeZone id SMT-8.",
                              "GMT", TimeZone.getTimeZone("SMT-8").getID());
diff --git a/libcore/luni/src/test/resources/tests/api/java/net/file1.cache b/libcore/luni/src/test/resources/tests/api/java/net/file1.cache
new file mode 100644 (file)
index 0000000..9245960
--- /dev/null
@@ -0,0 +1 @@
+Cache test
\ No newline at end of file
index b2375f8..3119131 100644 (file)
@@ -231,7 +231,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "add",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testAddMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -432,7 +431,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "subtract",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testSubtractMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -629,7 +627,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "multiply",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testMultiplyMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -767,7 +764,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "pow",
         args = {int.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testPowMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -912,7 +908,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "divide",
         args = {java.math.BigDecimal.class, int.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testDivideINonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -1820,7 +1815,9 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "divide",
         args = {java.math.BigDecimal.class, int.class, java.math.RoundingMode.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound IS INSUFFICIENT!!!")
+    @KnownFailure("Has a rounding problem. seems like the precision is"
+            + " 1 too small and cuts off the last digit. also this test might"
+            + "not be correct. The name implies that scale should be used.")
     public void testDivideScaleRoundingModeNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -2041,7 +2038,8 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "divide",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound IS INSUFFICIENT!!!")
+    @KnownFailure("The same test and the same problem like "
+            + "testDivideScaleRoundingModeNonTrivial")
     public void testDivideMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -2196,7 +2194,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "divideToIntegralValue",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testDivideToIntegralValueMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
@@ -2382,7 +2379,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "divideAndRemainder",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("WHY ISN'T THE LAST VALUE ROUNDED?")
     public void testDivideAndRemainderMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res[];
@@ -2542,7 +2538,6 @@ public class BigDecimalArithmeticTest extends TestCase {
         method = "remainder",
         args = {java.math.BigDecimal.class, java.math.MathContext.class}
     )
-    @KnownFailure("WHY ISN'T THE LAST VALUE ROUNDED?")
     public void testRemainderMathContextNonTrivial() {
         MathContext mc;
         BigDecimal a, b, res;
index a1b3202..97e8a5d 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.apache.harmony.math.tests.java.math;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -80,7 +79,6 @@ public class BigDecimalCompareTest extends TestCase {
         method = "abs",
         args = {java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.abs")
     public void testAbsMathContextNeg() {
         String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
         BigDecimal aNumber = new BigDecimal(a);
@@ -628,7 +626,6 @@ public class BigDecimalCompareTest extends TestCase {
         method = "negate",
         args = {java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.negate")
     public void testNegateMathContextPositive() {
        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
        MathContext mc = new MathContext(37, RoundingMode.FLOOR);
@@ -678,7 +675,6 @@ public class BigDecimalCompareTest extends TestCase {
         method = "negate",
         args = {java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.negate")
     public void testNegateMathContextNegative() {
        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
        int aScale = 49;
index a428c9f..74d0cb0 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.apache.harmony.math.tests.java.math;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -374,7 +373,6 @@ public class BigDecimalConstructorsTest extends TestCase {
         method = "BigDecimal",
         args = {java.math.BigInteger.class, int.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testConstrBigIntegerScaleMathContext_AndroidFailure() {
         MathContext mc;
         BigDecimal bd;
@@ -802,7 +800,6 @@ public class BigDecimalConstructorsTest extends TestCase {
         method = "BigDecimal",
         args = {double.class, java.math.MathContext.class}
     )
-    @KnownFailure("Fix in BigDecimal.inplaceRound")
     public void testConstrDoubleMathContext_AndroidFailure() {
         BigDecimal bd;
         MathContext mc;
index 3444a27..17c9a26 100644 (file)
@@ -529,7 +529,7 @@ public class BigDecimalScaleOperationsTest extends TestCase {
         method = "movePointRight",
         args = {int.class}
     )
-    @KnownFailure("Throws ArrayIndexOutOfBoundsException instead of ArithmeticException!")
+    @KnownFailure("Throws OutOfMemoryError instead of ArithmeticException!")
     public void testMovePointRightEx2() {
         BigDecimal a = new BigDecimal("123456789012345678901234567890123456789E25");
         try {
index 7bf973d..2313190 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.nio.tests.java.nio;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
@@ -695,7 +694,6 @@ public abstract class IntBufferTest extends AbstractBufferTest {
         method = "put",
         args = {int[].class, int.class, int.class}
     )
-    @KnownFailure("ToT fixed")
     public  void testPutintArrayintint2() {
         // Regression test
         ByteBuffer buf = ByteBuffer.allocateDirect(20);
index 6c7cbff..8985d31 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.nio.tests.java.nio;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
@@ -27,7 +26,6 @@ import java.nio.BufferOverflowException;
 import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
-import java.nio.IntBuffer;
 import java.nio.InvalidMarkException;
 import java.nio.ShortBuffer;
 
@@ -689,7 +687,6 @@ public abstract class ShortBufferTest extends AbstractBufferTest {
         method = "put",
         args = {short[].class, int.class, int.class}
     )
-    @KnownFailure("ToT fixed")
     public  void testPutshortArrayintint2() {
         // Regression test
         ByteBuffer buf = ByteBuffer.allocateDirect(10);
index 6faa772..b9f9bc6 100644 (file)
@@ -182,7 +182,6 @@ public class Charset_MultiByte_GB2312 extends Charset_AbstractTest {
         method = "functionalCoDec_REPR",
         args = {}
     )
-    @KnownFailure("This Characterset is not properly supported in Android!")
     @Override
     public void test_CodecDynamic() throws CharacterCodingException {
         super.test_CodecDynamic();
index 3c386b7..3f1afb5 100644 (file)
@@ -375,7 +375,6 @@ public class Charset_MultiByte_ISO_2022_JP extends Charset_AbstractTest {
         method = "functionalCoDec_REPR",
         args = {}
     )
-    @KnownFailure("This Characterset is not properly supported in Android!")
     @Override
     public void test_CodecDynamic() throws CharacterCodingException {
         super.test_CodecDynamic();
index 013d90f..5a1faa2 100644 (file)
@@ -231,7 +231,6 @@ public class Charset_MultiByte_x_windows_950 extends Charset_AbstractTest {
         method = "functionalCoDec_REPR",
         args = {}
     )
-    @KnownFailure("This Characterset is not properly supported in Android!")
     @Override
     public void test_CodecDynamic() throws CharacterCodingException {
         super.test_CodecDynamic();
index f53a579..80f663c 100644 (file)
@@ -49,24 +49,18 @@ public class AbstractPreferencesTest extends TestCase {
     protected void setUp() throws Exception {
         super.setUp();
 
+        Preferences.systemRoot().clear();
+        Preferences.userRoot().clear();
+
         parent = (AbstractPreferences) Preferences.userNodeForPackage(this.getClass());
-/*
-        String str[] = parent.childrenNames();
-        for (int i = 0; i < str.length; i++) {
-            System.out.print(str[i] + "  ");
-        }
-        System.out.println();
-/**/
+
         pref = (AbstractPreferences) parent.node(nodeName);
     }
 
     protected void tearDown() throws Exception {
-/*        String str[] = parent.childrenNames();
-        for (int i = 0; i < str.length; i++) {
-            System.out.print(str[i] + "  ");
-        }
-        System.out.println();/**/
         parent.removeNode();
+        Preferences.systemRoot().clear();
+        Preferences.userRoot().clear();
         super.tearDown();
     }
 
index a5deaed..3e1a377 100644 (file)
 package org.apache.harmony.prefs.tests.java.util.prefs;
 
 import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 
 import java.io.FilePermission;
-import java.io.IOException;
 import java.security.Permission;
-import java.util.prefs.AbstractPreferences;
 import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;
 
@@ -36,28 +32,15 @@ import junit.framework.TestCase;
 @TestTargetClass(java.util.prefs.Preferences.class)
 public class FilePreferencesImplTest extends TestCase {
 
-    private String prevFactory;
-    private Preferences uroot;
-    private Preferences sroot;
-    
     public FilePreferencesImplTest() {
         super();
     }
     
-    protected void setUp() throws Exception {
-     //   prevFactory = System.getProperty("java.util.prefs.PreferencesFactory");
-    //    System.setProperty("java.util.prefs.PreferencesFactory", "java.util.prefs.FilePreferencesFactoryImpl");
-        
-    //    uroot = (AbstractPreferences) Preferences.userRoot();
-        uroot = Preferences.userRoot();
-        sroot = Preferences.systemRoot();
+    @Override
+    protected void setUp(){
     }
-    
-    protected void tearDown() throws Exception {
-      //  if (prevFactory != null)
-      //      System.setProperty("java.util.prefs.PreferencesFactory", prevFactory);
-        uroot = null;
-        sroot = null;
+    @Override
+    protected void tearDown(){
     }
 
     @TestTargets({
@@ -80,7 +63,8 @@ public class FilePreferencesImplTest extends TestCase {
             args = {}
         )
     })
-    public void testPutGet() throws IOException, BackingStoreException {
+    public void testUserPutGet() throws BackingStoreException {
+        Preferences uroot = Preferences.userRoot().node("test");
         uroot.put("ukey1", "value1");
         assertEquals("value1", uroot.get("ukey1", null));
         String[] names = uroot.keys();
@@ -96,7 +80,30 @@ public class FilePreferencesImplTest extends TestCase {
         uroot.clear();
         names = uroot.keys();
         assertEquals(0, names.length);
+    }
 
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            notes = "Exceptions checking missed, but method is abstract, probably it is OK",
+            method = "put",
+            args = {java.lang.String.class, java.lang.String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            notes = "Exceptions checking missed, but method is abstract, probably it is OK",
+            method = "get",
+            args = {java.lang.String.class, java.lang.String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            notes = "Exceptions checking missed, but method is abstract, probably it is OK",
+            method = "keys",
+            args = {}
+        )
+    })
+    public void testSystemPutGet() throws BackingStoreException {
+        Preferences sroot = Preferences.systemRoot().node("test");
         sroot.put("skey1", "value1");
         assertEquals("value1", sroot.get("skey1", null));
         sroot.put("\u4e2d key1", "\u4e2d value1");
@@ -109,68 +116,74 @@ public class FilePreferencesImplTest extends TestCase {
         method = "childrenNames",
         args = {}
     )
-    @AndroidOnly("Checking of childNames.length doesn't pass on RI because of " +
-            "it depends on .userPrefs properties.")
-    @KnownFailure("This test fails on emulator. " +
-            "java.util.prefs.BackingStoreException is thrown during calling of" +
-            "childrenNames() method.")
-    public void testChildNodes() throws Exception {
-        
+    public void testUserChildNodes() throws Exception {
+        Preferences uroot = Preferences.userRoot().node("test");
+
         Preferences child1 = uroot.node("child1");
         Preferences child2 = uroot.node("\u4e2d child2");
         Preferences grandchild = child1.node("grand");
         assertNotNull(grandchild);
 
         String[] childNames = uroot.childrenNames();
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println("test:" + childNames[i]);
-        }        
-        assertEquals(4, childNames.length);
+        assertContains(childNames, "child1");
+        assertContains(childNames, "\u4e2d child2");
+        assertNotContains(childNames, "grand");
 
         childNames = child1.childrenNames();
-        assertEquals(1, childNames.length);
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println(childNames[i]);
-        }
+        assertContains(childNames, "grand");
 
         childNames = child2.childrenNames();
         assertEquals(0, childNames.length);
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println(childNames[i]);
-        }
 
         child1.removeNode();
         childNames = uroot.childrenNames();
-        assertEquals(3, childNames.length);
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println(childNames[i]);
-        }
-        // child2.removeNode();
-        // childNames = uroot.childrenNames();
-        // assertEquals(0, childNames.length);
+        assertNotContains(childNames, "child1");
+        assertContains(childNames, "\u4e2d child2");
+        assertNotContains(childNames, "grand");
 
-        child1 = sroot.node("child1");
-        child2 = sroot.node("child2");
-        grandchild = child1.node("grand");
+        child2.removeNode();
+        childNames = uroot.childrenNames();
+        assertNotContains(childNames, "child1");
+        assertNotContains(childNames, "\u4e2d child2");
+        assertNotContains(childNames, "grand");
+    }
 
-        childNames = sroot.childrenNames();
+    @TestTargetNew(
+        level = TestLevel.PARTIAL,
+        notes = "Exceptions checking missed, but method is abstract, probably it is OK",
+        method = "childrenNames",
+        args = {}
+    )
+    @AndroidOnly("It seems like the RI can't remove nodes created in the system root.")
+    public void testSystemChildNodes() throws Exception {
+        Preferences sroot = Preferences.systemRoot().node("test");
 
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println(childNames[i]);
-        }
-    //    assertEquals(2, childNames.length);
+        Preferences child1 = sroot.node("child1");
+        Preferences child2 = sroot.node("child2");
+        Preferences grandchild = child1.node("grand");
+
+        String[] childNames = sroot.childrenNames();
+        assertContains(childNames, "child1");
+        assertContains(childNames, "child2");
+        assertNotContains(childNames, "grand");
 
         childNames = child1.childrenNames();
         assertEquals(1, childNames.length);
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println(childNames[i]);
-        }
 
         childNames = child2.childrenNames();
         assertEquals(0, childNames.length);
-        for (int i = 0; i < childNames.length; i++) {
-            System.out.println(childNames[i]);
-        }
+
+        child1.removeNode();
+        childNames = sroot.childrenNames();
+        assertNotContains(childNames, "child1");
+        assertContains(childNames, "child2");
+        assertNotContains(childNames, "grand");
+
+        child2.removeNode();
+        childNames = sroot.childrenNames();
+        assertNotContains(childNames, "child1");
+        assertNotContains(childNames, "child2");
+        assertNotContains(childNames, "grand");
     }
 
     @TestTargets({
@@ -206,6 +219,8 @@ public class FilePreferencesImplTest extends TestCase {
         )
     })
     public void testSecurityException() throws BackingStoreException {
+        Preferences uroot = Preferences.userRoot().node("test");
+
         Preferences child1 = uroot.node("child1");
         MockFileSecurityManager manager = new MockFileSecurityManager();
         manager.install();
@@ -248,6 +263,23 @@ public class FilePreferencesImplTest extends TestCase {
         }
     }
 
+    private void assertContains(String[] childNames, String name) {
+        for (String childName : childNames) {
+            if (childName == name) {
+                return;
+            }
+        }
+        fail("No child with name " + name + " was found. It was expected to exist.");
+    }
+
+    private void assertNotContains(String[] childNames, String name) {
+        for (String childName : childNames) {
+            if (childName == name) {
+                fail("Child with name " + name + " was found. This was unexpected.");
+            }
+        }
+    }
+
     static class MockFileSecurityManager extends SecurityManager {
 
         SecurityManager dflt;
index 2221cc5..9d526d6 100644 (file)
@@ -45,6 +45,9 @@ import java.util.prefs.Preferences;
 @TestTargetClass(Preferences.class)
 public class PreferencesTest extends TestCase {
 
+    private String oldJavaHome;
+    private String oldUserHome;
+
     MockSecurityManager manager = new MockSecurityManager();
 
     MockInputStream stream = null;
@@ -77,18 +80,10 @@ public class PreferencesTest extends TestCase {
                 "<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\"><preferences><root type=\"user\"><map></map></root></preferences>"
                         .getBytes("UTF-8"));
         stream = new MockInputStream(in);
-        
-        String userHome = System.getProperty("user.home");
-        if (userHome != null) {
-            File userHomeDir = new File(userHome);
-            if (!userHomeDir.isDirectory() || !userHomeDir.canWrite()) {
-                userHome = null;
-            }
-        }
-        if (userHome == null) {
-            System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
-        }
-        
+
+        Preferences.systemRoot().clear();
+        Preferences.userRoot().clear();
+
         Preferences p = Preferences.userNodeForPackage(Preferences.class);
         p.clear();
         try {
@@ -109,6 +104,9 @@ public class PreferencesTest extends TestCase {
             p.removeNode();
         } catch (BackingStoreException e) {
         }
+
+        Preferences.systemRoot().clear();
+        Preferences.userRoot().clear();
     }
 
     @TestTargetNew(
@@ -146,7 +144,7 @@ public class PreferencesTest extends TestCase {
         }
 
         try {
-            p = Preferences.userNodeForPackage(null);
+            p = Preferences.systemNodeForPackage(null);
             fail("NullPointerException has not been thrown");
         } catch (NullPointerException e) {
             // expected
index 20f8221..b60fe2b 100644 (file)
@@ -22,6 +22,7 @@ import SQLite.Exception;
 import SQLite.Stmt;
 import SQLite.TableResult;
 import dalvik.annotation.AndroidOnly;
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
@@ -268,12 +269,12 @@ public class StmtTest extends SQLiteTest {
      * @tests {@link Stmt#reset()}
      */
     @TestTargetNew(
-        level = TestLevel.TODO,
+        level = TestLevel.COMPLETE,
         notes = "method test",
         method = "reset",
         args = {}
     )
-    @AndroidOnly("Tableresult is not cleared when resetting statement: "+
+    @BrokenTest("Tableresult is not cleared when resetting statement: "+
             "Either complete spec or change implementation accordingly.")
     public void testReset() throws Exception {
         db.exec("create table TEST (res integer not null)", null);
index 5d9a6bd..6f9cbd2 100644 (file)
@@ -545,6 +545,7 @@ public class TestUtils {
     // Second example
     /**
      * Certificate:
+     * <pre>
     Data:
         Version: 3 (0x2)
         Serial Number: 0 (0x0)
@@ -588,6 +589,7 @@ public class TestUtils {
         99:1c:f5:cb:77:86:36:cd:43:37:99:09:c2:9a:d8:f2:28:05:
         06:0c
 
+     * </pre>
      */
     public static final String rootCert = "-----BEGIN CERTIFICATE-----\n" + 
     "MIIDGzCCAoSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJBTjEQ\n" + 
@@ -631,6 +633,7 @@ public class TestUtils {
     
     /**
      * Certificate:
+     * <pre>
     Data:
         Version: 3 (0x2)
         Serial Number: 1 (0x1)
@@ -673,6 +676,7 @@ public class TestUtils {
         ba:b4:a2:c7:2c:cb:b1:3a:c2:d8:0c:21:31:ee:68:7e:97:ce:
         98:22:2e:c6:cf:f0:1a:11:04:ca:9a:06:de:98:48:85:ac:6c:
         6f:98
+     * </pre>
      */
     public static final String  endCert = 
         "-----BEGIN CERTIFICATE-----\n" + 
index 9db5382..34b5f0d 100644 (file)
@@ -534,13 +534,13 @@ public abstract class SerializationTest extends TestCase {
     private static Serializable getObject(TestCase test, String toAppend)
             throws Exception {
 
-        StringBuilder path = new StringBuilder("serialization");
+        StringBuilder path = new StringBuilder("/serialization");
 
         path.append(File.separatorChar);
         path.append(test.getClass().getName().replace('.', File.separatorChar));
         path.append(toAppend);
 
-        InputStream in = ClassLoader.getSystemClassLoader()
+        InputStream in = SerializationTest.class
                 .getResourceAsStream(path.toString());
 
         Assert.assertNotNull("Failed to load serialization resource file: "
index 93257da..a90a4d0 100644 (file)
@@ -96,10 +96,10 @@ public class Support_SimpleDateFormat extends Support_Format {
         // test with simple example
         format.applyPattern("h:m z");
 
-        super.text = "5:19 EDT";
+        super.text = "5:19 GMT-05:00";
         t_FormatWithField(21, format, date, null, Field.HOUR1, 0, 1);
         t_FormatWithField(22, format, date, null, Field.MINUTE, 2, 4);
-        t_FormatWithField(23, format, date, null, Field.TIME_ZONE, 5, 8);
+        t_FormatWithField(23, format, date, null, Field.TIME_ZONE, 5, 14);
 
         // test fields that are not included in the formatted text
 
@@ -125,14 +125,14 @@ public class Support_SimpleDateFormat extends Support_Format {
 
         // test with simple example with pattern char Z
         format.applyPattern("h:m Z z");
-        super.text = "5:19 -0400 EDT";
+        super.text = "5:19 -0400 GMT-05:00";
         t_FormatWithField(40, format, date, null, Field.HOUR1, 0, 1);
         t_FormatWithField(41, format, date, null, Field.MINUTE, 2, 4);
         t_FormatWithField(42, format, date, null, Field.TIME_ZONE, 5, 10);
     }
 
     public void t_formatToCharacterIterator() {
-        TimeZone tz = TimeZone.getTimeZone("EST");
+        TimeZone tz = TimeZone.getTimeZone("GMT-05:00");
         Calendar cal = new GregorianCalendar(tz);
         cal.set(1999, Calendar.SEPTEMBER, 13, 17, 19, 01);
         cal.set(Calendar.MILLISECOND, 0);
@@ -184,11 +184,11 @@ public class Support_SimpleDateFormat extends Support_Format {
     }
 
     private Vector<FieldContainer> getDateVector3() {
-        // "5:19 EDT"
+        // "5:19 GMT-05:00"
         Vector<FieldContainer> v = new Vector<FieldContainer>();
         v.add(new FieldContainer(0, 1, Field.HOUR1));
         v.add(new FieldContainer(2, 4, Field.MINUTE));
-        v.add(new FieldContainer(5, 8, Field.TIME_ZONE));
+        v.add(new FieldContainer(5, 14, Field.TIME_ZONE));
         return v;
     }
 
@@ -208,7 +208,7 @@ public class Support_SimpleDateFormat extends Support_Format {
         // 05
         // 005 19 019 1 01 001 0 00 000 Mon Monday 256 256 256 2 02 38 038 3 003
         // PM
-        // PM 5 005 EDT Eastern Daylight Time -0400 -0400"
+        // PM 5 005 GMT-05:00 GMT-05:00 -0500 -0500"
         v.add(new FieldContainer(0, 2, Field.ERA));
         v.add(new FieldContainer(3, 5, Field.ERA));
         v.add(new FieldContainer(6, 8, Field.YEAR));
@@ -253,10 +253,10 @@ public class Support_SimpleDateFormat extends Support_Format {
         v.add(new FieldContainer(145, 147, Field.AM_PM));
         v.add(new FieldContainer(149, 150, Field.HOUR0));
         v.add(new FieldContainer(151, 154, Field.HOUR0));
-        v.add(new FieldContainer(155, 158, Field.TIME_ZONE));
-        v.add(new FieldContainer(159, 180, Field.TIME_ZONE));
+        v.add(new FieldContainer(155, 164, Field.TIME_ZONE));
+        v.add(new FieldContainer(165, 174, Field.TIME_ZONE));
+        v.add(new FieldContainer(175, 180, Field.TIME_ZONE));
         v.add(new FieldContainer(181, 186, Field.TIME_ZONE));
-        v.add(new FieldContainer(187, 192, Field.TIME_ZONE));
         return v;
     }
 
index 6562019..e3ea9dc 100644 (file)
@@ -1728,7 +1728,7 @@ public class BidiTest extends TestCase {
     )
     public void testCreateLineBidiInvalid() {
         // regression for HARMONY-1050
-        Bidi bidi = new Bidi("str", 1);
+        Bidi bidi = new Bidi("str", Bidi.DIRECTION_RIGHT_TO_LEFT);
         try {
             bidi.createLineBidi(-1, 1);
             fail("Expected IAE");
@@ -1775,7 +1775,7 @@ public class BidiTest extends TestCase {
     )
     @KnownFailure("Is this a failure or just a different behaviour of ICU?")
     public void testCreateLineBidi_AndroidFailure() {
-        Bidi bidi = new Bidi("str", 1);
+        Bidi bidi = new Bidi("str", Bidi.DIRECTION_RIGHT_TO_LEFT);
         bidi.createLineBidi(2, 2);
     }
 
index 04a2b47..161a2c5 100644 (file)
@@ -353,14 +353,14 @@ public class CollatorTest extends junit.framework.TestCase {
         method = "setDecomposition",
         args = {int.class}
     )
-    @KnownFailure("Already fixed?")
+    @KnownFailure("uses decomposition even if set to NO_DECOMPOSITION")
     public void test_setDecompositionI() {
         Collator c = Collator.getInstance(Locale.FRENCH);
         c.setStrength(Collator.IDENTICAL);
         c.setDecomposition(Collator.NO_DECOMPOSITION);
-        assertTrue("Collator should not be using decomposition", !c.equals(
+        assertFalse("Collator should not be using decomposition", c.equals(
                 "\u212B", "\u00C5")); // "ANGSTROM SIGN" and "LATIN CAPITAL
-        // LETTER A WITH RING ABOVE"
+                                      // LETTER A WITH RING ABOVE"
         c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
         assertTrue("Collator should be using decomposition", c.equals("\u212B",
                 "\u00C5")); // "ANGSTROM SIGN" and "LATIN CAPITAL LETTER A WITH
index 2998eb6..1b2d8bb 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.harmony.text.tests.java.text;
 
 import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
@@ -152,7 +151,6 @@ public class DecimalFormatSymbolsTest extends TestCase {
         assertTrue("Returned incorrect currency",
                 dfsUS.getCurrency() == currency);
 
-        // BEGIN android-changed
         // use cs_CZ instead
         //Currency currK = Currency.getInstance("KRW");
         Currency currC = Currency.getInstance("CZK");
@@ -186,7 +184,6 @@ public class DecimalFormatSymbolsTest extends TestCase {
                 dfs1.getInternationalCurrencySymbol());
 
         dfs1 = new DecimalFormatSymbols(new Locale("de", "AT"));
-        // END android-changed
         assertTrue("Test4: Returned incorrect currency",
                 dfs1.getCurrency() == currE);
         assertEquals("Test4: Returned incorrect currencySymbol", "\u20ac", dfs1
@@ -417,10 +414,8 @@ public class DecimalFormatSymbolsTest extends TestCase {
             assertTrue("Hash codes of equal object are equal", dfs2
                     .hashCode() == dfs1.hashCode());
             dfs1.setInfinity("infinity_infinity");
-            // BEGIN android-changed
             assertTrue("Hash codes of non-equal objects are equal", dfs2
                     .hashCode() != dfs1.hashCode());
-            // END android-changed
         } catch (Exception e) {
             fail("Unexpected exception " + e.toString());
         }
@@ -545,7 +540,7 @@ public class DecimalFormatSymbolsTest extends TestCase {
         method = "setInternationalCurrencySymbol",
         args = {java.lang.String.class}
     )
-    @KnownFailure("getCurrency() doesn't return null. Test passes on RI.")
+    @KnownFailure("getCurrency() doesn't return null for bogus currency code.")
     public void test_setInternationalCurrencySymbolLjava_lang_String() {
         Locale locale = Locale.CANADA;
         DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
@@ -734,7 +729,7 @@ public class DecimalFormatSymbolsTest extends TestCase {
         method = "!SerializationGolden",
         args = {}
     )
-    @BrokenTest("Deserialized object is not equal to the original object." +
+    @KnownFailure("Deserialized object is not equal to the original object." +
             "Test passes on RI.")
     public void test_RIHarmony_compatible() throws Exception {
         ObjectInputStream i = null;
index 4ff54d0..a5ff158 100644 (file)
@@ -662,10 +662,11 @@ public class DecimalFormatTest extends TestCase {
         method = "getMinimumIntegerDigits",
         args = {}
     )
-    @KnownFailure("Something seems wrong with Android implementation, here!")
-    public void test_getMaximumIntegerDigits_AndroidFailure() {
+    @AndroidOnly("second 0 needs to be quoted in icu." +
+            "(quoting special characters in prefix and suffix necessary)")
+    public void test_getMaximumIntegerDigits2() {
         // regression test for HARMONY-878
-        assertTrue(new DecimalFormat("0\t0").getMaximumIntegerDigits() > 0);
+        assertTrue(new DecimalFormat("0\t'0'").getMaximumIntegerDigits() > 0);
     }
 
     @TestTargetNew(
@@ -1412,23 +1413,28 @@ public class DecimalFormatTest extends TestCase {
         method = "applyPattern",
         args = {java.lang.String.class}
     )
-    @KnownFailure("Something seems wrong with Android implementation, here!")
-    public void test_applyPatternLjava_lang_String_AndroidFailure() {
+    @AndroidOnly("icu supports 2 grouping sizes.")
+    public void test_applyPatternLjava_lang_String2() {
         DecimalFormat decFormat = new DecimalFormat("#.#");
         String [] patterns = {"####.##", "######.######", "000000.000000", 
                 "######.000000", "000000.######", " ###.###", "$#####.######",
                 "$$####.######", "%#,##,###,####", "#,##0.00;(#,##0.00)", 
                  "##.##-E"};
         
-        String [] expResult = {"#0.##", "#0.######", "#000000.000000", 
+        String [] expResult = {"#0.##", "#0.######", "#000000.000000",
                 "#.000000", "#000000.######", " #0.###", "$#0.######",
-                "$$#0.######", "%#,####", "#,##0.00;(#,##0.00)", 
-                 "#0.##-E"};
+                "$$#0.######",
+                "%#,###,####", // icu only. icu supports two grouping sizes 
+                "#,##0.00;(#,##0.00)",
+                "#0.##-'E'"}; // icu only. E in the suffix does not need to be
+                              // quoted. This is done automatically.
                 
         for (int i = 0; i < patterns.length; i++) {
             decFormat.applyPattern(patterns[i]);
-            assertEquals("Failed to apply following pattern: " + patterns[i],
-                    expResult[i], decFormat.toPattern());
+            String result = decFormat.toPattern();
+            assertEquals("Failed to apply following pattern: " + patterns[i] +
+                    " expected: " + expResult[i] + " returned: " + result,
+                    expResult[i], result);
         }
     }
 
@@ -2428,6 +2434,7 @@ public class DecimalFormatTest extends TestCase {
         method = "!SerializationGolden",
         args = {}
     )
+    @KnownFailure("a regression. This didn't fail before")
     public void test_serializationHarmonyRICompatible() {
         NumberFormat nf = NumberFormat.getInstance(Locale.FRANCE);
 
index 7cdd164..3c864a5 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.harmony.text.tests.java.text;
 
 import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
@@ -151,7 +150,6 @@ public class RuleBasedCollatorTest extends TestCase {
         method = "equals",
         args = {java.lang.Object.class}
     )
-    @KnownFailure("Succeeds against RI.")
     public void testEqualsObject() throws ParseException {
         String rule = "< a < b < c < d < e";
         RuleBasedCollator coll = new RuleBasedCollator(rule);
@@ -282,17 +280,17 @@ public class RuleBasedCollatorTest extends TestCase {
         method = "getCollationElementIterator",
         args = {java.text.CharacterIterator.class}
     )
-    @KnownFailure("Succeeds against RI.")
+    @KnownFailure("ICU seems to miss collation data")
     public void testGetCollationElementIteratorCharacterIterator() throws Exception {
         {
-            Locale locale = new Locale("es", "", "TRADITIONAL");
+            Locale locale = new Locale("cs", "CZ", "");
             RuleBasedCollator coll = (RuleBasedCollator) Collator
                     .getInstance(locale);
             String text = "cha";
             StringCharacterIterator source = new StringCharacterIterator(text);
             CollationElementIterator iterator = coll
                     .getCollationElementIterator(source);
-            int[] e_offset = { 0, 1, 2 };
+            int[] e_offset = { 0, 2 };
             int offset = iterator.getOffset();
             int i = 0;
             assertEquals(e_offset[i++], offset);
@@ -407,7 +405,6 @@ public class RuleBasedCollatorTest extends TestCase {
         method = "getAvailableLocales",
         args = {}
     )
-    @KnownFailure("Succeeds against RI.")
     public void testGetAvaiableLocales() {
         Locale[] locales = Collator.getAvailableLocales();
         boolean isUS = false;
index 821808f..286f080 100644 (file)
@@ -17,7 +17,6 @@
 package org.apache.harmony.text.tests.java.text;
 
 import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
@@ -470,7 +469,8 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
     )
     @KnownFailure("SimpleDateFormat.format(Date date, " +
             "StringBuffer toAppendTo, FieldPosition pos) " +
-            "return incorrect week number for \" W\" pattern. ")
+            "return incorrect week number for \" W\" pattern. " + 
+            "Also Android doesn't support formatting of PST, EST, ...")
     public void test_formatLjava_util_DateLjava_lang_StringBufferLjava_text_FieldPosition() {
         // Test for method java.lang.StringBuffer
         // java.text.SimpleDateFormat.format(java.util.Date,
@@ -607,20 +607,6 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
                 " 0", DateFormat.HOUR0_FIELD);
         test.test(" KK", cal, " 03", DateFormat.HOUR0_FIELD);
         test.test(" KKKK", cal, " 0003", DateFormat.HOUR0_FIELD);
-        
-//        Android doesn't support EST/EDT time zones
-//        format.setTimeZone(TimeZone.getTimeZone("EST"));
-//        test.test(" z", cal, " EDT", DateFormat.TIMEZONE_FIELD);
-//        Calendar temp2 = new GregorianCalendar(1999, Calendar.JANUARY, 12);
-//        test.test(" z", temp2, " EST", DateFormat.TIMEZONE_FIELD);
-//        test.test(" zz", cal, " EDT", DateFormat.TIMEZONE_FIELD);
-//        test.test(" zzz", cal, " EDT", DateFormat.TIMEZONE_FIELD);
-//        test.test(" zzzz", cal, " Eastern Daylight Time",
-//                DateFormat.TIMEZONE_FIELD);
-//        test.test(" zzzz", temp2, " Eastern Standard Time",
-//                DateFormat.TIMEZONE_FIELD);
-//       test.test(" zzzzz", cal, " Eastern Daylight Time",
-//                DateFormat.TIMEZONE_FIELD);
 
         format.setTimeZone(new SimpleTimeZone(60000, "ONE MINUTE"));
         test.test(" z", cal, " GMT+00:01", DateFormat.TIMEZONE_FIELD);
@@ -647,6 +633,19 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
         } catch (Throwable ex) {
             fail("Expected test to throw NPE, not " + ex.getClass().getName());
         }
+        
+        format.setTimeZone(TimeZone.getTimeZone("EST"));
+        test.test(" z", cal, " EDT", DateFormat.TIMEZONE_FIELD);
+        Calendar temp2 = new GregorianCalendar(1999, Calendar.JANUARY, 12);
+        test.test(" z", temp2, " EST", DateFormat.TIMEZONE_FIELD);
+        test.test(" zz", cal, " EDT", DateFormat.TIMEZONE_FIELD);
+        test.test(" zzz", cal, " EDT", DateFormat.TIMEZONE_FIELD);
+        test.test(" zzzz", cal, " Eastern Daylight Time",
+                DateFormat.TIMEZONE_FIELD);
+        test.test(" zzzz", temp2, " Eastern Standard Time",
+                DateFormat.TIMEZONE_FIELD);
+       test.test(" zzzzz", cal, " Eastern Daylight Time",
+                DateFormat.TIMEZONE_FIELD);
     }
 
     /**
@@ -672,6 +671,7 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
             args = {java.lang.String.class}
         )
     })
+    @KnownFailure("Android doesn't support formatting of PST, EST, ...")
     public void test_timeZoneFormatting() {
         // tests specific to formatting of timezones
         Date summerDate = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 3,
@@ -681,33 +681,32 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
 
         TestFormat test = new TestFormat(
                 "test_formatLjava_util_DateLjava_lang_StringBufferLjava_text_FieldPosition");
-//        Android doesn't support this time zone 
-//        test.verifyFormatTimezone("PST", "PDT, Pacific Daylight Time",
-//                "-0700, -0700", summerDate);
-//        test.verifyFormatTimezone("PST", "PST, Pacific Standard Time",
-//                "-0800, -0800", winterDate);
-
         test.verifyFormatTimezone("GMT-7", "GMT-07:00, GMT-07:00",
                 "-0700, -0700", summerDate);
         test.verifyFormatTimezone("GMT-7", "GMT-07:00, GMT-07:00",
                 "-0700, -0700", winterDate);
 
-        // Pacific/Kiritimati is one of the timezones supported only in mJava
+        // Pacific/Kiritimati is one of the timezones supported only in Java
 //         Android doesn't support this time zone 
 //        test.verifyFormatTimezone("Pacific/Kiritimati", "LINT, Line Is. Time",
 //                "+1400, +1400", summerDate);
 //        test.verifyFormatTimezone("Pacific/Kiritimati", "LINT, Line Is. Time",
 //                "+1400, +1400", winterDate);
 
-//        test.verifyFormatTimezone("EDT", "EDT, Eastern Daylight Time",
-//                "-0400, -0400", summerDate);
-//        test.verifyFormatTimezone("EST", "EST, Eastern Standard Time",
-//                "-0500, -0500", winterDate);
-
         test.verifyFormatTimezone("GMT+14", "GMT+14:00, GMT+14:00",
                 "+1400, +1400", summerDate);
         test.verifyFormatTimezone("GMT+14", "GMT+14:00, GMT+14:00",
                 "+1400, +1400", winterDate);
+
+        test.verifyFormatTimezone("PST", "PDT, Pacific Daylight Time",
+                "-0700, -0700", summerDate);
+        test.verifyFormatTimezone("PST", "PST, Pacific Standard Time",
+                "-0800, -0800", winterDate);
+
+        test.verifyFormatTimezone("EDT", "EDT, Eastern Daylight Time",
+                "-0400, -0400", summerDate);
+        test.verifyFormatTimezone("EST", "EST, Eastern Standard Time",
+                "-0500, -0500", winterDate);
     }
 
     /**
index b1ce1bc..250cf83 100644 (file)
 #include "org_apache_harmony_xnet_provider_jsse_common.h"
 
 /**
- * Global variable used in module org_apache_harmony_xnet_provider_jsse_common.h.
- * It is correctly updated in the function accept().
- */
-int verify_callback_mydata_index = 0;
-
-/**
  * Module scope variables initialized during JNI registration.
  */
 static jfieldID field_ssl_ctx;
@@ -1273,8 +1267,6 @@ static void org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl_accept(JNIEn
     SSL_CTX *ssl_ctx;
     mydata_t mydata;
 
-    char name[] = "mydata index";
-
     ssl_ctx = (SSL_CTX *)jssl_ctx;
 
     ssl = create_ssl(env, object, ssl_ctx);
@@ -1310,33 +1302,55 @@ static void org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl_accept(JNIEn
 
     SSL_set_bio(ssl, bio, bio);
 
-    /* Call to "register" some new application specific data. It takes three
-     * optional function pointers which are called when the parent structure 
-     * (in this case an RSA structure) is initially created, when it is copied
-     * and when it is freed up. If any or all of these function pointer 
-     * arguments are not used they should be set to NULL. Here we simply
-     * register a dummy callback application with the index 0.
+    /*
+     * Fill in the mydata structure needed for the certificate callback and
+     * store this in the SSL application data slot.
      */
-    verify_callback_mydata_index = SSL_get_ex_new_index(0, name, NULL, NULL, NULL);
-
-    /* Fill in the mydata structure */
     mydata.env = env;
     mydata.object = object;
-    SSL_set_ex_data(ssl, verify_callback_mydata_index, &mydata);
+    SSL_set_app_data(ssl, &mydata);
 
+    /*
+     * Do the actual SSL_accept(). It is possible this code is insufficient.
+     * Maybe we need to deal with all the special SSL error cases (WANT_*),
+     * just like we do for SSL_connect(). But currently it is looking ok.
+     */
     ret = SSL_accept(ssl);
 
-    if (ret < 1) {
+    /*
+     * Clear the SSL application data slot again, so we can safely use it for
+     * our ordinary synchronization structure afterwards. Also, we don't want
+     * sslDestroyAppData() to think that there is something that needs to be
+     * freed right now (in case of an error).
+     */
+    SSL_set_app_data(ssl, NULL);
+
+    if (ret == 0) {
         /*
-         * Translate the error, and throw if it turns out to be a real
-         * problem.
+         * The other side closed the socket before the handshake could be
+         * completed, but everything is within the bounds of the TLS protocol.
+         * We still might want to find out the real reason of the failure.
          */
         int sslErrorCode = SSL_get_error(ssl, ret);
-        if (sslErrorCode != SSL_ERROR_ZERO_RETURN) {
-            throwIOExceptionWithSslErrors(env, ret, sslErrorCode,
-                    "Trouble accepting connection");
-            free_ssl(env, object);
-        }
+        if (sslErrorCode == SSL_ERROR_NONE ||
+                sslErrorCode == SSL_ERROR_SYSCALL && errno == 0) {
+          throwIOExceptionStr(env, "Connection closed by peer");
+        } else {
+          throwIOExceptionWithSslErrors(env, ret, sslErrorCode,
+              "Trouble accepting connection");
+       }
+        free_ssl(env, object);
+        return;
+    } else if (ret < 0) {
+        /*
+         * Translate the error and throw exception. We are sure it is an error
+         * at this point.
+         */
+        int sslErrorCode = SSL_get_error(ssl, ret);
+        throwIOExceptionWithSslErrors(env, ret, sslErrorCode,
+                "Trouble accepting connection");
+        free_ssl(env, object);
+        return;
     }
 
     /*
index 16ecf9d..9ed75be 100644 (file)
@@ -91,8 +91,6 @@ static jobjectArray getcertificatebytes(JNIEnv* env,
     }
 }
 
-extern int verify_callback_mydata_index;
-
 /**
  * Verify the X509 certificate.
  */
@@ -107,7 +105,7 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *x509_store_ctx)
     /* Get the correct index to the SSLobject stored into X509_STORE_CTX. */
     ssl = (SSL*)X509_STORE_CTX_get_ex_data(x509_store_ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
 
-    mydata = (mydata_t*)SSL_get_ex_data(ssl, verify_callback_mydata_index);
+    mydata = (mydata_t*)SSL_get_app_data(ssl);
 
     cls = mydata->env->GetObjectClass(mydata->object);