You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by he...@apache.org on 2007/02/16 18:34:23 UTC
svn commit: r508508 - in /struts/struts2/trunk/core/src/test:
java/org/apache/struts2/TestAction.java
java/org/apache/struts2/views/jsp/ui/SelectTest.java
resources/org/apache/struts2/views/jsp/ui/Select-11.txt
Author: hermanns
Date: Fri Feb 16 09:34:22 2007
New Revision: 508508
URL: http://svn.apache.org/viewvc?view=rev&rev=508508
Log:
select tag: current option is not selected if actual value to check is no String (aka: nameValue resolves to type other than String)
o added additional unit test submitted by Stuart Piltch
WW-1711
Added:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-11.txt
Modified:
struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestAction.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestAction.java?view=diff&rev=508508&r1=508507&r2=508508
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestAction.java Fri Feb 16 09:34:22 2007
@@ -40,6 +40,7 @@
private Collection collection2;
private Map map;
private String foo;
+ private Integer fooInt;
private String result;
private User user;
private String[] array;
@@ -125,6 +126,14 @@
public void setCollection2(Collection collection) {
this.collection2 = collection;
+ }
+
+ public Integer getFooInt() {
+ return fooInt;
+ }
+
+ public void setFooInt(Integer fooInt) {
+ this.fooInt = fooInt;
}
public String execute() throws Exception {
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java?view=diff&rev=508508&r1=508507&r2=508508
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java Fri Feb 16 09:34:22 2007
@@ -379,6 +379,94 @@
verify(SelectTag.class.getResource("Select-6.txt"));
}
+
+ public void testSimpleInteger() throws Exception {
+ TestAction testAction = (TestAction) action;
+
+ IdName hello = new IdName(new Integer(1), "hello");
+ IdName world = new IdName(new Integer(2), "world");
+ List list2 = new ArrayList();
+ list2.add(hello);
+ list2.add(world);
+ testAction.setList2(list2);
+
+ testAction.setFooInt(new Integer(1));
+
+ SelectTag tag = new SelectTag();
+ tag.setPageContext(pageContext);
+ tag.setEmptyOption("true");
+ tag.setLabel("mylabel");
+ tag.setName("fooInt");
+ tag.setList("list2");
+ tag.setListKey("id");
+ tag.setListValue("name");
+
+ // header stuff
+ tag.setHeaderKey("headerKey");
+ tag.setHeaderValue("headerValue");
+
+ // empty option
+ tag.setEmptyOption("true");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(SelectTag.class.getResource("Select-11.txt"));
+ }
+
+ public void testSimpleIntegerWithValueWorkaround() throws Exception {
+ TestAction testAction = (TestAction) action;
+
+ IdName hello = new IdName(new Integer(1), "hello");
+ IdName world = new IdName(new Integer(2), "world");
+ List list2 = new ArrayList();
+ list2.add(hello);
+ list2.add(world);
+ testAction.setList2(list2);
+
+ testAction.setFooInt(new Integer(1));
+
+ SelectTag tag = new SelectTag();
+ tag.setPageContext(pageContext);
+ tag.setEmptyOption("true");
+ tag.setLabel("mylabel");
+ tag.setName("fooInt");
+ tag.setList("list2");
+ tag.setListKey("id");
+ tag.setListValue("name");
+ tag.setValue("fooInt.toString()");
+
+ // header stuff
+ tag.setHeaderKey("headerKey");
+ tag.setHeaderValue("headerValue");
+
+ // empty option
+ tag.setEmptyOption("true");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(SelectTag.class.getResource("Select-11.txt"));
+ }
+
+ public class IdName {
+ private String name;
+ private Integer id;
+
+ public IdName(Integer id, String name) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+ }
+
private void prepareTagGeneric(SelectTag tag) {
TestAction testAction = (TestAction) action;
ArrayList collection = new ArrayList();
Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-11.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-11.txt?view=auto&rev=508508
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-11.txt (added)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-11.txt Fri Feb 16 09:34:22 2007
@@ -0,0 +1,9 @@
+<tr>
+ <td class="tdLabel"><label for="fooInt" class="label">mylabel:</label></td>
+ <td><select name="fooInt" id="fooInt">
+ <option value="headerKey">headerValue</option>
+ <option value=""></option>
+ <option value="1" selected="selected">hello</option>
+ <option value="2">world</option>
+</select></td>
+</tr>