* only a single LiteralChunk.
*/
public void testAddParameterAddLiteralSequence() {
ParsedHtmlTemplate parsed = new ParsedHtmlTemplate();
parsed.addParameter(new ParameterChunk(new HtmlContext(
HtmlContext.Type.TEXT), 0));
parsed.addLiteral("<a");
parsed.addLiteral(" href=\"");
parsed.addParameter(new ParameterChunk(new HtmlContext(
HtmlContext.Type.URL_ATTRIBUTE_START, "a", "href"), 1));
List<TemplateChunk> chunks = parsed.getChunks();
assertEquals(3, chunks.size());
Iterator<TemplateChunk> it = chunks.iterator();
LiteralChunk litChunk;
ParameterChunk paramChunk;
paramChunk = (ParameterChunk) it.next();
assertEquals(TemplateChunk.Kind.PARAMETER, paramChunk.getKind());
assertEquals(HtmlContext.Type.TEXT, paramChunk.getContext().getType());
assertNull(paramChunk.getContext().getTag());
assertNull(paramChunk.getContext().getAttribute());
assertEquals(0, paramChunk.getParameterIndex());
assertEquals("P((TEXT,null,null),0)", paramChunk.toString());
litChunk = (LiteralChunk) it.next();
assertEquals(TemplateChunk.Kind.LITERAL, litChunk.getKind());
assertEquals("<a href=\"", litChunk.getLiteral());
assertEquals("L(<a href=\")", litChunk.toString());
paramChunk = (ParameterChunk) it.next();
assertEquals(TemplateChunk.Kind.PARAMETER, paramChunk.getKind());
assertEquals(
HtmlContext.Type.URL_ATTRIBUTE_START, paramChunk.getContext().getType());
assertEquals("a", paramChunk.getContext().getTag());
assertEquals("href", paramChunk.getContext().getAttribute());
assertEquals(1, paramChunk.getParameterIndex());
assertEquals("P((URL_ATTRIBUTE_START,a,href),1)", paramChunk.toString());
assertEquals(
"[P((TEXT,null,null),0), L(<a href=\"), "
+ "P((URL_ATTRIBUTE_START,a,href),1)]",
parsed.toString());