View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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  import java.util.ArrayList;
27  import java.util.List;
28  
29  import junit.framework.TestCase;
30  
31  public class _AttachedListStateWrapperTest extends TestCase {
32  
33    public static void main(String[] args) {
34      junit.textui.TestRunner.run(_AttachedListStateWrapperTest.class);
35    }
36  
37    public _AttachedListStateWrapperTest(String name) {
38      super(name);
39    }
40  
41    protected void setUp() throws Exception {
42      super.setUp();
43    }
44  
45    protected void tearDown() throws Exception {
46      super.tearDown();
47    }
48  
49    /*
50     * Test method for 'javax.faces.component._AttachedListStateWrapper._AttachedListStateWrapper(List)'
51     */
52    public void test_AttachedListStateWrapper() {
53      List foo = new ArrayList();
54      _AttachedListStateWrapper subject = new _AttachedListStateWrapper(foo);
55      assertNotNull(subject.getWrappedStateList());
56      assertTrue(subject.getWrappedStateList() == foo);
57    }
58  
59    public void testSerialize() throws Exception {
60      String foo = "foo";
61      List list = new ArrayList();
62      list.add(foo);
63      _AttachedListStateWrapper subject = new _AttachedListStateWrapper(list);
64      ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
65      ObjectOutputStream oos = new ObjectOutputStream(baos);
66      oos.writeObject(subject);
67      oos.flush();
68      baos.flush();
69      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
70      ObjectInputStream ois = new ObjectInputStream(bais);
71      _AttachedListStateWrapper blorg = (_AttachedListStateWrapper)ois.readObject();
72      assertEquals(blorg.getWrappedStateList(), subject.getWrappedStateList());
73      oos.close();
74      ois.close();
75    }
76    
77  }