Author: sebb
Date: Wed Apr 17 12:32:56 2013
New Revision: 1468867
URL: http://svn.apache.org/r1468867
Log:
More tests
Modified:
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
Modified:
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java?rev=1468867&r1=1468866&r2=1468867&view=diff
==============================================================================
---
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
(original)
+++
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
Wed Apr 17 12:32:56 2013
@@ -99,34 +99,62 @@ public class ClassLoaderObjectInputStrea
private static final long serialVersionUID = 1L;
private int i;
+ private Object o;
+
private E e;
- Test(int i) {
+ Test(int i, Object o) {
this.i = i;
this.e = E.A;
+ this.o = o;
}
@Override
public boolean equals(Object other) {
if (other instanceof Test) {
Test tother = (Test) other;
return (this.i == tother.i)
- & (this.e == tother.e);
+ & (this.e == tother.e)
+ & equalObject(tother.o);
} else {
return false;
}
}
+ private boolean equalObject(Object other) {
+ if (this.o == null) {
+ return other == null;
+ }
+ return o.equals(other);
+ }
@Override
public int hashCode() {
return super.hashCode();
}
}
- public void testObject() throws Exception {
+ public void testObject1() throws Exception {
+
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+ final Object input = new Test(123, null);
+ oos.writeObject(input);
+ oos.close();
+
+ final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ final ClassLoaderObjectInputStream clois =
+ new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais);
+ final Object result = clois.readObject();
+
+ assertEquals(input, result);
+ clois.close();
+ }
+
+ public void testObject2() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
- final Object input = new Test(123);
+ final Object input = new Test(123, Integer.valueOf(0));
oos.writeObject(input);
oos.close();