Log Message
Fix unit tests testing JVM specific features.
Modified Paths
Diff
Modified: trunk/xstream/src/test/com/thoughtworks/acceptance/TreeMapAndTreeSetTest.java (2099 => 2100)
--- trunk/xstream/src/test/com/thoughtworks/acceptance/TreeMapAndTreeSetTest.java 2013-07-12 20:22:08 UTC (rev 2099)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/TreeMapAndTreeSetTest.java 2013-07-18 22:23:36 UTC (rev 2100)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2005 Joe Walnes.
- * Copyright (C) 2006, 2007, 2010, 2011 XStream Committers.
+ * Copyright (C) 2006, 2007, 2010, 2011, 2013 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -17,6 +17,8 @@
import java.util.TreeMap;
import java.util.TreeSet;
+import com.thoughtworks.xstream.core.JVM;
+
public class TreeMapAndTreeSetTest extends AbstractAcceptanceTest {
public static class MyComparator implements Comparator {
@@ -106,32 +108,34 @@
}
public void testTreeMapDoesNotUseComparatorAtDeserialization() {
- TreeMap map = new TreeMap(new UnusedComparator());
- map.put("john", "doe");
- map.put("benny", "hill");
- map.put("joe", "walnes");
-
- String expected = "" +
- "<tree-map>\n" +
- " <comparator class=\"unused-comparator\"/>\n" +
- " <entry>\n" +
- " <string>benny</string>\n" +
- " <string>hill</string>\n" +
- " </entry>\n" +
- " <entry>\n" +
- " <string>joe</string>\n" +
- " <string>walnes</string>\n" +
- " </entry>\n" +
- " <entry>\n" +
- " <string>john</string>\n" +
- " <string>doe</string>\n" +
- " </entry>\n" +
- "</tree-map>";
-
- assertEquals(expected, xstream.toXML(map));
- TreeMap result = (TreeMap) xstream.fromXML(expected);
- assertSame(UnusedComparator.THROWING_COMPARATOR, result.comparator());
- assertEquals(new ArrayList(map.entrySet()), new ArrayList(result.entrySet()));
+ if (JVM.hasOptimizedTreeMapPutAll()) {
+ TreeMap map = new TreeMap(new UnusedComparator());
+ map.put("john", "doe");
+ map.put("benny", "hill");
+ map.put("joe", "walnes");
+
+ String expected = "" +
+ "<tree-map>\n" +
+ " <comparator class=\"unused-comparator\"/>\n" +
+ " <entry>\n" +
+ " <string>benny</string>\n" +
+ " <string>hill</string>\n" +
+ " </entry>\n" +
+ " <entry>\n" +
+ " <string>joe</string>\n" +
+ " <string>walnes</string>\n" +
+ " </entry>\n" +
+ " <entry>\n" +
+ " <string>john</string>\n" +
+ " <string>doe</string>\n" +
+ " </entry>\n" +
+ "</tree-map>";
+
+ assertEquals(expected, xstream.toXML(map));
+ TreeMap result = (TreeMap) xstream.fromXML(expected);
+ assertSame(UnusedComparator.THROWING_COMPARATOR, result.comparator());
+ assertEquals(new ArrayList(map.entrySet()), new ArrayList(result.entrySet()));
+ }
}
public void testTreeSetWithComparator() {
@@ -176,22 +180,24 @@
}
public void testTreeSetDoesNotUseComparatorAtDeserialization() {
- TreeSet set = new TreeSet(new UnusedComparator());
- set.add("guy");
- set.add("hi");
- set.add("bye");
-
- String expected = "" +
- "<sorted-set>\n" +
- " <comparator class=\"unused-comparator\"/>\n" +
- " <string>bye</string>\n" +
- " <string>guy</string>\n" +
- " <string>hi</string>\n" +
- "</sorted-set>";
-
- assertEquals(expected, xstream.toXML(set));
- TreeSet result = (TreeSet) xstream.fromXML(expected);
- assertSame(UnusedComparator.THROWING_COMPARATOR, result.comparator());
- assertEquals(new ArrayList(set), new ArrayList(result));
+ if (JVM.hasOptimizedTreeSetAddAll()) {
+ TreeSet set = new TreeSet(new UnusedComparator());
+ set.add("guy");
+ set.add("hi");
+ set.add("bye");
+
+ String expected = "" +
+ "<sorted-set>\n" +
+ " <comparator class=\"unused-comparator\"/>\n" +
+ " <string>bye</string>\n" +
+ " <string>guy</string>\n" +
+ " <string>hi</string>\n" +
+ "</sorted-set>";
+
+ assertEquals(expected, xstream.toXML(set));
+ TreeSet result = (TreeSet) xstream.fromXML(expected);
+ assertSame(UnusedComparator.THROWING_COMPARATOR, result.comparator());
+ assertEquals(new ArrayList(set), new ArrayList(result));
+ }
}
}
To unsubscribe from this list please visit:
