Search in sources :

Example 16 with ExceptionConfig

use of org.apache.struts.config.ExceptionConfig 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.");
    }
}
Also used : ExceptionConfig(org.apache.struts.config.ExceptionConfig) UnavailableException(javax.servlet.UnavailableException) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException)

Aggregations

ExceptionConfig (org.apache.struts.config.ExceptionConfig)16 UnavailableException (javax.servlet.UnavailableException)7 ServletException (javax.servlet.ServletException)6 ForwardConfig (org.apache.struts.config.ForwardConfig)5 ActionConfig (org.apache.struts.config.ActionConfig)4 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 MissingResourceException (java.util.MissingResourceException)3 SAXException (org.xml.sax.SAXException)3 FormBeanConfig (org.apache.struts.config.FormBeanConfig)2 ActionConfigMatcher (org.apache.struts.config.ActionConfigMatcher)1 FormPropertyConfig (org.apache.struts.config.FormPropertyConfig)1 MessageResourcesConfig (org.apache.struts.config.MessageResourcesConfig)1 ModuleConfig (org.apache.struts.config.ModuleConfig)1 ModuleConfigFactory (org.apache.struts.config.ModuleConfigFactory)1 PlugInConfig (org.apache.struts.config.PlugInConfig)1