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  
22  import junit.framework.Test;
23  import junit.framework.TestSuite;
24  
25  import org.apache.shale.test.base.AbstractJsfTestCase;
26  
27  /***
28   * <p>Test case for <code>Messages</code>.</p>
29   */
30  public class MessagesTestCase extends AbstractJsfTestCase {
31      
32  
33      // ------------------------------------------------------------ Constructors
34  
35  
36      // Construct a new instance of this test case.
37      public MessagesTestCase(String name) {
38          super(name);
39      }
40  
41  
42      // ---------------------------------------------------- Overall Test Methods
43  
44  
45      // Set up instance variables required by this test case.
46      protected void setUp() throws Exception {
47  
48          super.setUp();
49  
50          // Set up the instance we will be testing
51          m = new Messages("org.apache.shale.util.TestBundle");
52  
53      }
54  
55  
56      // Return the tests included in this test case.
57      public static Test suite() {
58  
59          return (new TestSuite(MessagesTestCase.class));
60  
61      }
62  
63  
64      // Tear down instance variables required by this test case.
65      protected void tearDown() throws Exception {
66  
67          m = null;
68          super.tearDown();
69  
70      }
71  
72  
73      // ------------------------------------------------------ Instance Variables
74  
75  
76      // The instance to be tested
77      Messages m = null;
78  
79  
80      // ------------------------------------------------------------ Test Methods
81  
82  
83      // Test access to the English values for this resource bundle
84      public void testEngish() {
85  
86          Locale l = new Locale("en", "US");
87          assertEquals("English Key 1", m.getMessage("key1", l));
88          assertEquals("English Key 2", m.getMessage("key2", l));
89  
90      }
91  
92  
93      // Test access to the French values for this resource bundle
94      public void testFrench() {
95  
96          Locale l = new Locale("fr", "FR");
97          assertEquals("French Key 1", m.getMessage("key1", l));
98          assertEquals("French Key 2", m.getMessage("key2", l));
99  
100     }
101 
102 
103     // Test a pristine instance
104     public void testPristine() {
105 
106         assertEquals("org.apache.shale.util.TestBundle", m.getName());
107 
108     }
109 
110 
111 }