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