11/*
2- * Copyright 2002-2012 the original author or authors.
2+ * Copyright 2002-2013 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2525import org .springframework .mock .web .test .MockHttpServletResponse ;
2626
2727/**
28- * Unit tests for ParamTag
28+ * Unit tests for {@link ParamTag}
2929 *
3030 * @author Scott Andrews
31+ * @author Nicholas Williams
3132 */
3233public class ParamTagTests extends AbstractTagTests {
3334
@@ -67,7 +68,7 @@ public void testParamWithBodyValue() throws JspException {
6768 assertEquals ("value" , parent .getParam ().getValue ());
6869 }
6970
70- public void testParamWithNullValue () throws JspException {
71+ public void testParamWithImplicitNullValue () throws JspException {
7172 tag .setName ("name" );
7273
7374 int action = tag .doEndTag ();
@@ -77,6 +78,43 @@ public void testParamWithNullValue() throws JspException {
7778 assertNull (parent .getParam ().getValue ());
7879 }
7980
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+
80118 public void testParamWithNoParent () {
81119 tag .setName ("name" );
82120 tag .setValue ("value" );
0 commit comments