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.ArrayList;
20
21 import junit.framework.TestCase;
22
23 import org.yaml.snakeyaml.Yaml;
24
25
26
27
28
29 public class ArrayListTest extends TestCase {
30 public void testListImplementation() {
31 Bean1 bean = new Bean1();
32 bean.setId("ID123");
33 ArrayList<String> list = new ArrayList<String>(3);
34 list.add("zzz");
35 list.add("xxx");
36 list.add("ccc");
37 bean.setList(list);
38 Yaml yaml = new Yaml();
39 String doc = yaml.dump(bean);
40
41 Bean1 loaded = (Bean1) yaml.load(doc);
42 assertEquals(3, loaded.getList().size());
43 assertEquals(ArrayList.class, loaded.getList().getClass());
44 }
45
46 public static class Bean1 {
47 private ArrayList<String> list;
48 private String id;
49
50 public ArrayList<String> getList() {
51 return list;
52 }
53
54 public void setList(ArrayList<String> list) {
55 this.list = list;
56 }
57
58 public String getId() {
59 return id;
60 }
61
62 public void setId(String id) {
63 this.id = id;
64 }
65 }
66 }