KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > TestMessageFinder


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.impl;
16
17 import java.util.Locale JavaDoc;
18
19 import org.apache.hivemind.internal.MessageFinder;
20 import org.apache.hivemind.test.HiveMindTestCase;
21 import org.apache.hivemind.util.ClasspathResource;
22
23 /**
24  * @author Howard M. Lewis Ship
25  */

26 public class TestMessageFinder extends HiveMindTestCase
27 {
28     private MessageFinder newFinder()
29     {
30         ClasspathResource r = new ClasspathResource(getClassResolver(),
31                 "org/apache/hivemind/impl/MessageFinder.xml");
32
33         return new MessageFinderImpl(r);
34     }
35
36     public void testLocaleOverridesBase()
37     {
38         MessageFinder mf = newFinder();
39
40         assertEquals("MessageFinder_fr.overriden-in-base", mf.getMessage(
41                 "overridden-in-base",
42                 Locale.FRENCH));
43
44         // FRANCE is more detailed than FRENCH
45
// Also, there is no MessageFinder_fr_FR.properties file,
46
// and that's ok.
47

48         assertEquals("MessageFinder_fr.overriden-in-base", mf.getMessage(
49                 "overridden-in-base",
50                 Locale.FRANCE));
51     }
52
53     public void testLocaleDoeNotObscureBase()
54     {
55         MessageFinder mf = newFinder();
56
57         assertEquals("MessageFinder.only-in-properties", mf.getMessage(
58                 "only-in-base",
59                 Locale.FRENCH));
60     }
61 }
Popular Tags