use of javax.servlet.UnavailableException in project sonarqube by SonarSource.
the class TestActionServlet method testProcessForwardConfigClassNoExtends.
/**
* Make sure processForwardConfigClass() returns what it was given if the
* forward passed to it doesn't extend anything.
*/
public void testProcessForwardConfigClassNoExtends() throws Exception {
moduleConfig.addForwardConfig(baseForward);
ForwardConfig result = null;
try {
result = actionServlet.processForwardConfigClass(baseForward, moduleConfig, null);
} catch (UnavailableException e) {
fail("An exception should not be thrown when there's nothing to do");
}
assertSame("Result should be the same as the input.", baseForward, result);
}
use of javax.servlet.UnavailableException in project sonarqube by SonarSource.
the class TestActionServlet method notestProcessExceptionConfigClassError.
/**
* Make sure the code throws the correct exception when it can't create an
* instance of the base config's custom class.
*/
public void notestProcessExceptionConfigClassError() throws Exception {
ExceptionConfig customBase = new CustomExceptionConfigArg("java.lang.NullPointerException");
moduleConfig.addExceptionConfig(customBase);
ExceptionConfig customSub = new ExceptionConfig();
customSub.setType("java.lang.IllegalStateException");
customSub.setExtends("java.lang.NullPointerException");
moduleConfig.addExceptionConfig(customSub);
try {
actionServlet.processExceptionConfigClass(customSub, moduleConfig, null);
fail("Exception should be thrown");
} catch (UnavailableException e) {
// success
} catch (Exception e) {
fail("Unexpected exception thrown.");
}
}
use of javax.servlet.UnavailableException in project head by mifos.
the class EnumPlugin method init.
@Override
public void init(ActionServlet actionServlet, ModuleConfig config) throws ServletException {
try {
ServletContext servletContext = actionServlet.getServletContext();
List<String> enumFileNameList = getEnumFileNames();
List<Class> enumClassList = buildClasses(enumFileNameList);
EnumMapBuilder constantBuilder = EnumMapBuilder.getInstance();
for (Class cl : enumClassList) {
servletContext.setAttribute(getName(cl), constantBuilder.buildMap(cl));
}
} catch (Exception e) {
UnavailableException ue = new UnavailableException(e.getMessage(), 0);
ue.initCause(e);
throw ue;
}
}
use of javax.servlet.UnavailableException in project head by mifos.
the class ConstPlugin method init.
@Override
public void init(ActionServlet actionServlet, ModuleConfig config) throws ServletException {
try {
ServletContext servletContext = actionServlet.getServletContext();
List<String> constantFileNameList = getConstantFileNames();
List<Class> constantClassList = buildClasses(constantFileNameList);
ConstantMapBuilder constantBuilder = ConstantMapBuilder.getInstance();
for (Class cl : constantClassList) {
servletContext.setAttribute(getName(cl), constantBuilder.buildMap(cl));
}
} catch (Exception e) {
UnavailableException ue = new UnavailableException(e.getMessage(), 0);
ue.initCause(e);
throw ue;
}
}
use of javax.servlet.UnavailableException in project opennms by OpenNMS.
the class BaseAcknowledgeServlet method init.
/**
* Looks up the <code>dispath.success</code> parameter in the servlet's
* config. If not present, this servlet will throw an exception so it will
* be marked unavailable.
*
* @throws javax.servlet.ServletException if any.
*/
@Override
public void init() throws ServletException {
ServletConfig config = this.getServletConfig();
this.redirectSuccess = config.getInitParameter("redirect.success");
if (this.redirectSuccess == null) {
throw new UnavailableException("Require a redirect.success init parameter.");
}
}
Aggregations