Log Message
Add test fixture for referenced implicit elements.
Modified Paths
- trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitArrayTest.java
- trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitCollectionTest.java
- trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitMapTest.java
Diff
Modified: trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitArrayTest.java (2210 => 2211)
--- trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitArrayTest.java 2014-01-09 19:03:16 UTC (rev 2210)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitArrayTest.java 2014-01-11 14:45:43 UTC (rev 2211)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013, 2014 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -67,7 +67,36 @@
xstream.addImplicitArray(Farm.class, "animals");
assertBothWays(farm, expected);
}
+
+ public void testWithReferencedImplicitElement() {
+ List list = new ArrayList();
+ Farm farm = new Farm();
+ farm.animals = new Animal[] {
+ new Animal("Cow"),
+ new Animal("Sheep")
+ };
+ list.add(farm.animals[0]);
+ list.add(farm);
+ list.add(farm.animals[1]);
+ String expected = "" +
+ "<list>\n" +
+ " <animal>\n" +
+ " <name>Cow</name>\n" +
+ " </animal>\n" +
+ " <farm>\n" +
+ " <animal reference=\"../../animal\"/>\n" +
+ " <animal>\n" +
+ " <name>Sheep</name>\n" +
+ " </animal>\n" +
+ " </farm>\n" +
+ " <animal reference=\"../farm/animal[2]\"/>\n" +
+ "</list>";
+
+ xstream.addImplicitArray(Farm.class, "animals");
+ assertBothWays(list, expected);
+ }
+
public static class MegaFarm extends Farm {
String separator = "---";
String[] names;
Modified: trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitCollectionTest.java (2210 => 2211)
--- trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitCollectionTest.java 2014-01-09 19:03:16 UTC (rev 2210)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitCollectionTest.java 2014-01-11 14:45:43 UTC (rev 2211)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004, 2005 Joe Walnes.
- * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -101,6 +101,36 @@
assertBothWays(farm, expected);
}
+ public void testWithReferencedImplicitElement() {
+ List list = new ArrayList();
+ Animal cow = new Animal("Cow");
+ Animal sheep = new Animal("Sheep");
+ Farm farm = new Farm(100);
+ farm.add(cow);
+ farm.add(sheep);
+ list.add(cow);
+ list.add(farm);
+ list.add(sheep);
+
+ String expected = "" +
+ "<list>\n" +
+ " <animal>\n" +
+ " <name>Cow</name>\n" +
+ " </animal>\n" +
+ " <farm>\n" +
+ " <size>100</size>\n" +
+ " <animal reference=\"../../animal\"/>\n" +
+ " <animal>\n" +
+ " <name>Sheep</name>\n" +
+ " </animal>\n" +
+ " </farm>\n" +
+ " <animal reference=\"../farm/animal[2]\"/>\n" +
+ "</list>";
+
+ xstream.addImplicitCollection(Farm.class, "animals");
+ assertBothWays(list, expected);
+ }
+
public static class MegaFarm extends Farm {
String separator = "---";
List names;
Modified: trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitMapTest.java (2210 => 2211)
--- trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitMapTest.java 2014-01-09 19:03:16 UTC (rev 2210)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/ImplicitMapTest.java 2014-01-11 14:45:43 UTC (rev 2211)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013, 2014 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -119,6 +119,37 @@
assertBothWays(sample, expected);
}
+ public void testWithReferencedImplicitElement() {
+ List list = new ArrayList();
+ SampleMaps sample = new SampleMaps();
+ sample.good = new OrderRetainingMap();
+ sample.good.put("Windows", new Software("Microsoft", "Windows"));
+ sample.good.put("Linux", new Software("Red Hat", "Linux"));
+ list.add(sample.good.get("Windows"));
+ list.add(sample);
+ list.add(sample.good.get("Linux"));
+
+ String expected = "" +
+ "<list>\n" +
+ " <software>\n" +
+ " <vendor>Microsoft</vendor>\n" +
+ " <name>Windows</name>\n" +
+ " </software>\n" +
+ " <sample>\n" +
+ " <software reference=\"../../software\"/>\n" +
+ " <software>\n" +
+ " <vendor>Red Hat</vendor>\n" +
+ " <name>Linux</name>\n" +
+ " </software>\n" +
+ " <bad/>\n" +
+ " </sample>\n" +
+ " <software reference=\"../sample/software[2]\"/>\n" +
+ "</list>";
+
+ xstream.addImplicitMap(SampleMaps.class, "good", Software.class, "name");
+ assertBothWays(list, expected);
+ }
+
public static class MegaSampleMaps extends SampleMaps {
String separator = "---";
Map other = new OrderRetainingMap();
To unsubscribe from this list please visit:
