Search in sources :

Example 51 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestTagUtils method testString_getActionMappingURL_String_PageContext.

public void testString_getActionMappingURL_String_PageContext() {
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/myapp", "/foo.do", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo", pageContext), "/myapp/foo");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 52 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestTagUtils method testComputeURLCharacterEncodingAction.

public void testComputeURLCharacterEncodingAction() {
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setName("baz");
    actionConfig.setPath("/baz");
    moduleConfig.addActionConfig(actionConfig);
    request.setPathElements("/myapp", "/foo.do", null, null);
    Map map = new HashMap();
    map.put("foo1", "bar1");
    map.put("foo2", "bar2");
    String url = null;
    try {
        url = tagutils.computeURL(pageContext, null, null, null, "baz", null, map, "anchor", false);
    } catch (MalformedURLException e) {
        fail("MalformedURLException: " + e);
    }
    assertNotNull("url present", url);
    assertTrue("url value", url.equals("/myapp/baz?foo1=bar1&foo2=bar2#anchor") || url.equals("/myapp/baz?foo2=bar2&foo1=bar1#anchor"));
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 53 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean6.

// use servlet mapping (path mapping)
//  -- using "/" as mapping
public void testString_getActionMappingURL_String_String_PageContext_boolean6() {
    pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "/");
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/mycontext", "/baz", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/", pageContext), "/mycontext/");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 54 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean2.

// use servlet mapping (extension mapping)
//  -- with params
public void testString_getActionMappingURL_String_String_PageContext_boolean2() {
    pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "*.do");
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/myapp", "/baz.do?foo=bar", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo?foo=bar", pageContext), "/myapp/foo.do?foo=bar");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 55 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean4.

// use servlet mapping (path mapping)
public void testString_getActionMappingURL_String_String_PageContext_boolean4() {
    pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "/myapp/*");
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/mycontext", "/baz", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo", pageContext), "/mycontext/myapp/foo");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Aggregations

ActionConfig (org.apache.struts.config.ActionConfig)76 ForwardConfig (org.apache.struts.config.ForwardConfig)14 UnavailableException (javax.servlet.UnavailableException)8 ActionForm (org.apache.struts.action.ActionForm)8 ExceptionConfig (org.apache.struts.config.ExceptionConfig)8 FormBeanConfig (org.apache.struts.config.FormBeanConfig)8 ModuleConfig (org.apache.struts.config.ModuleConfig)8 ServletException (javax.servlet.ServletException)6 MalformedURLException (java.net.MalformedURLException)4 Map (java.util.Map)4 Action (org.apache.struts.action.Action)4 UnauthorizedActionException (org.apache.struts.chain.commands.UnauthorizedActionException)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 MissingResourceException (java.util.MissingResourceException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 ActionErrors (org.apache.struts.action.ActionErrors)2 MockActionContext (org.apache.struts.chain.contexts.MockActionContext)2 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)2