2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shale.util;
19  
20  import java.util.Locale;
21  import java.util.Map;
22  
23  import javax.faces.context.FacesContext;
24  
25  import junit.framework.Test;
26  import junit.framework.TestSuite;
27  
28  import org.apache.shale.test.base.AbstractJsfTestCase;
29  
30  /***
31   * <p>Test case for <code>LoadBundle</code>.</p>
32   */
33  public class LoadBundleTestCase extends AbstractJsfTestCase {
34      
35  
36      // ------------------------------------------------------------ Constructors
37  
38  
39      // Construct a new instance of this test case.
40      public LoadBundleTestCase(String name) {
41          super(name);
42      }
43  
44  
45      // ---------------------------------------------------- Overall Test Methods
46  
47  
48      // Set up instance variables required by this test case.
49      protected void setUp() throws Exception {
50  
51          super.setUp();
52  
53          // Set up the instance we will be testing
54          lb = new LoadBundle("org.apache.shale.util.TestBundle");
55  
56      }
57  
58  
59      // Return the tests included in this test case.
60      public static Test suite() {
61  
62          return (new TestSuite(LoadBundleTestCase.class));
63  
64      }
65  
66  
67      // Tear down instance variables required by this test case.
68      protected void tearDown() throws Exception {
69  
70          lb = null;
71          super.tearDown();
72  
73      }
74  
75  
76      // ------------------------------------------------------ Instance Variables
77  
78  
79      // The instance to be tested
80      LoadBundle lb = null;
81  
82  
83      // ------------------------------------------------------------ Test Methods
84  
85  
86      // Test access to the English values for this resource bundle
87      public void testEngish() {
88  
89          FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("en", "US"));
90          Map map = lb.getMap();
91          assertNotNull(map);
92          assertEquals("English Key 1", map.get("key1"));
93          assertEquals("English Key 2", map.get("key2"));
94  
95      }
96  
97  
98      // Test access to the French values for this resource bundle
99      public void testFrench() {
100 
101         FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("fr", "FR"));
102         Map map = lb.getMap();
103         assertNotNull(map);
104         assertEquals("French Key 1", map.get("key1"));
105         assertEquals("French Key 2", map.get("key2"));
106 
107     }
108 
109 
110     // Test a pristine instance
111     public void testPristine() {
112 
113         assertEquals("org.apache.shale.util.TestBundle", lb.getBasename());
114 
115     }
116 
117 
118 }