KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cintoo > messages > context > TestMixedContexts


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

16 package cintoo.messages.context;
17
18 import cintoo.messages.bundle.DefaultBundleManager;
19
20 import java.util.Locale JavaDoc;
21 import java.util.ResourceBundle JavaDoc;
22
23 import org.testng.annotations.*;
24 import org.testng.Assert;
25
26 public class TestMixedContexts {
27     private DefaultBundleManager manager;
28     private Locale JavaDoc de_locale;
29
30   @Configuration(beforeTestMethod = true)
31   public void setUp() {
32         manager = new DefaultBundleManager(new DefaultContextCache());
33         de_locale = new Locale JavaDoc("de", "de");
34     }
35
36   @Test
37   public void testTwoDifferentContexts() {
38         manager.setBundle("testp1", PackageContext.string("t1"));
39         manager.setBundle("testp2", IdContext.id("t2"));
40
41         ResourceBundle JavaDoc bundle = manager.getBundle(PackageContext.string("t1"), de_locale);
42         Assert.assertEquals(bundle.getString("testKey1"), "testValue1", "Returns correct bundle for package context t1");
43
44         bundle = manager.getBundle(IdContext.id("t2"), de_locale);
45         Assert.assertEquals(bundle.getString("testKey2"), "testValue2", "Returns correct bundle for id context t2");
46     }
47 }
48
Popular Tags