struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [07/50] [abbrv] struts git commit: added testcase for WW-4312 / #69
Date Fri, 15 Jul 2016 13:18:34 GMT
added testcase for WW-4312 / #69


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

Branch: refs/heads/master
Commit: 6fd37d86cceeae43a3481ed70ba2f500778249a4
Parents: dad437b
Author: cnenning <cnenning@apache.org>
Authored: Tue Jan 5 13:47:15 2016 +0100
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Tue Jan 19 16:18:00 2016 +0100

----------------------------------------------------------------------
 .../components/IteratorComponentTest.java       | 38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/6fd37d86/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java b/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
index 1115493..c9a075a 100644
--- a/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
+++ b/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
@@ -76,6 +76,44 @@ public class IteratorComponentTest extends StrutsInternalTestCase {
         assertEquals("item2 item3 item4 ", out.getBuffer().toString());
     }
 
+    public void testIteratorWithNulls() throws Exception {
+        // given
+        final ValueStack stack = ActionContext.getContext().getValueStack();
+        stack.push(new FooAction() {
+            private List items  = Arrays.asList("1", "2", null, "4");
+
+            public List getItems() {
+                return items;
+            }
+        });
+
+        StringWriter out = new StringWriter();
+
+        IteratorComponent ic = new IteratorComponent(stack);
+        ic.setValue("items");
+        ic.setVar("val");
+        Property prop = new Property(stack);
+
+        ic.getComponentStack().push(prop);
+        ic.getComponentStack().push(prop);
+        ic.getComponentStack().push(prop);
+        ic.getComponentStack().push(prop);
+
+        String body = ", ";
+
+        // when
+        assertTrue(ic.start(out));
+
+        for (int i = 0; i < 4; i++) {
+            prop.start(out);
+            prop.end(out, body);
+            ic.end(out, null);
+        }
+
+        // then
+        assertEquals("1, 2, , 4, ", out.getBuffer().toString());
+    }
+
     static class FooAction {
 
         private List items;


Mime
View raw message