18
18
*/
19
19
package org .apache .struts2 .views .jsp .ui ;
20
20
21
- import java .util .Map ;
22
-
21
+ import com .opensymphony .xwork2 .ActionContext ;
22
+ import com .opensymphony .xwork2 .config .ConfigurationException ;
23
+ import com .opensymphony .xwork2 .config .ConfigurationProvider ;
24
+ import com .opensymphony .xwork2 .inject .ContainerBuilder ;
25
+ import com .opensymphony .xwork2 .test .StubConfigurationProvider ;
26
+ import com .opensymphony .xwork2 .util .ValueStack ;
27
+ import com .opensymphony .xwork2 .util .location .LocatableProperties ;
28
+ import org .apache .struts2 .ServletActionContext ;
29
+ import org .apache .struts2 .StrutsConstants ;
23
30
import org .apache .struts2 .TestAction ;
24
31
import org .apache .struts2 .views .jsp .AbstractUITagTest ;
25
32
33
+ import javax .servlet .http .HttpServletRequest ;
34
+ import java .util .Map ;
35
+
26
36
public class CheckboxTest extends AbstractUITagTest {
27
37
28
38
/**
@@ -31,7 +41,7 @@ public class CheckboxTest extends AbstractUITagTest {
31
41
* String, String[])} as properties to verify.<br> This implementation extends testdata from AbstractUITag.
32
42
*
33
43
* @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
34
- * as key.
44
+ * as key.
35
45
*/
36
46
@ Override
37
47
protected Map <String , PropertyHolder > initializedGenericTagTestProperties () {
@@ -73,7 +83,7 @@ public void testChecked() throws Exception {
73
83
freshTag .setPageContext (pageContext );
74
84
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
75
85
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
76
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
86
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
77
87
}
78
88
79
89
public void testChecked_clearTagStateSet () throws Exception {
@@ -102,7 +112,7 @@ public void testChecked_clearTagStateSet() throws Exception {
102
112
freshTag .setPageContext (pageContext );
103
113
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
104
114
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
105
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
115
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
106
116
}
107
117
108
118
public void testCheckedWithTopLabelPosition () throws Exception {
@@ -129,10 +139,10 @@ public void testCheckedWithTopLabelPosition() throws Exception {
129
139
freshTag .setPageContext (pageContext );
130
140
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
131
141
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
132
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
142
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
133
143
}
134
144
135
- public void testCheckedWithTopLabelPosition_clearTagStateSet () throws Exception {
145
+ public void testCheckedWithTopLabelPosition_clearTagStateSet () throws Exception {
136
146
TestAction testAction = (TestAction ) action ;
137
147
testAction .setFoo ("true" );
138
148
@@ -159,7 +169,7 @@ public void testCheckedWithTopLabelPosition_clearTagStateSet() throws Exception
159
169
freshTag .setPageContext (pageContext );
160
170
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
161
171
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
162
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
172
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
163
173
}
164
174
165
175
public void testCheckedWithLeftLabelPosition () throws Exception {
@@ -186,7 +196,7 @@ public void testCheckedWithLeftLabelPosition() throws Exception {
186
196
freshTag .setPageContext (pageContext );
187
197
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
188
198
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
189
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
199
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
190
200
}
191
201
192
202
public void testCheckedWithLeftLabelPosition_clearTagStateSet () throws Exception {
@@ -216,7 +226,7 @@ public void testCheckedWithLeftLabelPosition_clearTagStateSet() throws Exception
216
226
freshTag .setPageContext (pageContext );
217
227
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
218
228
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
219
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
229
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
220
230
}
221
231
222
232
public void testCheckedWithError () throws Exception {
@@ -245,7 +255,7 @@ public void testCheckedWithError() throws Exception {
245
255
freshTag .setPageContext (pageContext );
246
256
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
247
257
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
248
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
258
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
249
259
}
250
260
251
261
public void testCheckedWithError_clearTagStateSet () throws Exception {
@@ -277,7 +287,7 @@ public void testCheckedWithError_clearTagStateSet() throws Exception {
277
287
freshTag .setPageContext (pageContext );
278
288
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
279
289
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
280
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
290
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
281
291
}
282
292
283
293
public void testCheckedWithErrorStyle () throws Exception {
@@ -306,7 +316,7 @@ public void testCheckedWithErrorStyle() throws Exception {
306
316
freshTag .setPageContext (pageContext );
307
317
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
308
318
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
309
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
319
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
310
320
}
311
321
312
322
public void testCheckedWithErrorStyle_clearTagStateSet () throws Exception {
@@ -338,7 +348,7 @@ public void testCheckedWithErrorStyle_clearTagStateSet() throws Exception {
338
348
freshTag .setPageContext (pageContext );
339
349
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
340
350
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
341
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
351
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
342
352
}
343
353
344
354
public void testUnchecked () throws Exception {
@@ -362,7 +372,7 @@ public void testUnchecked() throws Exception {
362
372
freshTag .setPageContext (pageContext );
363
373
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
364
374
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
365
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
375
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
366
376
}
367
377
368
378
public void testUnchecked_clearTagStateSet () throws Exception {
@@ -389,7 +399,7 @@ public void testUnchecked_clearTagStateSet() throws Exception {
389
399
freshTag .setPageContext (pageContext );
390
400
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
391
401
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
392
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
402
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
393
403
}
394
404
395
405
public void testDisabled () throws Exception {
@@ -414,7 +424,7 @@ public void testDisabled() throws Exception {
414
424
freshTag .setPageContext (pageContext );
415
425
assertFalse ("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
416
426
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
417
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
427
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
418
428
}
419
429
420
430
public void testDisabled_clearTagStateSet () throws Exception {
@@ -442,7 +452,7 @@ public void testDisabled_clearTagStateSet() throws Exception {
442
452
freshTag .setPageContext (pageContext );
443
453
assertTrue ("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
444
454
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly." ,
445
- strutsBodyTagsAreReflectionEqual (tag , freshTag ));
455
+ strutsBodyTagsAreReflectionEqual (tag , freshTag ));
446
456
}
447
457
448
458
public void testSubmitUncheckedAsFalse () throws Exception {
@@ -487,4 +497,29 @@ public void testSubmitUncheckedAsTrue() throws Exception {
487
497
verify (CheckboxTag .class .getResource ("Checkbox-8.txt" ));
488
498
}
489
499
500
+ public void testSubmitUncheckedGlobalAsTrue () throws Exception {
501
+ initDispatcherWithConfigs ("struts-default.xml, struts-checkbox-submit-unchecked.xml" );
502
+ String submitUnchecked = container .getInstance (String .class , StrutsConstants .STRUTS_UI_CHECKBOX_SUBMIT_UNCHECKED );
503
+ assertEquals ("true" , submitUnchecked );
504
+
505
+ createMocks ();
506
+
507
+ TestAction testAction = (TestAction ) action ;
508
+ testAction .setFoo ("true" );
509
+
510
+ CheckboxTag tag = new CheckboxTag ();
511
+ tag .setPageContext (pageContext );
512
+ tag .setLabel ("mylabel" );
513
+ tag .setName ("foo" );
514
+ tag .setFieldValue ("baz" );
515
+ // tag.setSubmitUnchecked("true"); - value should be injected by container
516
+ tag .setTitle ("mytitle" );
517
+ tag .setDisabled ("true" );
518
+
519
+ tag .doStartTag ();
520
+ tag .doEndTag ();
521
+
522
+ verify (CheckboxTag .class .getResource ("Checkbox-8.txt" ));
523
+ }
524
+
490
525
}
0 commit comments