Skip to content

Commit

Permalink
added testcase for WW-4312 / apache#69
Browse files Browse the repository at this point in the history
  • Loading branch information
cnenning committed Jan 5, 2016
1 parent f457c77 commit 4f29d88
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,44 @@ public void testIteratorWithBegin() throws Exception {
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;
Expand Down

0 comments on commit 4f29d88

Please sign in to comment.