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.view.facelets.tag.composite.localized;
20  
21  import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
22  import org.apache.myfaces.mc.test.core.annotation.DeclareFacesConfig;
23  import org.junit.Assert;
24  import org.junit.Test;
25  
26  /**
27   * Check if a composite component can be localized following the rules
28   * of JSF 2.0 Resource Handler API that are used for css, javascript
29   * and other resources.
30   * 
31   * @author Leonardo Uribe
32   *
33   */
34  @DeclareFacesConfig("/faces-config.xml")
35  public class LocalizedCompositeComponentTestCase extends AbstractMyFacesRequestTestCase
36  {
37      // This is a nice example that shows how AbstractMyFacesRequestTestCase 
38      // could be be useful.
39      // This test requires the default ResourceHandler algorithm and involves
40      // create multiple views. So, for this test use FaceletTestCase just does
41      // not fit well and it is more easy to use a test case than setup and
42      // teardown all MyFaces container. 
43      
44      @Test
45      public void testNoLocaleCompositeComponent() throws Exception
46      {
47          setupRequest("/testNoLocalizedComposite.xhtml");
48          processLifecycleExecuteAndRender();
49          Assert.assertTrue(getRenderedContent().contains(
50                  "English page fragment"));
51          tearDownRequest();
52      }
53      
54      @Test
55      public void testSpanishLocaleCompositeComponent() throws Exception
56      {
57          setupRequest("/testSpanishLocalizedComposite.xhtml");
58          processLifecycleExecuteAndRender();
59          Assert.assertTrue(getRenderedContent().contains(
60                  "Fragmento de pagina Espanol"));
61          tearDownRequest();
62      }
63      
64      @Test
65      public void testGermanLocaleCompositeComponent() throws Exception
66      {
67          setupRequest("/testGermanLocalizedComposite.xhtml");
68          processLifecycleExecuteAndRender();
69          Assert.assertTrue(getRenderedContent().contains(
70                  "Deutsches Seitenfragment"));
71          tearDownRequest();
72      }
73  }