protected void tearDown() {
servlet = null;
}
public void testGetRootDir() {
MockServletConfig config = new MockServletConfig();
MockServletContext context = new MockServletContext();
config.setServletContext(context);
try {
servlet.getRootDir(config);
fail("should have exception when required attributes not set");
} catch (ServletException e) {
}
config.setInitParameter("rootDir", ".");
try {
servlet.getRootDir(config);
} catch (ServletException e) {
fail("shouldn't throw exception when valid rootDir parameter set");
}
context.setInitParameter("logDir", "this directory does not exist");
try {
servlet.getRootDir(config);
} catch (ServletException e) {
fail("good rootDir but bad logDir should work");
}
config = new MockServletConfig();
context = new MockServletContext();
config.setServletContext(context);
context.setInitParameter("logDir", ".");
try {
servlet.getRootDir(config);
} catch (ServletException e) {
fail("shouldn't throw exception when valid logDir parameter set");
}
config.setInitParameter("rootDir", "this directory does not exist");
try {
servlet.getRootDir(config);
} catch (ServletException e) {
fail("bad rootDir but good logDir should work");
}