use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.
the class TestActionServlet method testProcessForwardConfigClassOverriddenSubConfigClass.
/**
* Test the case where the subconfig has already specified its own config
* class. If the code still attempts to create a new instance, an error
* will be thrown.
*/
public void testProcessForwardConfigClassOverriddenSubConfigClass() throws Exception {
moduleConfig.addForwardConfig(baseForward);
ForwardConfig customSub = new CustomForwardConfigArg("failure", "/failure.jsp");
customSub.setExtends("success");
moduleConfig.addForwardConfig(customSub);
try {
actionServlet.processForwardConfigClass(customSub, moduleConfig, null);
} catch (Exception e) {
fail("Exception should not be thrown");
}
}
use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.
the class TestActionServlet method testProcessActionExtensionWithForwardConfig.
/**
* Test that an ActionConfig's ForwardConfig can inherit from a
* global ForwardConfig.
*/
public void testProcessActionExtensionWithForwardConfig() throws ServletException {
ForwardConfig forwardConfig = new ForwardConfig();
forwardConfig.setName("sub");
forwardConfig.setExtends("success");
baseAction.addForwardConfig(forwardConfig);
moduleConfig.addActionConfig(baseAction);
moduleConfig.addForwardConfig(baseForward);
actionServlet.processActionConfigExtension(baseAction, moduleConfig);
forwardConfig = baseAction.findForwardConfig("sub");
assertEquals("'sub' forward's inheritance was not processed.", baseForward.getPath(), forwardConfig.getPath());
}
use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.
the class TestRequestUtils method testForwardURL3.
// Third module (custom forwardPattern)
public void testForwardURL3() {
request.setAttribute(Globals.MODULE_KEY, moduleConfig3);
request.setPathElements("/myapp", "/3/action.do", null, null);
ForwardConfig forward = null;
String result = null;
// redirect=false, module=null
forward = moduleConfig3.findForwardConfig("moduleForward");
assertNotNull("moduleForward found", forward);
result = RequestUtils.forwardURL(request, forward, null);
assertNotNull("moduleForward computed", result);
assertEquals("moduleForward value", "/forwarding/3/module/forward", result);
// redirect=true, module=null
forward = moduleConfig3.findForwardConfig("moduleRedirect");
assertNotNull("moduleRedirect found", forward);
result = RequestUtils.forwardURL(request, forward, null);
assertNotNull("moduleRedirect computed", result);
assertEquals("moduleRedirect value", "/forwarding/3/module/redirect", result);
// redirect=false, module=/context
forward = moduleConfig3.findForwardConfig("contextForward");
assertNotNull("contextForward found", forward);
result = RequestUtils.forwardURL(request, forward, null);
assertNotNull("contextForward computed", result);
assertEquals("contextForward value", "/forwarding/context/forward", result);
// redirect=true, module=/context
forward = moduleConfig3.findForwardConfig("contextRedirect");
assertNotNull("contextRedirect found", forward);
result = RequestUtils.forwardURL(request, forward, null);
assertNotNull("contextRedirect computed", result);
assertEquals("contextRedirct value", "/forwarding/context/redirect", result);
// noslash, module=null
forward = moduleConfig3.findForwardConfig("moduleNoslash");
assertNotNull("moduleNoslash found", forward);
result = RequestUtils.forwardURL(request, forward, null);
assertNotNull("moduleNoslash computed", result);
assertEquals("moduleNoslash value", "/forwarding/3/module/noslash", result);
// noslash, module=/
forward = moduleConfig3.findForwardConfig("contextNoslash");
assertNotNull("contextNoslash found", forward);
result = RequestUtils.forwardURL(request, forward, null);
assertNotNull("contextNoslash computed", result);
assertEquals("contextNoslash value", "/forwarding/context/noslash", result);
}
use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.
the class TagTestBase method setUp.
/**
* Helper method that creates/configures a basic configuration of Mock
* Objects.
*
*
* PageContext ServletConfig ServletContext HttpServletRequest HttpSession
* HttpServletResponse
*
* "/myapp", "/foo", null, null,
*/
public void setUp() {
// -- default Module
this.moduleConfig = new ModuleConfigImpl("");
this.moduleConfig.addForwardConfig(new ForwardConfig("foo", "/bar.jsp", false));
this.moduleConfig.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
this.moduleConfig.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
this.moduleConfig.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
// -- module "/2"
this.moduleConfig2 = new ModuleConfigImpl("/2");
this.moduleConfig2.addForwardConfig(new ForwardConfig("foo", "/baz.jsp", false));
this.moduleConfig2.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
this.moduleConfig2.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
this.moduleConfig2.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
// -- module "/3"
this.moduleConfig3 = new ModuleConfigImpl("/3");
// -- configure the ServletContext
this.servletContext = new MockServletContext();
this.servletContext.setAttribute(Globals.MODULE_KEY, moduleConfig);
this.servletContext.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
this.servletContext.setAttribute(Globals.MODULE_KEY + "/3", moduleConfig3);
// -- configure the ServletConfig
this.servletConfig = new MockServletConfig();
this.servletConfig.setServletContext(servletContext);
// -- configure the request
this.request = new MockHttpServletRequest(new MockHttpSession());
pageContext = new MockPageContext(servletConfig, request, new MockHttpServletResponse());
}
use of org.apache.struts.config.ForwardConfig 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);
}
Aggregations