18
18
*/
19
19
package org .apache .struts2 .views .jsp ;
20
20
21
- import java .io .File ;
22
- import java .io .StringWriter ;
23
- import java .util .HashMap ;
24
- import java .util .Locale ;
25
- import java .util .Map ;
26
-
27
- import javax .servlet .http .HttpServletResponse ;
28
- import javax .servlet .jsp .JspWriter ;
29
-
21
+ import com .mockobjects .dynamic .Mock ;
22
+ import com .opensymphony .xwork2 .Action ;
23
+ import com .opensymphony .xwork2 .ActionContext ;
24
+ import com .opensymphony .xwork2 .inject .Container ;
25
+ import com .opensymphony .xwork2 .util .ValueStack ;
30
26
import org .apache .commons .lang3 .builder .EqualsBuilder ;
31
27
import org .apache .struts2 .ServletActionContext ;
32
28
import org .apache .struts2 .StrutsInternalTestCase ;
33
29
import org .apache .struts2 .TestAction ;
34
30
import org .apache .struts2 .dispatcher .ApplicationMap ;
35
31
import org .apache .struts2 .dispatcher .Dispatcher ;
36
- import org .apache .struts2 .dispatcher .MockDispatcher ;
37
32
import org .apache .struts2 .dispatcher .HttpParameters ;
33
+ import org .apache .struts2 .dispatcher .MockDispatcher ;
38
34
import org .apache .struts2 .dispatcher .RequestMap ;
39
35
import org .apache .struts2 .dispatcher .SessionMap ;
40
36
41
- import com . mockobjects . dynamic . Mock ;
42
- import com . opensymphony . xwork2 . Action ;
43
- import com . opensymphony . xwork2 . ActionContext ;
44
- import com . opensymphony . xwork2 . inject . Container ;
45
- import com . opensymphony . xwork2 . util .ValueStack ;
46
-
37
+ import javax . servlet . http . HttpServletResponse ;
38
+ import javax . servlet . jsp . JspWriter ;
39
+ import java . io . File ;
40
+ import java . io . StringWriter ;
41
+ import java . util .HashMap ;
42
+ import java . util . Map ;
47
43
48
44
/**
49
45
* Base class to extend for unit testing UI Tags.
50
- *
51
46
*/
52
47
public abstract class AbstractTagTest extends StrutsInternalTestCase {
53
48
protected Action action ;
@@ -62,7 +57,7 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase {
62
57
protected StrutsMockHttpServletRequest request ;
63
58
protected StrutsMockPageContext pageContext ;
64
59
protected HttpServletResponse response ;
65
-
60
+
66
61
protected Mock mockContainer ;
67
62
68
63
/**
@@ -114,11 +109,11 @@ protected void createMocks() {
114
109
Dispatcher .setInstance (du );
115
110
session = new SessionMap <>(request );
116
111
Map <String , Object > extraContext = du .createContextMap (new RequestMap (request ),
117
- HttpParameters .create (request .getParameterMap ()).build (),
118
- session ,
119
- new ApplicationMap (pageContext .getServletContext ()),
120
- request ,
121
- response );
112
+ HttpParameters .create (request .getParameterMap ()).build (),
113
+ session ,
114
+ new ApplicationMap (pageContext .getServletContext ()),
115
+ request ,
116
+ response );
122
117
// let's not set the locale -- there is a test that checks if Dispatcher actually picks this up...
123
118
// ... but generally we want to just use no locale (let it stay system default)
124
119
extraContext = ActionContext .of (extraContext ).withLocale (null ).getContextMap ();
@@ -149,18 +144,18 @@ protected void tearDown() throws Exception {
149
144
}
150
145
151
146
/**
152
- * Compare if two component tags are considered equal according to their fields as accessed
147
+ * Compare if two component tags are considered equal according to their fields as accessed
153
148
* via reflection.
154
- *
155
- * Utilizes {@link EqualsBuilder#reflectionEquals(java.lang.Object, java.lang.Object, boolean)} to perform
149
+ * <p>
150
+ * Utilizes {@link EqualsBuilder#reflectionEquals(java.lang.Object, java.lang.Object, boolean)} to perform
156
151
* the check, and compares transient fields as well. This may fail when run while a security manager is
157
152
* active, due to a need to user reflection.
158
- *
153
+ * <p>
159
154
* This method may be useful for checking if the state of a tag is what is expected after a given set of operations,
160
155
* or after clearing state such as for calls involving {@link StrutsBodyTagSupport#clearTagStateForTagPoolingServers()}
161
156
* has taken place following {@link StrutsBodyTagSupport#doEndTag()} processing. When making comparisons, keep in mind the
162
157
* pageContext and parent Tag state are not cleared by clearTagStateForTagPoolingServers().
163
- *
158
+ *
164
159
* @param tag1 the first {@link StrutsBodyTagSupport} to compare against the other.
165
160
* @param tag2 the second {@link StrutsBodyTagSupport} to compare against the other.
166
161
* @return true if the Tags are equal based on field comparisons by reflection, false otherwise.
@@ -170,15 +165,16 @@ protected boolean strutsBodyTagsAreReflectionEqual(StrutsBodyTagSupport tag1, St
170
165
}
171
166
172
167
/**
173
- * Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
174
- * {@link ComponentTagSupport} tag's {@link Component} to match expectations for the test.
175
- *
168
+ * Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
169
+ * {@link ComponentTagSupport} tag's {@link import org.apache.struts2.components.Component} to match expectations
170
+ * for the test.
171
+ * <p>
176
172
* The component reference is not available to the tag until after the doStartTag() method is called.
177
- * We need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
178
- * what we set for the Tag when a non-default (true) value is used, so this method accesses the component instance,
179
- * sets the value specified and forces the tag's parameters to be repopulated again.
180
- *
181
- * @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
173
+ * We need to ensure the component's {@link import org.apache.struts2.components. Component#performClearTagStateForTagPoolingServers}
174
+ * state matches what we set for the Tag when a non-default (true) value is used, so this method accesses
175
+ * the component instance, sets the value specified and forces the tag's parameters to be repopulated again.
176
+ *
177
+ * @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
182
178
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
183
179
*/
184
180
protected void setComponentTagClearTagState (ComponentTagSupport tag , boolean performClearTagStateForTagPoolingServers ) {
0 commit comments