File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\test\java\hudson\util\PackedMapTest.java.html

1 package hudson.util;
2
3 import junit.framework.TestCase;
4
5 import java.util.Map;
6 import java.util.Map.Entry;
7 import java.util.TreeMap;
8
9 /**
10 * @author Kohsuke Kawaguchi
11 */
12 public class PackedMapTest extends TestCase {
13 static class Holder {
14 PackedMap pm;
15 }
16
17 private XStream2 xs = new XStream2();
18
19 public void testBasic() throws Exception {
20 Map<String,String> o = new TreeMap<String, String>();
21 o.put("a","b");
22 o.put("c","d");
23
24 PackedMap<String,String> p = PackedMap.of(o);
25 assertEquals("b",p.get("a"));
26 assertEquals("d", p.get("c"));
27 assertEquals(p.size(),2);
28 for (Entry<String,String> e : p.entrySet()) {
29 System.out.println(e.getKey()+'='+e.getValue());
30 }
31
32 Holder h = new Holder();
33 h.pm = p;
34 String xml = xs.toXML(h);
35 assertEquals(
36 "<hudson.util.PackedMapTest_-Holder>\n" +
37 " <pm>\n" +
38 " <entry>\n" +
39 " <string>a</string>\n" +
40 " <string>b</string>\n" +
41 " </entry>\n" +
42 " <entry>\n" +
43 " <string>c</string>\n" +
44 " <string>d</string>\n" +
45 " </entry>\n" +
46 " </pm>\n" +
47 "</hudson.util.PackedMapTest_-Holder>",
48 xml);
49
50 xs.fromXML(xml);
51 }
52 }
53