package com.oreilly.javaxp.cactus.servlet;
import org.apache.cactus.ServletTestCase;
/**
* @author Brian M. Coyner
* $version $Id: TestConfigParamServlet.java,v 1.2 2003/02/27 00:24:44 jepc Exp $
*/
public class TestConfigParamServlet extends ServletTestCase {
private ConfigParamServlet servlet;
public TestConfigParamServlet(String name) {
super(name);
}
public void setUp() {
this.servlet = new ConfigParamServlet();
}
public void testValidInitParameters() throws Exception {
// the config object is instantiated by the Servlet Redirector
// Servlet. Our test case is given access to this object
// implicitly by the Cactus framework. A very important step
// is to initialize our servlet being tested with this config
// object (ServletConfig) as shown below!
this.config.setInitParameter(ConfigParamServlet.CONFIG_PARAM,
ConfigParamServlet.CONFIG_VALUE);
// critical step!
this.servlet.init(this.config);
assertTrue("Valid Init Parameter.",
this.servlet.validateInitParameters());
}
public void testInvalidInitParameterValues() throws Exception {
this.config.setInitParameter(ConfigParamServlet.CONFIG_PARAM, "JUNK");
this.servlet.init(this.config);
assertTrue("Invalid Init Parameter.",
!this.servlet.validateInitParameters());
}
}
|