1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.yaml.snakeyaml.issues.issue73;
17
18 import java.util.TreeSet;
19
20 import junit.framework.TestCase;
21
22 import org.yaml.snakeyaml.Yaml;
23
24
25
26
27
28 public class TreeSetTest extends TestCase {
29 public void testSetImplementation() {
30 Bean1 bean = new Bean1();
31 bean.setId("ID123");
32 TreeSet<String> list = new TreeSet<String>();
33 list.add("zzz");
34 list.add("xxx");
35 list.add("ccc");
36 bean.setSet(list);
37 Yaml yaml = new Yaml();
38 String doc = yaml.dump(bean);
39
40
41 Bean1 loaded = (Bean1) yaml.load(doc);
42 assertEquals(3, loaded.getSet().size());
43 assertEquals(TreeSet.class, loaded.getSet().getClass());
44 assertTrue(loaded.getSet().contains("zzz"));
45 assertTrue(loaded.getSet().contains("xxx"));
46 assertTrue(loaded.getSet().contains("ccc"));
47 }
48
49 public static class Bean1 {
50 private TreeSet<String> set;
51 private String id;
52
53 public TreeSet<String> getSet() {
54 return set;
55 }
56
57 public void setSet(TreeSet<String> set) {
58 this.set = set;
59 }
60
61 public String getId() {
62 return id;
63 }
64
65 public void setId(String id) {
66 this.id = id;
67 }
68 }
69 }