Search in sources :

Example 76 with UnavailableException

use of javax.servlet.UnavailableException in project sonar-java 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);
}
Also used : UnavailableException(javax.servlet.UnavailableException) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 77 with UnavailableException

use of javax.servlet.UnavailableException in project sonar-java by SonarSource.

the class TestActionServlet method testInitModuleFormBeansNullFormType.

/**
 * Test that initModuleFormBeans throws an exception when a form with a
 * null type is present.
 */
public void testInitModuleFormBeansNullFormType() throws ServletException {
    FormBeanConfig formBean = new FormBeanConfig();
    formBean.setName("noTypeForm");
    moduleConfig.addFormBeanConfig(formBean);
    try {
        actionServlet.initModuleFormBeans(moduleConfig);
        fail("An exception should've been thrown here.");
    } catch (UnavailableException e) {
    // success
    } catch (Exception e) {
        fail("Unrecognized exception thrown: " + e);
    }
}
Also used : FormBeanConfig(org.apache.struts.config.FormBeanConfig) UnavailableException(javax.servlet.UnavailableException) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException)

Example 78 with UnavailableException

use of javax.servlet.UnavailableException in project sonar-java by SonarSource.

the class TestActionServlet method testProcessActionConfigClassNoExtends.

/**
 * Make sure processActionConfigClass() returns what it was given if the
 * action passed to it doesn't extend anything.
 */
public void testProcessActionConfigClassNoExtends() throws Exception {
    moduleConfig.addActionConfig(baseAction);
    ActionConfig result = null;
    try {
        result = actionServlet.processActionConfigClass(baseAction, moduleConfig);
    } catch (UnavailableException e) {
        fail("An exception should not be thrown here");
    }
    assertSame("Result should be the same as the input.", baseAction, result);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) UnavailableException(javax.servlet.UnavailableException)

Example 79 with UnavailableException

use of javax.servlet.UnavailableException in project sonar-java by SonarSource.

the class TestActionServlet method notestProcessForwardConfigClassError.

/**
 * Make sure the code throws the correct exception when it can't create an
 * instance of the base config's custom class.
 */
public void notestProcessForwardConfigClassError() throws Exception {
    ForwardConfig customBase = new CustomForwardConfigArg("success", "/success.jsp");
    moduleConfig.addForwardConfig(customBase);
    ForwardConfig customSub = new ActionForward();
    customSub.setName("failure");
    customSub.setExtends("success");
    moduleConfig.addForwardConfig(customSub);
    try {
        actionServlet.processForwardConfigClass(customSub, moduleConfig, null);
        fail("Exception should be thrown");
    } catch (UnavailableException e) {
    // success
    } catch (Exception e) {
        fail("Unexpected exception thrown.");
    }
}
Also used : UnavailableException(javax.servlet.UnavailableException) ForwardConfig(org.apache.struts.config.ForwardConfig) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException)

Example 80 with UnavailableException

use of javax.servlet.UnavailableException in project sonar-java 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

UnavailableException (javax.servlet.UnavailableException)95 ServletException (javax.servlet.ServletException)54 IOException (java.io.IOException)33 MalformedURLException (java.net.MalformedURLException)15 SAXException (org.xml.sax.SAXException)14 MissingResourceException (java.util.MissingResourceException)12 ExceptionConfig (org.apache.struts.config.ExceptionConfig)10 URL (java.net.URL)8 Servlet (javax.servlet.Servlet)8 FormBeanConfig (org.apache.struts.config.FormBeanConfig)8 ForwardConfig (org.apache.struts.config.ForwardConfig)8 ServletContext (javax.servlet.ServletContext)6 ActionConfig (org.apache.struts.config.ActionConfig)6 ArrayList (java.util.ArrayList)5 ServletConfig (javax.servlet.ServletConfig)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 ClientAbortException (org.apache.catalina.connector.ClientAbortException)4 InvalidConfigException (com.revolsys.ui.web.config.InvalidConfigException)3 XmlConfigLoader (com.revolsys.ui.web.config.XmlConfigLoader)3 BufferedImage (java.awt.image.BufferedImage)3