use of org.apache.wicket.markup.parser.AbstractMarkupFilter in project wicket by apache.
the class OpenCloseTagExpanderTest method doNotExpandVoidElements.
/**
* https://issues.apache.org/jira/browse/WICKET-5237
*
* @throws ParseException
*/
@Test
public void doNotExpandVoidElements() throws ParseException {
String[] htmlVoidElements = new String[] { "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr" };
for (String htmlVoidElement : htmlVoidElements) {
OpenCloseTagExpander expander = new OpenCloseTagExpander() {
@Override
public IMarkupFilter getNextFilter() {
return new AbstractMarkupFilter() {
@Override
protected MarkupElement onComponentTag(ComponentTag tag) throws ParseException {
return null;
}
@Override
public MarkupElement nextElement() throws ParseException {
return new TestMarkupElement();
}
};
}
};
ComponentTag tag = new ComponentTag(htmlVoidElement, XmlTag.TagType.OPEN_CLOSE);
expander.onComponentTag(tag);
MarkupElement markupElement = expander.nextElement();
// assert the next element is returned by the parent
assertThat(markupElement, instanceOf(TestMarkupElement.class));
}
}
use of org.apache.wicket.markup.parser.AbstractMarkupFilter in project wicket by apache.
the class OpenCloseTagExpanderTest method expandNonVoidElements.
/**
* https://issues.apache.org/jira/browse/WICKET-5237
*
* @throws ParseException
*/
@Test
public void expandNonVoidElements() throws ParseException {
for (String htmlNonVoidElement : OpenCloseTagExpander.REPLACE_FOR_TAGS) {
OpenCloseTagExpander expander = new OpenCloseTagExpander() {
@Override
public IMarkupFilter getNextFilter() {
return new AbstractMarkupFilter() {
@Override
protected MarkupElement onComponentTag(ComponentTag tag) throws ParseException {
return null;
}
@Override
public MarkupElement nextElement() throws ParseException {
return new TestMarkupElement();
}
};
}
};
ComponentTag tag = new ComponentTag(htmlNonVoidElement, XmlTag.TagType.OPEN_CLOSE);
expander.onComponentTag(tag);
ComponentTag markupElement = (ComponentTag) expander.nextElement();
// assert the next element is returned by the parent
assertEquals(htmlNonVoidElement, markupElement.getName());
assertTrue(markupElement.closes(tag));
}
}
Aggregations