1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package javax.faces.component;
21
22 import java.io.ByteArrayInputStream;
23 import java.io.ByteArrayOutputStream;
24 import java.io.ObjectInputStream;
25 import java.io.ObjectOutputStream;
26
27 import junit.framework.TestCase;
28
29 public class _AttachedStateWrapperTest extends TestCase {
30
31 public static void main(String[] args) {
32 junit.textui.TestRunner.run(_AttachedStateWrapperTest.class);
33 }
34
35 public _AttachedStateWrapperTest(String name) {
36 super(name);
37 }
38
39 protected void setUp() throws Exception {
40 super.setUp();
41 }
42
43 protected void tearDown() throws Exception {
44 super.tearDown();
45 }
46
47
48
49
50 public void test_AttachedStateWrapper() {
51 _AttachedStateWrapper subject = new _AttachedStateWrapper(null, null);
52 assertNull(subject.getWrappedStateObject());
53 assertNull(subject.getClazz());
54 }
55
56
57
58
59 public void testGetClazz() {
60 _AttachedStateWrapper subject = new _AttachedStateWrapper(String.class, "foo");
61 assertEquals(subject.getClazz(), String.class);
62 }
63
64
65
66
67 public void testGetWrappedStateObject() {
68 _AttachedStateWrapper subject = new _AttachedStateWrapper(String.class, "foo");
69 assertEquals(subject.getClazz(), String.class);
70 }
71
72 public void testSerialize() throws Exception {
73 String foo = "foo";
74 _AttachedStateWrapper subject = new _AttachedStateWrapper(String.class, foo);
75 ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
76 ObjectOutputStream oos = new ObjectOutputStream(baos);
77 oos.writeObject(subject);
78 oos.flush();
79 baos.flush();
80 ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
81 ObjectInputStream ois = new ObjectInputStream(bais);
82 _AttachedStateWrapper blorg = (_AttachedStateWrapper) ois
83 .readObject();
84 assertEquals(blorg.getWrappedStateObject(), subject.getWrappedStateObject());
85 oos.close();
86 ois.close();
87 }
88 }