org.jdom2.test.cases.input.TestDTDParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdom Show documentation
Show all versions of jdom Show documentation
A complete, Java-based solution for accessing, manipulating,
and outputting XML data
package org.jdom2.test.cases.input;
import static org.junit.Assert.*;
import org.jdom2.DocType;
import org.jdom2.JDOMException;
import org.jdom2.JDOMFactory;
import org.jdom2.DefaultJDOMFactory;
import org.jdom2.input.stax.DTDParser;
import org.jdom2.test.util.UnitTestUtil;
import org.junit.Test;
@SuppressWarnings("javadoc")
public class TestDTDParser {
private static final JDOMFactory factory = new DefaultJDOMFactory();
@Test
public void testParseSimple() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseSimpleCompact() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseSimpleCompactInternal() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals("internal", dt.getInternalSubset());
}
@Test
public void testParseSYSTEMquotNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseSYSTEMaposNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseSYSTEMquotSimple() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals("internal", dt.getInternalSubset());
}
@Test
public void testParseSYSTEMaposSimple() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals("internal", dt.getInternalSubset());
}
@Test
public void testParsePUBLICquotenullNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParsePUBLICaposnullNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParsePUBLICquotquotNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParsePUBLICquotaposNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParsePUBLICaposquotNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParsePUBLICaposaposNONE() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParsePUBLICaposaposSimple() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals("internal", dt.getInternalSubset());
}
@Test
public void testParsePUBLICaposaposSimpleCompact() throws JDOMException {
DocType dt = DTDParser.parse(
"",
factory);
assertEquals("root", dt.getElementName());
assertEquals("public", dt.getPublicID());
assertEquals("system", dt.getSystemID());
assertEquals("internal", dt.getInternalSubset());
}
@Test
public void testParsePUBLICaposaposSimpleSpacy() throws JDOMException {
DocType dt = DTDParser.parse(
" ] > ",
factory);
assertEquals("root", dt.getElementName());
assertEquals(" public ", dt.getPublicID());
assertEquals(" system ", dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
@Test
public void testParseInternalA() throws JDOMException {
DocType dt = DTDParser.parse(
"]>",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n \n", dt.getInternalSubset());
}
@Test
public void testParseInternalEmbeddedNewlines() throws JDOMException {
DocType dt = DTDParser.parse(
" \n \n ] \n >",
factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n \n", dt.getInternalSubset());
}
@Test
public void testParseIncomplete() {
try {
DTDParser.parse("",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseTab() throws JDOMException {
DocType dt = DTDParser.parse("",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseNewline() throws JDOMException {
DocType dt = DTDParser.parse("",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseCarriageReturn() throws JDOMException {
DocType dt = DTDParser.parse("",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(null, dt.getInternalSubset());
}
@Test
public void testParseInternalSpace() throws JDOMException {
DocType dt = DTDParser.parse(" ] >",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
@Test
public void testParseInternalTab() throws JDOMException {
DocType dt = DTDParser.parse("\t]\t>",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
@Test
public void testParseInternalNewline() throws JDOMException {
DocType dt = DTDParser.parse("\n]\n>",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
@Test
public void testParseInternalCarriageReturn() throws JDOMException {
DocType dt = DTDParser.parse("\r]\r>",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
@Test
public void testParseInternalWithAPosSpace() throws JDOMException {
DocType dt = DTDParser.parse("]>",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
@Test
public void testParseInternalWithQuoteSpace() throws JDOMException {
DocType dt = DTDParser.parse("]>",factory);
assertEquals("root", dt.getElementName());
assertEquals(null, dt.getPublicID());
assertEquals(null, dt.getSystemID());
assertEquals(" \n", dt.getInternalSubset());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy