harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r483345 - in /harmony/enhanced/classlib/trunk/modules/luni/src/test: java/org/apache/harmony/luni/tests/java/net/ java/org/apache/harmony/luni/tests/java/util/ java/tests/api/java/net/ java/tests/api/java/util/ resources/serialization/java/...
Date Thu, 07 Dec 2006 05:03:35 GMT
Author: smishura
Date: Wed Dec  6 21:03:34 2006
New Revision: 483345

URL: http://svn.apache.org/viewvc?view=rev&rev=483345
Log:
Migrate to new serialization testing framework

Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
      - copied, changed from r482980, harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetSocketAddressTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMap2Test.java
      - copied, changed from r483333, harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.golden.0.ser
      - copied unchanged from r482980, harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/InetSocketAddress.golden.2.ser
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.golden.1.ser
      - copied unchanged from r482980, harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/InetSocketAddress.golden.1.ser
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IdentityHashMap2Test.golden.ser
      - copied unchanged from r483333, harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/util/IdentityHashMapTest.golden.0.ser
Removed:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetSocketAddressTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/InetSocketAddress.golden.1.ser
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/InetSocketAddress.golden.2.ser
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/util/IdentityHashMapTest.golden.0.ser
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AllTests.java

Copied: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
(from r482980, harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetSocketAddressTest.java)
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java?view=diff&rev=483345&p1=harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetSocketAddressTest.java&r1=482980&p2=harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java&r2=483345
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetSocketAddressTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
Wed Dec  6 21:03:34 2006
@@ -13,19 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package tests.api.java.net;
+package org.apache.harmony.luni.tests.java.net;
 
+import java.io.Serializable;
 import java.net.InetSocketAddress;
 
-import tests.util.SerializationTester;
-
 import junit.framework.TestCase;
 
