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.UIComponentBase;
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  import org.jmock.Mock;
32  
33  /**
34   * Unit tests for UIXProcess
35   *
36   */
37  public class UIXProcessTest extends UIComponentTestCase
38  {
39    /**
40     * Creates a new UIXProcessTest.
41     *
42     * @param testName  the unit test name
43     */
44    public UIXProcessTest(
45      String testName)
46    {
47      super(testName);
48    }
49    
50    @Override
51    protected void setUp() throws Exception
52    {
53      super.setUp();
54    }
55    
56    @Override
57    protected void tearDown() throws Exception
58    {
59      super.tearDown();
60    }
61    
62    public static Test suite()
63    {
64      return new TestSuite(UIXProcessTest.class);
65    }
66  
67    public static void main(String[] args)
68    {
69      TestRunner.run(UIXProcessTest.class);
70    }
71    
72    /**
73     * Tests the initial values for the component attributes.
74     */
75    public void testInitialAttributeValues()
76    {
77      UIXProcess component = new UIXProcess();
78      assertEquals(true, component.isRendered());
79    }
80  
81    /**
82     * Tests the transparency of the component attribute by comparing
83     * bean accessor and mutator methods with attribute map accessor
84     * and mutator methods.
85     */
86    public void testAttributeTransparency()
87    {
88      UIXProcess component = new UIXProcess();
89  
90      doTestAttributeTransparency(component, "rendered",
91                                  Boolean.TRUE, Boolean.FALSE);
92  
93    }
94  
95  
96  
97  
98    /**
99     * Tests the process-validations lifecycle phase.
100    */
101   public void testProcessValidations()
102   {
103     UIXProcess component = new UIXProcess();
104     doTestProcessValidations(component);
105   }
106 
107   /**
108    * Tests the apply-request-values lifecycle phase.
109    */
110   public void testApplyRequestValues()
111   {
112     UIXProcess component = new UIXProcess();
113     doTestApplyRequestValues(component);
114 
115     component = new UIXProcess();
116     component.setRendered(false);
117     doTestApplyRequestValues(component);
118   }
119 
120   /**
121    * Tests the update-model-values lifecycle phase.
122    */
123   public void testUpdateModelValues()
124   {
125     UIXProcess component = new UIXProcess();
126     doTestUpdateModelValues(component);
127   }
128 
129 
130   /**
131    * Tests the render-response lifecycle phase.
132    *
133    * @throws IOException  when test fails
134    */
135   public void testRenderResponse() throws IOException
136   {
137     UIXProcess component = new UIXProcess();
138     doTestRenderResponse(component);
139   }
140   
141   protected Mock createMockUIComponent()
142   {
143     // the UIXProcess is allowed to call getId and setId on its child
144     Mock mock = super.createMockUIComponent();
145     
146     mock.stubs().method("getId");
147     mock.stubs().method("setId");
148         
149     return mock;
150   }
151 
152 }