// no else block
StringReader reader = new StringReader("${loop}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${/if}"
+ "${/loop}");
StringWriter writer = new StringWriter();
new DefaultParser(reader, writer).perform(dataFieldResolver);
Assert.assertEquals("2", writer.toString());
StringReader reader2 = new StringReader("${loop}" + "${numberArray}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${/if}"
+ "${/loop}");
StringWriter writer2 = new StringWriter();
new DefaultParser(reader2, writer2).perform(dataFieldResolver);
Assert.assertEquals("0122345", writer2.toString());
StringReader reader3 = new StringReader("${loop}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${/if}"
+ "${numberArray}" + "${/loop}");
StringWriter writer3 = new StringWriter();
new DefaultParser(reader3, writer3).perform(dataFieldResolver);
Assert.assertEquals("0122345", writer3.toString());
// empty else block
StringReader reader4 = new StringReader("${loop}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${else}"
+ "${/if}" + "${/loop}");
StringWriter writer4 = new StringWriter();
new DefaultParser(reader4, writer4).perform(dataFieldResolver);
Assert.assertEquals("2", writer4.toString());
StringReader reader5 = new StringReader("${loop}" + "${numberArray}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${else}"
+ "${/if}" + "${/loop}");
StringWriter writer5 = new StringWriter();
new DefaultParser(reader5, writer5).perform(dataFieldResolver);
Assert.assertEquals("0122345", writer5.toString());
StringReader reader6 = new StringReader("${loop}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${else}"
+ "${/if}" + "${numberArray}" + "${/loop}");
StringWriter writer6 = new StringWriter();
new DefaultParser(reader6, writer6).perform(dataFieldResolver);
Assert.assertEquals("0122345", writer6.toString());
// with content in else block
StringReader reader7 = new StringReader("${loop}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${else}"
+ "${numberArray}" + "${/if}" + "${/loop}");
StringWriter writer7 = new StringWriter();
new DefaultParser(reader7, writer7).perform(dataFieldResolver);
Assert.assertEquals("012345", writer7.toString());
StringReader reader8 = new StringReader("${loop}" + "${numberArray}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${else}"
+ "${numberArray}" + "${/if}" + "${/loop}");
StringWriter writer8 = new StringWriter();
new DefaultParser(reader8, writer8).perform(dataFieldResolver);
Assert.assertEquals("001122334455", writer8.toString());
StringReader reader9 = new StringReader("${loop}"
+ "${if numberArray = \"2\"}" + "${numberArray}" + "${else}"
+ "${numberArray}" + "${/if}" + "${numberArray}" + "${/loop}");
StringWriter writer9 = new StringWriter();
new DefaultParser(reader9, writer9).perform(dataFieldResolver);
Assert.assertEquals("001122334455", writer9.toString());
}