1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.test; |
16 |
| |
17 |
| import java.util.ArrayList; |
18 |
| import java.util.Collection; |
19 |
| import java.util.HashMap; |
20 |
| import java.util.Iterator; |
21 |
| import java.util.List; |
22 |
| import java.util.Map; |
23 |
| |
24 |
| import org.apache.hivemind.impl.BaseLocatable; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public class RequestDescriptor extends BaseLocatable |
33 |
| { |
34 |
| private String _servletName; |
35 |
| private String _servletPath; |
36 |
| |
37 |
| |
38 |
| private Map _parameters = new HashMap(); |
39 |
| |
40 |
| |
41 |
| private List _assertions = new ArrayList(); |
42 |
| |
43 |
5
| public void addAssertion(ResponseAssertion assertion)
|
44 |
| { |
45 |
5
| _assertions.add(assertion);
|
46 |
| } |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
4
| public void executeAssertions(ScriptedTestSession session)
|
53 |
| { |
54 |
4
| Iterator i = _assertions.iterator();
|
55 |
4
| while (i.hasNext())
|
56 |
| { |
57 |
5
| ResponseAssertion a = (ResponseAssertion) i.next();
|
58 |
| |
59 |
5
| a.execute(session);
|
60 |
| } |
61 |
| } |
62 |
| |
63 |
10
| public void addParameter(String name, String value)
|
64 |
| { |
65 |
10
| ParameterList pl = (ParameterList) _parameters.get(name);
|
66 |
10
| if (pl == null)
|
67 |
| { |
68 |
7
| pl = new ParameterList();
|
69 |
7
| _parameters.put(name, pl);
|
70 |
| } |
71 |
| |
72 |
10
| pl.add(value);
|
73 |
| } |
74 |
| |
75 |
| |
76 |
| |
77 |
| |
78 |
| |
79 |
| |
80 |
| |
81 |
6
| public String[] getParameterValues(String name)
|
82 |
| { |
83 |
6
| ParameterList pl = (ParameterList) _parameters.get(name);
|
84 |
| |
85 |
6
| if (pl == null)
|
86 |
1
| return null;
|
87 |
| |
88 |
5
| return pl.getValues();
|
89 |
| } |
90 |
| |
91 |
6
| public String getServletName()
|
92 |
| { |
93 |
6
| return _servletName;
|
94 |
| } |
95 |
| |
96 |
8
| public void setServletName(String string)
|
97 |
| { |
98 |
8
| _servletName = string;
|
99 |
| } |
100 |
| |
101 |
2
| public String getServletPath()
|
102 |
| { |
103 |
2
| return _servletPath;
|
104 |
| } |
105 |
| |
106 |
7
| public void setServletPath(String string)
|
107 |
| { |
108 |
7
| _servletPath = string;
|
109 |
| } |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
2
| public String[] getParameterNames()
|
115 |
| { |
116 |
2
| Collection c = _parameters.keySet();
|
117 |
| |
118 |
2
| return (String[]) c.toArray(new String[c.size()]);
|
119 |
| } |
120 |
| |
121 |
| } |