/*
* 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.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 ModuleSupportTest extends TestCase {
private TestRequest request;
private ModuleSupport support;
private TestModuleContext module;
/**
* Constructor for I18nSupportTest.
* @param arg0
*/
public ModuleSupportTest(String arg0) {
super(arg0);
}
protected void setUp() throws ServletException {
request = new TestRequest();
ServletContext context = request.getSession().getServletContext();
// set support instance
context.setAttribute(ModuleSupport.MODULE_SUPPORT_KEY, support = new ModuleSupport());
// 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() {
assertSame(support, ModuleSupport.getInstance(request));
assertSame(support, ModuleSupport.getInstance(new TestPageContext(request)));
assertSame(support, ModuleSupport.getInstance(request.getSession().getServletContext()));
}
public void testGetModuleContext() {
assertSame(module, support.getModuleContext(request));
assertSame(module, support.getModuleContext(new TestPageContext(request)));
}
public static void main(String[] args) {
junit.textui.TestRunner.run(ModuleSupportTest.class);
}
}