01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 de.odysseus.calyxo.base;
17:
18: import javax.servlet.ServletContext;
19: import javax.servlet.ServletException;
20:
21: import de.odysseus.calyxo.base.test.TestI18nSupport;
22: import de.odysseus.calyxo.base.test.TestModuleGroup;
23: import de.odysseus.calyxo.base.test.TestModuleContext;
24: import de.odysseus.calyxo.base.test.TestPageContext;
25: import de.odysseus.calyxo.base.test.TestRequest;
26:
27: import junit.framework.TestCase;
28:
29: /**
30: *
31: * @author Christoph Beck
32: */
33: public class I18nSupportTest extends TestCase {
34:
35: private TestRequest request;
36: private TestModuleContext module;
37:
38: /**
39: * Constructor for I18nSupportTest.
40: * @param arg0
41: */
42: public I18nSupportTest(String arg0) {
43: super (arg0);
44: }
45:
46: protected void setUp() throws ServletException {
47: request = new TestRequest();
48: ServletContext context = request.getSession()
49: .getServletContext();
50: // configure test module
51: module = new TestModuleContext("test", context);
52: // configure module container
53: TestModuleGroup group = TestModuleGroup.getInstance(context);
54: group.add(module);
55: // select module
56: group.setTestModuleContext(request, module);
57: }
58:
59: public void testGetInstance() {
60: I18nSupport support = new TestI18nSupport();
61: module.setAttribute(I18nSupport.I18N_SUPPORT_KEY, support);
62:
63: assertSame(support, I18nSupport.getInstance(module));
64: assertSame(support, I18nSupport.getInstance(request));
65: assertSame(support, I18nSupport
66: .getInstance(new TestPageContext(request)));
67: }
68:
69: public static void main(String[] args) {
70: junit.textui.TestRunner.run(I18nSupportTest.class);
71: }
72:
73: }
|