MCPcopy Create free account
hub / github.com/attoparser/attoparser / MarkupParserTest

Class MarkupParserTest

src/test/java/org/attoparser/MarkupParserTest.java:50–2340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 * @since 2.0.0
49 */
50public class MarkupParserTest {
51
52 private static int totalTestExecutions = 0;
53
54
55 @Test
56 public void test() throws Exception {
57
58
59 final ParseConfiguration noRestrictions = ParseConfiguration.xmlConfiguration();
60 noRestrictions.setElementBalancing(ElementBalancing.NO_BALANCING);
61 noRestrictions.setNoUnmatchedCloseElementsRequired(false);
62 noRestrictions.setUniqueAttributesInElementRequired(false);
63 noRestrictions.setXmlWellFormedAttributeValuesRequired(false);
64 noRestrictions.setUniqueRootElementPresence(UniqueRootElementPresence.NOT_VALIDATED);
65 noRestrictions.getPrologParseConfiguration().setValidateProlog(false);
66
67
68 final ParseConfiguration noRestrictionsUpperCaseDocType = noRestrictions.clone();
69 noRestrictionsUpperCaseDocType.getPrologParseConfiguration().setValidateProlog(true);
70 noRestrictionsUpperCaseDocType.getPrologParseConfiguration().setRequireDoctypeKeywordsUpperCase(true);
71
72 final ParseConfiguration noRestrictionsAutoClose = noRestrictions.clone();
73 noRestrictionsAutoClose.setElementBalancing(ElementBalancing.AUTO_CLOSE);
74
75 final ParseConfiguration noRestrictionsAutoOpenClose = noRestrictions.clone();
76 noRestrictionsAutoOpenClose.setElementBalancing(ElementBalancing.AUTO_OPEN_CLOSE);
77
78 final ParseConfiguration noUnbalacedClosed = noRestrictions.clone();
79 noUnbalacedClosed.setElementBalancing(ElementBalancing.AUTO_CLOSE);
80 noUnbalacedClosed.setNoUnmatchedCloseElementsRequired(true);
81
82 final ParseConfiguration wellFormedXml = noRestrictions.clone();
83 wellFormedXml.setElementBalancing(ElementBalancing.REQUIRE_BALANCED);
84 wellFormedXml.setUniqueAttributesInElementRequired(true);
85 wellFormedXml.setXmlWellFormedAttributeValuesRequired(true);
86 wellFormedXml.getPrologParseConfiguration().setValidateProlog(true);
87 wellFormedXml.getPrologParseConfiguration().setPrologPresence(PrologPresence.ALLOWED);
88 wellFormedXml.getPrologParseConfiguration().setXmlDeclarationPresence(PrologPresence.ALLOWED);
89 wellFormedXml.getPrologParseConfiguration().setDoctypePresence(PrologPresence.ALLOWED);
90 wellFormedXml.setUniqueRootElementPresence(UniqueRootElementPresence.DEPENDS_ON_PROLOG_DOCTYPE);
91
92 final ParseConfiguration wellFormedXmlCaseInsensitive = wellFormedXml.clone();
93 wellFormedXmlCaseInsensitive.setCaseSensitive(false);
94
95
96 final String dt1 = "<!DOCTYPE>";
97 final String dt2 = "<!DOCTYPE html>";
98 final String dt3 = "<!DOCTYPE html public \"lala\">";
99 final String dt4 = "<!DOCTYPE html public \"aaa\" [<!ELEMENT>]>";
100
101 final ISimpleMarkupParser p = new SimpleMarkupParser(noRestrictions);
102
103 StringWriter sw1 = new StringWriter();
104 ISimpleMarkupHandler h = new TextTracerSimpleMarkupHandler(sw1);
105 p.parse(dt1, h);
106 Assertions.assertEquals("[DT()()()(){1,1}]", sw1.toString());
107

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected