--- jsr166/src/test/tck/JSR166TestCase.java 2011/06/22 07:46:57 1.90
+++ jsr166/src/test/tck/JSR166TestCase.java 2012/11/18 18:03:11 1.92
@@ -69,7 +69,7 @@ import java.security.SecurityPermission;
*
*
*
- *
Other notes
+ *
Other notes
*
*
* - Usually, there is one testcase method per JSR166 method
@@ -1202,16 +1202,33 @@ public class JSR166TestCase extends Test
}
}
- @SuppressWarnings("unchecked")
- T serialClone(T o) {
+ void assertSerialEquals(Object x, Object y) {
+ assertTrue(Arrays.equals(serialBytes(x), serialBytes(y)));
+ }
+
+ void assertNotSerialEquals(Object x, Object y) {
+ assertFalse(Arrays.equals(serialBytes(x), serialBytes(y)));
+ }
+
+ byte[] serialBytes(Object o) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
oos.flush();
oos.close();
+ return bos.toByteArray();
+ } catch (Throwable t) {
+ threadUnexpectedException(t);
+ return new byte[0];
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ T serialClone(T o) {
+ try {
ObjectInputStream ois = new ObjectInputStream
- (new ByteArrayInputStream(bos.toByteArray()));
+ (new ByteArrayInputStream(serialBytes(o)));
T clone = (T) ois.readObject();
assertSame(o.getClass(), clone.getClass());
return clone;