-public class InetSocketAddressTest extends TestCase {
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
 
-	private static final String SERIALIZATION_FILE_NAME = "serialization/java/net/InetSocketAddress.golden.1.ser";
-    
-    private static final String SERIALIZATION_FILE_NAME_UNRESOLVED = "serialization/java/net/InetSocketAddress.golden.2.ser";
+public class InetSocketAddressTest extends TestCase {
 
     /**
      * @tests java.net.InetSocketAddress#InetSocketAddress(String, int)
@@ -87,54 +85,42 @@
 			this.port = port;
 		}
 	};
-    
-    /**
-     * @tests serialization/deserialization.
-     */
-    public void test_serialization_unresolved() throws Exception {
-        InetSocketAddress ia= InetSocketAddress.createUnresolved("badhost",1000);
-        InetSocketAddress deIA = (InetSocketAddress) SerializationTester
-                .getDeserilizedObject(ia);
-        assertEquals(ia.getHostName(),deIA.getHostName());
-        assertEquals(ia.getPort(), deIA.getPort());
-        assertEquals(ia.getAddress(), deIA.getAddress());
-    }
-    
-    /**
-     * @tests serialization/deserialization.
-     */
-    public void test_serialization() throws Exception {
-        InetSocketAddress ia= InetSocketAddress.createUnresolved("badhost",1000);
-        InetSocketAddress deIA = (InetSocketAddress) SerializationTester
-                .getDeserilizedObject(ia);
-        assertEquals(ia.getHostName(),deIA.getHostName());
-        assertEquals(ia.getPort(), deIA.getPort());
-        assertEquals(ia.getAddress(), deIA.getAddress());
-    }
+
+    // comparator for InetSocketAddress objects
+    private static final SerializableAssert COMPARATOR = new SerializableAssert() {
+        public void assertDeserialized(Serializable initial,
+                Serializable deserialized) {
+
+            InetSocketAddress init = (InetSocketAddress) initial;
+            InetSocketAddress desr = (InetSocketAddress) deserialized;
+
+            assertEquals("HostName", init.getHostName(), desr.getHostName());
+            assertEquals("Port", init.getPort(), desr.getPort());
+            assertEquals("Address", init.getAddress(), desr.getAddress());
+        }
+    };
 
     /**
-     * @tests serialization/deserialization.
+     * @tests serialization/deserialization compatibility.
      */
-    public void test_serializationCompatibility_unresolved() throws Exception {
-        InetSocketAddress ia= InetSocketAddress.createUnresolved("badhost",1000);
-        InetSocketAddress deIA = (InetSocketAddress) SerializationTester
-                .readObject(ia,
-                        SERIALIZATION_FILE_NAME_UNRESOLVED);
-        assertEquals(ia.getHostName(),deIA.getHostName());
-        assertEquals(ia.getPort(), deIA.getPort());
-        assertEquals(ia.getAddress(), deIA.getAddress());
+    public void testSerializationSelf() throws Exception {
+
+        Object[] testCases = {
+                InetSocketAddress.createUnresolved("badhost", 1000), // unresolved
+                new InetSocketAddress("Localhost", 1000) };
+
+        SerializationTest.verifySelf(testCases, COMPARATOR);
     }
-    
+
     /**
-     * @tests serialization/deserialization.
+     * @tests serialization/deserialization compatibility with RI.
      */
-    public void test_serializationCompatibility() throws Exception {
-        InetSocketAddress ia= new InetSocketAddress("Localhost",1000);
-        InetSocketAddress deIA = (InetSocketAddress) SerializationTester
-                .readObject(ia,
-                        SERIALIZATION_FILE_NAME);
-        assertEquals(ia.getAddress(), deIA.getAddress());
-        assertEquals(ia.getPort(), deIA.getPort());
-        assertEquals(ia.getHostName().toLowerCase(),deIA.getHostName().toLowerCase());
+    public void testSerializationCompatibility() throws Exception {
+
+        Object[] testCases = {
+                InetSocketAddress.createUnresolved("badhost", 1000), // unresolved
+                new InetSocketAddress("Localhost", 1000) };
+
+        SerializationTest.verifyGolden(this, testCases, COMPARATOR);
     }
 }

Copied: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMap2Test.java
(from r483333, harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java)
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMap2Test.java?view=diff&rev=483345&p1=harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java&r1=483333&p2=harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMap2Test.java&r2=483345
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMap2Test.java
Wed Dec  6 21:03:34 2006
@@ -15,8 +15,9 @@
  *  limitations under the License.
  */
 
-package tests.api.java.util;
+package org.apache.harmony.luni.tests.java.util;
 
+import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.IdentityHashMap;
@@ -25,7 +26,8 @@
 import java.util.Set;
 import java.util.TreeSet;
 
-import tests.util.SerializationTester;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
 
 public class IdentityHashMap2Test extends junit.framework.TestCase {
 
@@ -318,19 +320,28 @@
 		assertTrue("newset and keyset do not have same elements 2", set
 				.equals(newset));
 	}
-    
+
+    // comparator for IdentityHashMap objects
+    private static final SerializableAssert COMPARATOR = new SerializableAssert() {
+        public void assertDeserialized(Serializable initial,
+                Serializable deserialized) {
+
+            IdentityHashMap init = (IdentityHashMap) initial;
+            IdentityHashMap desr = (IdentityHashMap) deserialized;
+
+            assertEquals("Size", init.size(), desr.size());
+        }
+    };
+
     /**
-     * @tests java.util.IdentityHashMap#serializationTest
+     * @tests serialization/deserialization compatibility with RI.
      */
-    public void test_serialization_compatibility() throws Exception {
+    public void testSerializationCompatibility() throws Exception {
         IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<String,
String>();
         identityHashMap.put("key1", "value1");
         identityHashMap.put("key2", "value2");
         identityHashMap.put("key3", "value3");
 
-        IdentityHashMap<String, String> nobj = (IdentityHashMap<String, String>)
SerializationTester
-                .readObject(identityHashMap,
-                        "serialization/java/util/IdentityHashMapTest.golden.0.ser");
-        assertEquals(identityHashMap.size(), nobj.size());
+        SerializationTest.verifyGolden(this, identityHashMap, COMPARATOR);
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AllTests.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AllTests.java?view=diff&rev=483345&r1=483344&r2=483345
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AllTests.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AllTests.java
Wed Dec  6 21:03:34 2006
@@ -54,7 +54,6 @@
 		suite.addTestSuite(HashSetTest.class);
 		suite.addTestSuite(HashtableTest.class);
 		suite.addTestSuite(IdentityHashMapTest.class);
-		suite.addTestSuite(IdentityHashMap2Test.class);
 		suite.addTestSuite(LinkedHashMapTest.class);
 		suite.addTestSuite(LinkedHashSetTest.class);
 		suite.addTestSuite(LinkedListTest.class);



Mime
View raw message