Skip to content

Commit 52e02a5

Browse files
committed
Bit more testing
1 parent 42510b1 commit 52e02a5

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/main/java/tools/jackson/dataformat/xml/ser/DTD.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static String _emptyToNull(String str) {
2222

2323
static String _nonEmptyNonNull(String prop, String str) {
2424
if (str == null || str.isEmpty()) {
25-
throw new IllegalArgumentException("Illegal argument for `%s`: must be non-empty String"
25+
throw new IllegalArgumentException("Illegal argument for '%s': must be non-empty String"
2626
.formatted(prop));
2727
}
2828
return str;

src/test/java/tools/jackson/dataformat/xml/ser/XmlGeneratorInitializerTest.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tools.jackson.dataformat.xml.XmlTestUtil;
88

99
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
import static org.junit.jupiter.api.Assertions.fail;
1011

1112
public class XmlGeneratorInitializerTest extends XmlTestUtil
1213
{
@@ -18,7 +19,7 @@ public void testDTDWithPublicId() throws Exception
1819
{
1920
ObjectWriter w = MAPPER.writer().with(
2021
new XmlGeneratorInitializer()
21-
.withDTD("StringBean", "system", "http://foo.bar", null));
22+
.withDTD("StringBean", "system", "http://foo.bar", ""));
2223
assertEquals(a2q("<!DOCTYPE StringBean PUBLIC 'http://foo.bar' 'system'>"
2324
+"<StringBean><text>test</text></StringBean>"),
2425
w.writeValueAsString(new StringBean("test")));
@@ -29,7 +30,7 @@ public void testDTDWithSystemIdOnly() throws Exception
2930
{
3031
ObjectWriter w = MAPPER.writer().with(
3132
new XmlGeneratorInitializer()
32-
.withDTD("StringBean", "system", null, null));
33+
.withDTD("StringBean", "system", "", null));
3334
assertEquals(a2q("<!DOCTYPE StringBean SYSTEM 'system'>"
3435
+"<StringBean><text>test</text></StringBean>"),
3536
w.writeValueAsString(new StringBean("test")));
@@ -46,4 +47,19 @@ public void testDTDWithInternalSubset() throws Exception
4647
+"<StringBean><text>test</text></StringBean>"),
4748
w.writeValueAsString(new StringBean("test")));
4849
}
50+
51+
@Test
52+
public void testDTDInvalidNoRoot() throws Exception
53+
{
54+
try {
55+
/*ObjectWriter w =*/ MAPPER.writer().with(
56+
new XmlGeneratorInitializer()
57+
.withDTD("", null, null, null));
58+
fail("Should not pass");
59+
} catch (IllegalArgumentException e) {
60+
verifyException(e, "Illegal argument for 'rootName': must be");
61+
}
62+
}
63+
64+
// Other tests
4965
}

0 commit comments

Comments
 (0)