public void testCompositeTagWithAnotherTagChild() throws ParserException { String childtag = "<Another/>"; createParser("<Custom>" + childtag + "</Custom>"); parser.setNodeFactory( new PrototypicalNodeFactory( new Tag[] { new CustomTag(), new AnotherTag(true), })); parseAndAssertNodeCount(1); assertType("node", CustomTag.class, node[0]); CustomTag customTag = (CustomTag) node[0]; assertEquals("child count", 1, customTag.getChildCount()); assertFalse("custom tag should not be xml end tag", customTag.isEmptyXmlTag()); assertEquals("starting loc", 0, customTag.getStartPosition()); assertEquals("ending loc", 8, customTag.getEndPosition()); assertEquals("custom tag starting loc", 0, customTag.getStartPosition()); assertEquals("custom tag ending loc", 27, customTag.getEndTag().getEndPosition()); Node child = customTag.childAt(0); assertType("child", AnotherTag.class, child); AnotherTag tag = (AnotherTag) child; assertEquals("another tag start pos", 8, tag.getStartPosition()); assertEquals("another tag ending pos", 18, tag.getEndPosition()); assertEquals("custom end tag start pos", 18, customTag.getEndTag().getStartPosition()); assertStringEquals("child html", childtag, child.toHtml()); }
public void testCompositeTagWithErroneousAnotherTag() throws ParserException { createParser("<custom>" + "<another>" + "</custom>"); parser.setNodeFactory( new PrototypicalNodeFactory( new Tag[] { new CustomTag(), new AnotherTag(true), })); parseAndAssertNodeCount(1); assertType("node", CustomTag.class, node[0]); CustomTag customTag = (CustomTag) node[0]; assertEquals("child count", 1, customTag.getChildCount()); assertFalse("custom tag should be xml end tag", customTag.isEmptyXmlTag()); assertEquals("starting loc", 0, customTag.getStartPosition()); assertEquals("ending loc", 8, customTag.getEndPosition()); AnotherTag anotherTag = (AnotherTag) customTag.childAt(0); assertEquals("another tag ending loc", 17, anotherTag.getEndPosition()); assertEquals("starting line position", 0, customTag.getStartingLineNumber()); assertEquals("ending line position", 0, customTag.getEndingLineNumber()); assertStringEquals("html", "<custom><another></another></custom>", customTag.toHtml()); }