forked from vbuell/python-javaobj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionsTest.java
More file actions
57 lines (47 loc) · 1.49 KB
/
CollectionsTest.java
File metadata and controls
57 lines (47 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.junit.Test;
class CollectionsSerializableBean implements Serializable {
// Collections
public Collection<String> arrayList;
public Collection<String> linkedList;
public Map<String, Object> hashMap;
public Queue<String> queue;
public CollectionsSerializableBean()
{
super();
arrayList = new ArrayList<String>();
arrayList.add("e1");
arrayList.add("e2");
linkedList = new LinkedList<String>();
linkedList.add("ll1");
linkedList.add("ll2");
hashMap = new HashMap<String, Object>();
hashMap.put("k1", null);
hashMap.put("k2", "value2");
hashMap.put("k3", arrayList);
hashMap.put("k3", linkedList);
queue = new ConcurrentLinkedQueue<String>();
queue.add("q1");
queue.add("q2");
queue.add("q3");
}
}
public class CollectionsTest {
ObjectOutputStream oos;
FileOutputStream fos;
@Test
public void testCollections() throws Exception {
oos = new ObjectOutputStream(fos = new FileOutputStream("objCollections.ser"));
oos.writeObject(new CollectionsSerializableBean());
oos.flush();
}
}