struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4837 Adds a test to test how Strings are treated
Date Fri, 04 Aug 2017 06:16:42 GMT
Repository: struts
Updated Branches:
  refs/heads/master 3e53a58bb -> c9d20b573


WW-4837 Adds a test to test how Strings are treated


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c9d20b57
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c9d20b57
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c9d20b57

Branch: refs/heads/master
Commit: c9d20b573efbdd74e683c767663b2bd02cea5fd7
Parents: 3e53a58
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Fri Aug 4 08:16:28 2017 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Fri Aug 4 08:16:28 2017 +0200

----------------------------------------------------------------------
 .../apache/struts2/views/jsp/ui/SelectTest.java | 59 ++++++++++++++++++++
 .../apache/struts2/views/jsp/ui/Select-15.txt   | 11 ++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/c9d20b57/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
index c6587df..58ff079 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import com.sun.xml.internal.bind.v2.util.StackRecorder;
 import org.apache.struts2.TestAction;
 import org.apache.struts2.views.jsp.AbstractUITagTest;
 
@@ -174,6 +175,46 @@ public class SelectTest extends AbstractUITagTest {
         verify(SelectTag.class.getResource("Select-14.txt"));
     }
 
+    public void testNumericString() throws Exception {
+        StringObject hello = new StringObject("hello", "1");
+        StringObject foo = new StringObject("foo", "2");
+
+        TestAction testAction = (TestAction) action;
+
+        Collection collection = new ArrayList(2);
+        // expect strings to be returned, we're still dealing with HTTP here!
+        collection.add("hello");
+        collection.add("foo");
+        testAction.setCollection(collection);
+
+        List list2 = new ArrayList();
+        list2.add(hello);
+        list2.add(foo);
+        list2.add(new StringObject("<cat>", "1.5"));
+        list2.add(new StringObject("<dog>", "2,5"));
+        testAction.setList2(list2);
+
+        SelectTag tag = new SelectTag();
+        tag.setPageContext(pageContext);
+        tag.setLabel("mylabel");
+        tag.setName("collection");
+        tag.setList("list2");
+        tag.setListKey("name");
+        tag.setListValue("number");
+        tag.setMultiple("true");
+        tag.setTitle("mytitle");
+        tag.setOnmousedown("alert('onmousedown');");
+        tag.setOnmousemove("alert('onmousemove');");
+        tag.setOnmouseout("alert('onmouseout');");
+        tag.setOnmouseover("alert('onmouseover');");
+        tag.setOnmouseup("alert('onmouseup');");
+
+        tag.doStartTag();
+        tag.doEndTag();
+
+        verify(SelectTag.class.getResource("Select-15.txt"));
+    }
+
     public class BigDecimalObject {
         private String name;
         private BigDecimal bigDecimal;
@@ -210,6 +251,24 @@ public class SelectTest extends AbstractUITagTest {
         }
     }
 
+    public class StringObject {
+        private String name;
+        private String number;
+
+        public StringObject(String name, String number) {
+            this.name = name;
+            this.number = number;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getNumber() {
+            return number;
+        }
+    }
+
     public class ByteObject {
         private String name;
         private Byte byteValue;

http://git-wip-us.apache.org/repos/asf/struts/blob/c9d20b57/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-15.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-15.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-15.txt
new file mode 100644
index 0000000..e5dc63e
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-15.txt
@@ -0,0 +1,11 @@
+<tr>
+    <td class="tdLabel"><label for="collection" class="label">mylabel:</label></td>
+    <td class="tdInput"><select name="collection" id="collection" title="mytitle"
multiple="multiple" onmousedown="alert('onmousedown');" onmouseup="alert('onmouseup');" onmouseover="alert('onmouseover');"
onmousemove="alert('onmousemove');" onmouseout="alert('onmouseout');">
+    <option value="hello" selected="selected">1</option>
+    <option value="foo" selected="selected">2</option>
+    <option value="&lt;cat&gt;">1.5</option>
+    <option value="&lt;dog&gt;">2,5</option>
+</select>
+<inputtype="hidden" id="__multiselect_collection" name="__multiselect_collection" value=""/>
+</td>
+</tr>


Mime
View raw message