Log Message
Add JSON unit tests for Jettison.
Modified Paths
Diff
Modified: trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java (2251 => 2252)
--- trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java 2014-01-31 22:39:05 UTC (rev 2251)
+++ trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java 2014-02-04 10:13:24 UTC (rev 2252)
@@ -34,6 +34,7 @@
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Properties;
/**
@@ -303,6 +304,32 @@
SpecialCharacters sc2 = (SpecialCharacters)xstream.fromXML(json);
assertEquals(json, xstream.toXML(sc2));
}
+
+ public void testProperties()
+ {
+ Properties properties = new Properties();
+ properties.setProperty("key.1", "Value 1");
+ String json = xstream.toXML(properties);
+ assertEquals("{'properties':[{'property':{'@name':'key.1','@value':'Value 1'}}]}".replace('\'', '"'), json);
+ Properties properties2 = (Properties)xstream.fromXML(json);
+ assertEquals(json, xstream.toXML(properties2));
+
+ properties.setProperty("key.2", "Value 2");
+ json = xstream.toXML(properties);
+ assertEquals("{'properties':[{'property':[{'@name':'key.2','@value':'Value 2'},{'@name':'key.1','@value':'Value 1'}]}]}".replace('\'', '"'), json);
+ properties2 = (Properties)xstream.fromXML(json);
+ assertEquals(json, xstream.toXML(properties2));
+ }
+
+ public void testEmptyArray()
+ {
+ xstream.alias("exception", Exception.class);
+ Exception[] exceptions = new Exception[3];
+ String json = xstream.toXML(exceptions);
+ assertEquals("{'exception-array':[{'null':['','','']}]}".replace('\'', '"'), json);
+ Exception[] exceptions2 = (Exception[])xstream.fromXML(json);
+ assertEquals(json, xstream.toXML(exceptions2));
+ }
public void todoTestCanMarshalEmbeddedExternalizable() {
xstream.alias("owner", OwnerOfExternalizable.class);
To unsubscribe from this list please visit:
