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  package org.apache.myfaces.trinidad.component;
20  
21  import java.io.IOException;
22  
23  import javax.faces.component.UIComponent;
24  
25  import junit.framework.Test;
26  import junit.framework.TestSuite;
27  import junit.textui.TestRunner;
28  
29  import org.apache.myfaces.trinidad.component.UIComponentTestCase;
30  
31  /**
32   * Unit tests for UIXShowDetail.
33   *
34   */
35  public class UIXShowDetailTest extends UIComponentTestCase
36  {
37    /**
38     * Creates a new UIXShowDetailTest.
39     *
40     * @param testName  the unit test name
41     */
42    public UIXShowDetailTest(
43      String testName)
44    {
45      super(testName);
46    }
47    
48    @Override
49    protected void setUp() throws Exception
50    {
51      super.setUp();
52    }
53    
54    @Override
55    protected void tearDown() throws Exception
56    {
57      super.tearDown();
58    }
59    
60    public static Test suite()
61    {
62      return new TestSuite(UIXShowDetailTest.class);
63    }
64  
65    /**
66     * Tests the initial values for the component attributes.
67     */
68    public void testInitialAttributeValues()
69    {
70      UIXShowDetail hideShow = createHideShow();
71      assertEquals(false, hideShow.isDisclosed());
72      assertEquals(true, hideShow.isRendered());
73      assertEquals(false, hideShow.isImmediate());
74    }
75  
76    /**
77     * Tests the transparency of the component attribute by comparing
78     * bean accessor and mutator methods with attribute map accessor
79     * and mutator methods.
80     *
81     * @todo remaining attributes
82     */
83    public void testAttributeTransparency()
84    {
85      UIXShowDetail component = createHideShow();
86  
87      doTestAttributeTransparency(component, "rendered",
88                                  Boolean.TRUE, Boolean.FALSE);
89      // remaining attributes here
90    }
91  
92    /**
93     * Tests the apply-request-values lifecycle phase.
94     */
95    public void testApplyRequestValues()
96    {
97      doTestApplyRequestValues(createHideShow());
98      
99      UIXShowDetail disclosed = createHideShow();
100     disclosed.setDisclosed(true);
101     doTestApplyRequestValues(disclosed);
102 
103     disclosed = createHideShow();
104 
105     disclosed.setDisclosed(true);
106     disclosed.setRendered(false);
107     doTestApplyRequestValues(disclosed);
108 
109     disclosed = createHideShow();
110     disclosed.setDisclosed(false);
111     disclosed.setRendered(false);
112     doTestApplyRequestValues(disclosed);
113   }
114 
115 
116   /**
117    * Tests the process-validations lifecycle phase.
118    */
119   public void testProcessValidations()
120   {
121     doTestProcessValidations(createHideShow());
122     UIXShowDetail disclosed = createHideShow();
123     disclosed.setDisclosed(true);
124     doTestProcessValidations(disclosed);
125   }
126 
127   /**
128    * Tests the update-model-values lifecycle phase.
129    */
130   public void testUpdateModelValues()
131   {
132     doTestUpdateModelValues(createHideShow());
133     UIXShowDetail disclosed = createHideShow();
134     disclosed.setDisclosed(true);
135     doTestUpdateModelValues(disclosed);
136   }
137 
138   /**
139    * Tests the invoke-application lifecycle phase.
140    */
141   public void testInvokeApplication()
142   {
143     UIXShowDetail component = createHideShow();
144 
145     doTestInvokeApplication(component, null);
146   }
147 
148   /**
149    * Tests the render-response lifecycle phase.
150    *
151    * @throws IOException  when test fails
152    */
153   public void testRenderResponse() throws IOException
154   {
155     doTestRenderResponse(createHideShow());
156   }
157 
158   public static void main(String[] args)
159   {
160     TestRunner.run(UIXShowDetailTest.class);
161   }
162   
163   @Override
164   protected boolean willChildrenBeProcessed(UIComponent component)
165   {
166     if (!component.isRendered())
167       return false;
168 
169     return ((UIXShowDetail) component).isDisclosed();
170   }
171 
172   protected UIXShowDetail createHideShow()
173   {
174     return new UIXShowDetail();
175   }
176 
177 }