Log Message
Use configured Jettison SimpleConverter for test.
Modified Paths
Diff
Modified: trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java (2117 => 2118)
--- trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java 2013-09-17 19:46:24 UTC (rev 2117)
+++ trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java 2013-09-17 21:52:21 UTC (rev 2118)
@@ -28,6 +28,8 @@
import java.io.ObjectOutputStream;
import java.io.StringReader;
import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
@@ -78,27 +80,27 @@
assertEquals(SIMPLE, result);
}
- public void testReadConfigured() {
- Configuration config = new Configuration();
- // TODO: Configure something useful (see XSTR-540)
- xstream = new XStream(new JettisonMappedXmlDriver(config));
- xstream.alias("product", Product.class);
- Product product = (Product)xstream.fromXML(SIMPLE);
- assertEquals(product.getName(), "Banana");
- assertEquals(product.getId(), "123");
- assertEquals("" + product.getPrice(), "" + 23.00);
+ public void testJettisonConfigured()
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException,
+ NoSuchMethodException, InvocationTargetException {
+ if (JVM.is15()) {
+ Object typeConverter = Class.class.forName(
+ "org.codehaus.jettison.mapped.SimpleConverter").newInstance();
+ Method setTypeConverter = Configuration.class.getMethod(
+ "setTypeConverter", new Class[]{typeConverter.getClass().getInterfaces()[0]});
+ Configuration config = new Configuration();
+ setTypeConverter.invoke(config, typeConverter);
+ xstream = new XStream(new JettisonMappedXmlDriver(config));
+ xstream.alias("product", Product.class);
+ Product product = new Product("Banana", "123", 23.00);
+ String result = xstream.toXML(product);
+ assertEquals(
+ "{'product':{'name':'Banana','id':'123','price':'23.0'}}".replace('\'', '"'),
+ result);
+ assertEquals(product, xstream.fromXML(result));
+ }
}
- public void testWriteConfigured() {
- Configuration config = new Configuration();
- // TODO: Configure something useful (see XSTR-540)
- xstream = new XStream(new JettisonMappedXmlDriver(config));
- xstream.alias("product", Product.class);
- Product product = new Product("Banana", "123", 23.00);
- String result = xstream.toXML(product);
- assertEquals(SIMPLE, result);
- }
-
public void testWriteHierarchy() {
Category category = new Category("fruit", "111");
ArrayList products = new ArrayList();
To unsubscribe from this list please visit:
