01: package com.opensymphony.webwork.components;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import com.opensymphony.webwork.views.jsp.AbstractTagTest;
07:
08: /**
09: * Verifies correct operation of parameter merging.
10: *
11: * Contributed by: Daniel Uribe
12: */
13: public class URLTest extends AbstractTagTest {
14: public void testIncludeGetDuplicateRequestParams() throws Exception {
15: String body = "";
16:
17: Map parameterMap = new HashMap();
18: parameterMap.put("param", new String[] { "1", "2", "3" });
19:
20: request.setQueryString("param=1¶m=2¶m=3");
21: request.setScheme("http");
22: request.setParameterMap(parameterMap);
23: URL url = new URL(stack, request, response);
24: url.setIncludeParams(URL.GET);
25: url.setIncludeContext(false);
26: url.setValue("myAction.action");
27: url.setNamespace("");
28:
29: url.start(writer);
30: url.end(writer, body);
31:
32: assertEquals("myAction.action?param=1&param=2&param=3",
33: writer.toString());
34: }
35:
36: public void testIncludeAllDuplicateRequestParams() throws Exception {
37: String body = "";
38:
39: Map parameterMap = new HashMap();
40: parameterMap.put("param", new String[] { "1", "2", "3" });
41:
42: request.setQueryString("param=1¶m=2¶m=3");
43: request.setScheme("http");
44: request.setParameterMap(parameterMap);
45: URL url = new URL(stack, request, response);
46: url.setIncludeParams(URL.ALL);
47: url.setIncludeContext(false);
48: url.setValue("myAction.action");
49: url.setNamespace("");
50:
51: url.start(writer);
52: url.end(writer, body);
53:
54: assertEquals("myAction.action?param=1&param=2&param=3",
55: writer.toString());
56: }
57: }
|