You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/11/07 11:49:22 UTC
svn commit: r472058 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test:
java/org/apache/harmony/luni/tests/java/net/ java/tests/api/java/net/
resources/serialization/java/net/
resources/serialization/org/apache/harmony/luni/tests/jav...
Author: smishura
Date: Tue Nov 7 02:49:21 2006
New Revision: 472058
URL: http://svn.apache.org/viewvc?view=rev&rev=472058
Log:
Refactoring serialization tests to use new testing framework
Added:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java
- copied, changed from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet4AddressTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java
- copied, changed from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet6AddressTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
- copied, changed from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.golden.ser
- copied unchanged from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/Inet4AddressTest.golden.ser
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.golden.0.ser
- copied unchanged from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/Inet6Address.golden.0.ser
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.golden.1.ser
- copied unchanged from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/Inet6Address.golden.1.ser
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/InetAddressTest.golden.ser
- copied unchanged from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/InetAddressTest.golden.ser
Removed:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet4AddressTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet6AddressTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/Inet4AddressTest.golden.ser
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/Inet6Address.golden.0.ser
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/Inet6Address.golden.1.ser
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/java/net/InetAddressTest.golden.ser
Copied: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java (from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet4AddressTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java?view=diff&rev=472058&p1=incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet4AddressTest.java&r1=471977&p2=incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java&r2=472058
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet4AddressTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java Tue Nov 7 02:49:21 2006
@@ -15,17 +15,17 @@
* limitations under the License.
*/
-package tests.api.java.net;
+package org.apache.harmony.luni.tests.java.net;
+import java.io.Serializable;
import java.net.Inet4Address;
import java.net.InetAddress;
-import tests.util.SerializationTester;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
public class Inet4AddressTest extends junit.framework.TestCase {
- private static final String SERIALIZATION_FILE_NAME = "serialization/java/net/Inet4AddressTest.golden.ser";
-
/**
* @tests java.net.Inet4Address#isMulticastAddress()
*/
@@ -363,37 +363,39 @@
}
}
-
- /*
- * Test serialization/deserilazation.
- */
- public void testSerialization() throws Exception {
- InetAddress ia= Inet4Address.getByName("localhost");
- InetAddress deIA = (Inet4Address) SerializationTester
- .getDeserilizedObject(ia);
- byte[] iaAddresss= ia.getAddress();
- byte[] deIAAddresss= deIA.getAddress();
- for (int i = 0; i < iaAddresss.length; i++) {
- assertEquals(iaAddresss[i], deIAAddresss[i]);
- }
- assertEquals(4, iaAddresss.length);
- assertEquals(ia.getHostName(), deIA.getHostName());
- }
-
- /*
- * Test serialization/deserilazation compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
- InetAddress ia= Inet4Address.getByName("localhost");
- InetAddress deIA = (Inet4Address) SerializationTester
- .readObject(ia,
- SERIALIZATION_FILE_NAME);
- byte[] iaAddresss= ia.getAddress();
- byte[] deIAAddresss= deIA.getAddress();
- for (int i = 0; i < iaAddresss.length; i++) {
- assertEquals(iaAddresss[i], deIAAddresss[i]);
- }
- assertEquals(4, iaAddresss.length);
- assertEquals(ia.getHostName(), deIA.getHostName());
- }
+ // comparator for Inet4Address objects
+ private static final SerializableAssert COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+
+ Inet4Address initAddr = (Inet4Address) initial;
+ Inet4Address desrAddr = (Inet4Address) deserialized;
+
+ byte[] iaAddresss = initAddr.getAddress();
+ byte[] deIAAddresss = desrAddr.getAddress();
+ for (int i = 0; i < iaAddresss.length; i++) {
+ assertEquals(iaAddresss[i], deIAAddresss[i]);
+ }
+ assertEquals(4, deIAAddresss.length);
+ assertEquals(initAddr.getHostName(), desrAddr.getHostName());
+ }
+ };
+
+ /**
+ * @tests serialization/deserialization compatibility.
+ */
+ public void testSerializationSelf() throws Exception {
+
+ SerializationTest.verifySelf(Inet4Address.getByName("localhost"),
+ COMPARATOR);
+ }
+
+ /**
+ * @tests serialization/deserialization compatibility with RI.
+ */
+ public void testSerializationCompatibility() throws Exception {
+
+ SerializationTest.verifyGolden(this, Inet4Address
+ .getByName("localhost"), COMPARATOR);
+ }
}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java (from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet6AddressTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java?view=diff&rev=472058&p1=incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet6AddressTest.java&r1=471977&p2=incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java&r2=472058
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/Inet6AddressTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java Tue Nov 7 02:49:21 2006
@@ -15,21 +15,19 @@
* limitations under the License.
*/
-package tests.api.java.net;
+package org.apache.harmony.luni.tests.java.net;
+import java.io.Serializable;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
-import tests.util.SerializationTester;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
public class Inet6AddressTest extends junit.framework.TestCase {
- private static final String SERIALIZATION_FILE_NAME0 = "serialization/java/net/Inet6Address.golden.0.ser";
-
- private static final String SERIALIZATION_FILE_NAME1 = "serialization/java/net/Inet6Address.golden.1.ser";
-
/**
* @tests java.net.Inet6Address#isMulticastAddress()
*/
@@ -966,53 +964,48 @@
return fullString.toUpperCase();
}
- /*
- * Test serialization/deserilazation.
- */
- public void testSerialization() throws Exception {
- byte[] localv6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- Inet6Address ia = (Inet6Address) InetAddress.getByAddress(localv6);
- Inet6Address deIA = (Inet6Address) SerializationTester
- .getDeserilizedObject(ia);
- byte[] deAddr = deIA.getAddress();
- for (int i = 0; i < localv6.length; i++) {
- assertEquals(localv6[i], deAddr[i]);
+ // comparator for Inet6Address objects
+ private static final SerializableAssert COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+
+ Inet6Address initAddr = (Inet6Address) initial;
+ Inet6Address desrAddr = (Inet6Address) deserialized;
+
+ byte[] iaAddresss = initAddr.getAddress();
+ byte[] deIAAddresss = desrAddr.getAddress();
+ for (int i = 0; i < iaAddresss.length; i++) {
+ assertEquals(iaAddresss[i], deIAAddresss[i]);
+ }
+ assertEquals(initAddr.getScopeId(), desrAddr.getScopeId());
+ assertEquals(initAddr.getScopedInterface(), desrAddr
+ .getScopedInterface());
}
- assertEquals(ia.getScopeId(), deIA.getScopeId());
- assertEquals(ia.getScopedInterface(), deIA.getScopedInterface());
- }
+ };
- /*
- * Test serialization/deserilazation compatibility with RI.
+ /**
+ * @tests serialization/deserialization compatibility.
*/
- public void testSerializationCompatibility() throws Exception {
+ public void testSerializationSelf() throws Exception {
+
byte[] localv6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- Inet6Address ia = (Inet6Address) InetAddress.getByAddress(localv6);
- Inet6Address deIA = (Inet6Address) SerializationTester.readObject(ia,
- SERIALIZATION_FILE_NAME0);
- byte[] deAddr = deIA.getAddress();
- for (int i = 0; i < localv6.length; i++) {
- assertEquals(localv6[i], deAddr[i]);
- }
- assertEquals(ia.getScopeId(), deIA.getScopeId());
- assertEquals(ia.getScopedInterface(), deIA.getScopedInterface());
+
+ SerializationTest.verifySelf(InetAddress.getByAddress(localv6),
+ COMPARATOR);
}
-
- /*
- * Test serialization/deserilazation compatibility with RI.
+
+ /**
+ * @tests serialization/deserialization compatibility with RI.
*/
- public void testSerializationCompatibility_NullInterfaceName()
- throws Exception {
- // regression test for Harmony-1039
+ public void testSerializationCompatibility() throws Exception {
+
byte[] localv6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- Inet6Address ia = (Inet6Address) InetAddress.getByAddress(localv6);
- Inet6Address deIA = (Inet6Address) SerializationTester.readObject(ia,
- SERIALIZATION_FILE_NAME1);
- byte[] deAddr = deIA.getAddress();
- for (int i = 0; i < localv6.length; i++) {
- assertEquals(localv6[i], deAddr[i]);
- }
- assertEquals(ia.getScopeId(), deIA.getScopeId());
- assertEquals(ia.getScopedInterface(), deIA.getScopedInterface());
+
+ Object[] addresses = { InetAddress.getByAddress(localv6),
+ // Regression for Harmony-1039: ser-form has
+ // null interface name
+ InetAddress.getByAddress(localv6) };
+
+ SerializationTest.verifyGolden(this, addresses, COMPARATOR);
}
}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetAddressTest.java (from r471977, incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetAddressTest.java?view=diff&rev=472058&p1=incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java&r1=471977&p2=incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetAddressTest.java&r2=472058
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetAddressTest.java Tue Nov 7 02:49:21 2006
@@ -15,21 +15,22 @@
* limitations under the License.
*/
-package tests.api.java.net;
+package org.apache.harmony.luni.tests.java.net;
+import java.io.Serializable;
import java.net.DatagramSocket;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.Permission;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
+
import tests.support.Support_Configuration;
-import tests.util.SerializationTester;
public class InetAddressTest extends junit.framework.TestCase {
- private static final String SERIALIZATION_FILE_NAME = "serialization/java/net/InetAddressTest.golden.ser";
-
private static boolean someoneDone[] = new boolean[2];
protected static boolean threadedTestSucceeded;
@@ -483,39 +484,41 @@
assertFalse(ia.isReachable(null, 0, 1000));
}
- /*
- * Test serialization/deserilazation.
+ // comparator for InetAddress objects
+ private static final SerializableAssert COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+
+ InetAddress initAddr = (InetAddress) initial;
+ InetAddress desrAddr = (InetAddress) deserialized;
+
+ byte[] iaAddresss = initAddr.getAddress();
+ byte[] deIAAddresss = desrAddr.getAddress();
+ for (int i = 0; i < iaAddresss.length; i++) {
+ assertEquals(iaAddresss[i], deIAAddresss[i]);
+ }
+ assertEquals(initAddr.getHostName(), desrAddr.getHostName());
+ }
+ };
+
+ /**
+ * @tests serialization/deserialization compatibility.
*/
- public void testSerialization() throws Exception {
- InetAddress ia= InetAddress.getByName("localhost");
- InetAddress deIA = (InetAddress) SerializationTester
- .getDeserilizedObject(ia);
- byte[] iaAddresss= ia.getAddress();
- byte[] deIAAddresss= deIA.getAddress();
- for (int i = 0; i < iaAddresss.length; i++) {
- assertEquals(iaAddresss[i], deIAAddresss[i]);
- }
- assertEquals(ia.getHostName(), deIA.getHostName());
+ public void testSerializationSelf() throws Exception {
+
+ SerializationTest.verifySelf(InetAddress.getByName("localhost"),
+ COMPARATOR);
}
- /*
- * Test serialization/deserilazation compatibility with RI.
+ /**
+ * @tests serialization/deserialization compatibility with RI.
*/
public void testSerializationCompatibility() throws Exception {
- InetAddress ia= InetAddress.getByName("localhost");
- // the ser file was serialized by InetAddress.getByName("localhost");
- InetAddress deIA = (InetAddress) SerializationTester
- .readObject(ia,
- SERIALIZATION_FILE_NAME);
- byte[] iaAddresss= ia.getAddress();
- byte[] deIAAddresss= deIA.getAddress();
- for (int i = 0; i < iaAddresss.length; i++) {
- assertEquals(iaAddresss[i], deIAAddresss[i]);
- }
- assertEquals(ia.getHostName(), deIA.getHostName());
+
+ SerializationTest.verifyGolden(this,
+ InetAddress.getByName("localhost"), COMPARATOR);
}
-
-
+
class MockSecurityManager extends SecurityManager {
public void checkPermission(Permission permission) {
if (permission.getName().equals("setSecurityManager")){