public void testSpaceContainingPublicIDs() {
// According to section 4.2.2 of the XML spec, public IDs are
// normalized like attribute values of non-CDATA type
try {
new DocType("root", " test", "http://www.example.org");
fail("allowed initial space in public ID");
}
catch (WellformednessException success) {
assertNotNull(success.getMessage());
}
try {
new DocType("root", "test ", "http://www.example.org");
fail("allowed trailing space in public ID");
}
catch (WellformednessException success) {
assertNotNull(success.getMessage());
}
try {
new DocType("root", "test\ntest", "http://www.example.org");
fail("allowed linefeed public ID");
}
catch (WellformednessException success) {
assertNotNull(success.getMessage());
}
try {
new DocType("root", "test\rtest", "http://www.example.org");
fail("allowed carriage return in public ID");
}
catch (WellformednessException success) {
assertNotNull(success.getMessage());
}
try {
new DocType("root", "test\r\ntest", "http://www.example.org");
fail("allowed carriage return linefeed pair public ID");
}
catch (WellformednessException success) {
assertNotNull(success.getMessage());
}
try {
new DocType("root", "test test", "http://www.example.org");
fail("allowed multiple consecutive spaces in public ID");
}
catch (WellformednessException success) {
assertNotNull(success.getMessage());
}
// one space is legal
DocType test = new DocType("root", "test test", "http://www.example.org");
assertEquals(test.getPublicID(), "test test");
}