Title: [2305] trunk/xstream/src/test/com/thoughtworks/acceptance/ReadResolveTest.java: Test resolve to null (invalidates XSTR-764).
Revision
2305
Author
joehni
Date
2014-12-12 14:40:31 -0600 (Fri, 12 Dec 2014)

Log Message

Test resolve to null (invalidates XSTR-764).

Modified Paths


Diff

Modified: trunk/xstream/src/test/com/thoughtworks/acceptance/ReadResolveTest.java (2304 => 2305)


--- trunk/xstream/src/test/com/thoughtworks/acceptance/ReadResolveTest.java	2014-11-11 00:23:18 UTC (rev 2304)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/ReadResolveTest.java	2014-12-12 20:40:31 UTC (rev 2305)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004, 2005 Joe Walnes.
- * Copyright (C) 2006, 2007 XStream Committers.
+ * Copyright (C) 2006, 2007, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -18,6 +18,7 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 /**
  * @author Chris Kelly
@@ -52,4 +53,31 @@
 
         assertSame(status, rStatus);
     }
+    
+    public static class ResolveToNull implements Serializable {
+        private String name;
+        public ResolveToNull(String name) {
+            this.name = name;
+        }
+        private Object readResolve() {
+            return null;
+        }
+    }
+    
+    public void testResolveToNull() throws IOException, ClassNotFoundException {
+        ResolveToNull obj = new ResolveToNull("test");
+        
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        ObjectOutputStream os = new ObjectOutputStream(bout);
+        os.writeObject(obj);
+        
+        byte[] bArray = bout.toByteArray();
+        ObjectInputStream in = null;
+        ByteArrayInputStream bin = new ByteArrayInputStream(bArray);
+        in = new ObjectInputStream(bin);
+        assertNull(in.readObject());
+        
+        xstream.alias("toNull", ResolveToNull.class);
+        assertNull(xstream.fromXML("<toNull><name>test</name></toNull>"));
+    }
 }

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to