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