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.core.output;
20  
21  import java.io.IOException;
22  
23  import junit.framework.Test;
24  import junit.framework.TestSuite;
25  
26  import org.apache.myfaces.trinidad.component.UIComponentTestCase;
27  
28  /**
29   * Unit tests for CoreOutputText.
30   *
31   */
32  public class CoreOutputTextTest extends UIComponentTestCase
33  {
34    /**
35     * Creates a new CoreOutputTextTest.
36     *
37     * @param testName  the unit test name
38     */
39    public CoreOutputTextTest(
40      String testName)
41    {
42      super(testName);
43    }
44    
45    @Override
46    protected void setUp() throws Exception
47    {
48      super.setUp();
49    }
50    
51    @Override
52    protected void tearDown() throws Exception
53    {
54      super.tearDown();
55    }
56    
57    public static Test suite()
58    {
59      return new TestSuite(CoreOutputTextTest.class);
60    }
61  
62    /**
63     * Tests the initial values for the component attributes.
64     * @todo deal with accessKey attr
65     */
66    public void testInitialAttributeValues()
67    {
68      CoreOutputText component = new CoreOutputText();
69      assertEquals(true, component.isRendered());
70      assertNull(component.getDescription());
71      assertNull(component.getValue());
72      assertEquals(0, component.getTruncateAt());
73  
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     * @todo deal with accessKey, truncateAt attr
81     */
82    public void testAttributeTransparency()
83    {
84      CoreOutputText component = new CoreOutputText();
85  
86      doTestAttributeTransparency(component, "rendered",
87                                  Boolean.TRUE, Boolean.FALSE);
88      doTestAttributeTransparency(component, "value",
89                                  "foo", "bar");
90      doTestAttributeTransparency(component, "description",
91                                  "foo", "bar");
92    }
93  
94    /**
95     * Tests the transparency of the component facets by comparing
96     * bean accessor and mutator methods with facet map accessor
97     * and mutator methods.
98     */
99    public void testFacetTransparency()
100   {
101     // no facets yet
102   }
103 
104   /**
105    * Tests the apply-request-values lifecycle phase.
106    */
107   public void testApplyRequestValues()
108   {
109     CoreOutputText component = new CoreOutputText();
110     // we don't use renderers for decode for this component:
111     // Or, we didn't.  But see ADFFACES-42
112     //    setRendererUsed(false);
113     doTestApplyRequestValues(component);
114     // setRendererUsed(true);
115 
116     component = new CoreOutputText();
117     component.setRendered(false);
118     doTestApplyRequestValues(component);
119   }
120 
121   /**
122    * Tests the process-validations lifecycle phase.
123    */
124   public void testProcessValidations()
125   {
126     CoreOutputText component = new CoreOutputText();
127     doTestProcessValidations(component);
128   }
129 
130   /**
131    * Tests the update-model-values lifecycle phase.
132    */
133   public void testUpdateModelValues()
134   {
135     CoreOutputText component = new CoreOutputText();
136     doTestUpdateModelValues(component);
137   }
138 
139   /**
140    * Tests the invoke-application lifecycle phase.
141    */
142   public void testInvokeApplication()
143   {
144     CoreOutputText component = new CoreOutputText();
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     CoreOutputText component = new CoreOutputText();
156     doTestRenderResponse(component);
157   }
158 }