/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.base;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import de.odysseus.calyxo.base.test.TestI18nSupport;
import de.odysseus.calyxo.base.test.TestModuleGroup;
import de.odysseus.calyxo.base.test.TestModuleContext;
import de.odysseus.calyxo.base.test.TestPageContext;
import de.odysseus.calyxo.base.test.TestRequest;
import junit.framework.TestCase;
/**
*
* @author Christoph Beck
*/
public class I18nSupportTest extends TestCase {
private TestRequest request;
private TestModuleContext module;
/**
* Constructor for I18nSupportTest.
* @param arg0
*/
public I18nSupportTest(String arg0) {
super(arg0);
}
protected void setUp() throws ServletException {
request = new TestRequest();
ServletContext context = request.getSession().getServletContext();
// configure test module
module = new TestModuleContext("test", context);
// configure module container
TestModuleGroup group = TestModuleGroup.getInstance(context);
group.add(module);
// select module
group.setTestModuleContext(request, module);
}
public void testGetInstance() {
I18nSupport support = new TestI18nSupport();
module.setAttribute(I18nSupport.I18N_SUPPORT_KEY, support);
assertSame(support, I18nSupport.getInstance(module));
assertSame(support, I18nSupport.getInstance(request));
assertSame(support, I18nSupport.getInstance(new TestPageContext(request)));
}
public static void main(String[] args) {
junit.textui.TestRunner.run(I18nSupportTest.class);
}
}