mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 21:12:15 +00:00
added more asserts, removed sysouts, generics
This commit is contained in:
1 parent
34b9d6b660
commit
5853b541fe
2 files changed
+19
-7
No files matched your search
@@ -118,11 +118,11 @@ public class XStream2Test extends TestCase {
|
||||
}
|
||||
|
||||
private static class ImmutableMapHolder {
|
||||
ImmutableMap m;
|
||||
ImmutableMap<?,?> m;
|
||||
}
|
||||
|
||||
private static class MapHolder {
|
||||
Map m;
|
||||
Map<?,?> m;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public class XStream2Test extends TestCase {
|
||||
ImmutableMapHolder a = new ImmutableMapHolder();
|
||||
a.m = m;
|
||||
String xml = xs.toXML(a);
|
||||
System.out.println(xml);
|
||||
//System.out.println(xml);
|
||||
assertFalse("shouldn't contain the class name",xml.contains("google"));
|
||||
assertFalse("shouldn't contain the class name",xml.contains("class"));
|
||||
a = (ImmutableMapHolder)xs.fromXML(xml);
|
||||
@@ -158,7 +158,7 @@ public class XStream2Test extends TestCase {
|
||||
MapHolder a = new MapHolder();
|
||||
a.m = m;
|
||||
String xml = xs.toXML(a);
|
||||
System.out.println(xml);
|
||||
//System.out.println(xml);
|
||||
assertTrue("XML should mention the class name",xml.contains('\"'+ImmutableMap.class.getName()+'\"'));
|
||||
a = (MapHolder)xs.fromXML(xml);
|
||||
|
||||
@@ -180,7 +180,7 @@ public class XStream2Test extends TestCase {
|
||||
assertEquals(1,pt.x);
|
||||
assertEquals(2,pt.y);
|
||||
String xml = xs.toXML(pt);
|
||||
System.out.println(xml);
|
||||
//System.out.println(xml);
|
||||
assertFalse("Shouldn't use the alias when writing back",xml.contains("legacy"));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class XStreamTest extends TestCase {
|
||||
|
||||
private XStream2 xstream = new XStream2();
|
||||
|
||||
public static class Foo {
|
||||
ConcurrentHashMap m = new ConcurrentHashMap();
|
||||
ConcurrentHashMap<String,String> m = new ConcurrentHashMap<String,String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that ConcurrentHashMap is serialized into a more compact format,
|
||||
* but still can deserialize to older, verbose format.
|
||||
*/
|
||||
public void testConcurrentHashMapSerialization() throws Exception {
|
||||
Foo foo = new Foo();
|
||||
foo.m.put("abc","def");
|
||||
@@ -49,13 +56,18 @@ public class XStreamTest extends TestCase {
|
||||
// should serialize like map
|
||||
String xml = FileUtils.readFileToString(v);
|
||||
assertFalse(xml.contains("java.util.concurrent"));
|
||||
System.out.println(xml);
|
||||
//System.out.println(xml);
|
||||
Foo deserialized = (Foo)xstream.fromXML(xml);
|
||||
assertEquals(2,deserialized.m.size());
|
||||
assertEquals("def", deserialized.m.get("abc"));
|
||||
assertEquals("jkl", deserialized.m.get("ghi"));
|
||||
} finally {
|
||||
v.delete();
|
||||
}
|
||||
|
||||
// should be able to read in old data just fine
|
||||
Foo map = (Foo)new XStream2().fromXML(getClass().getResourceAsStream("old-concurrentHashMap.xml"));
|
||||
assertEquals(1,map.m.size());
|
||||
assertEquals("def",map.m.get("abc"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user