1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2013 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
25
25
import org .springframework .mock .web .test .MockHttpServletResponse ;
26
26
27
27
/**
28
- * Unit tests for ParamTag
28
+ * Unit tests for {@link ParamTag}
29
29
*
30
30
* @author Scott Andrews
31
+ * @author Nicholas Williams
31
32
*/
32
33
public class ParamTagTests extends AbstractTagTests {
33
34
@@ -67,7 +68,7 @@ public void testParamWithBodyValue() throws JspException {
67
68
assertEquals ("value" , parent .getParam ().getValue ());
68
69
}
69
70
70
- public void testParamWithNullValue () throws JspException {
71
+ public void testParamWithImplicitNullValue () throws JspException {
71
72
tag .setName ("name" );
72
73
73
74
int action = tag .doEndTag ();
@@ -77,6 +78,43 @@ public void testParamWithNullValue() throws JspException {
77
78
assertNull (parent .getParam ().getValue ());
78
79
}
79
80
81
+ public void testParamWithExplicitNullValue () throws JspException {
82
+ tag .setName ("name" );
83
+ tag .setValue (null );
84
+
85
+ int action = tag .doEndTag ();
86
+
87
+ assertEquals (Tag .EVAL_PAGE , action );
88
+ assertEquals ("name" , parent .getParam ().getName ());
89
+ assertNull (parent .getParam ().getValue ());
90
+ }
91
+
92
+ public void testParamWithValueThenReleaseThenBodyValue () throws JspException {
93
+ tag .setName ("name1" );
94
+ tag .setValue ("value1" );
95
+
96
+ int action = tag .doEndTag ();
97
+
98
+ assertEquals (Tag .EVAL_PAGE , action );
99
+ assertEquals ("name1" , parent .getParam ().getName ());
100
+ assertEquals ("value1" , parent .getParam ().getValue ());
101
+
102
+ tag .release ();
103
+
104
+ parent = new MockParamSupportTag ();
105
+ tag .setPageContext (createPageContext ());
106
+ tag .setParent (parent );
107
+ tag .setName ("name2" );
108
+ tag .setBodyContent (new MockBodyContent ("value2" ,
109
+ new MockHttpServletResponse ()));
110
+
111
+ action = tag .doEndTag ();
112
+
113
+ assertEquals (Tag .EVAL_PAGE , action );
114
+ assertEquals ("name2" , parent .getParam ().getName ());
115
+ assertEquals ("value2" , parent .getParam ().getValue ());
116
+ }
117
+
80
118
public void testParamWithNoParent () {
81
119
tag .setName ("name" );
82
120
tag .setValue ("value" );
0 commit comments