FileDocCategorySizeDatePackage
URLTest.javaAPI DocExample1792Mon Jul 23 13:26:10 BST 2007org.apache.struts2.components

URLTest

public class URLTest extends org.apache.struts2.views.jsp.AbstractTagTest
Verifies correct operation of parameter merging. Contributed by: Daniel Uribe

Fields Summary
Constructors Summary
Methods Summary
public voidtestIncludeAllDuplicateRequestParams()

        String body = "";

        Map parameterMap = new HashMap();
        parameterMap.put("param", new String[] { "1", "2", "3" });

        request.setQueryString("param=1¶m=2¶m=3");
        request.setScheme("http");
        request.setParameterMap(parameterMap);
        URL url = new URL(stack, request, response);
        url.setIncludeParams(URL.ALL);
        url.setIncludeContext(false);
        url.setValue("myAction.action");
        url.setNamespace("");

        url.start(writer);
        url.end(writer, body);

        assertEquals("myAction.action?param=1&param=2&param=3",
            writer.toString());
    
public voidtestIncludeGetDuplicateRequestParams()

        String body = "";

        Map parameterMap = new HashMap();
        parameterMap.put("param", new String[] { "1", "2", "3" });

        request.setQueryString("param=1¶m=2¶m=3");
        request.setScheme("http");
        request.setParameterMap(parameterMap);
        URL url = new URL(stack, request, response);
        url.setIncludeParams(URL.GET);
        url.setIncludeContext(false);
        url.setValue("myAction.action");
        url.setNamespace("");

        url.start(writer);
        url.end(writer, body);

        assertEquals("myAction.action?param=1&param=2&param=3",
            writer.toString());