77import tools .jackson .dataformat .xml .XmlTestUtil ;
88
99import static org .junit .jupiter .api .Assertions .assertEquals ;
10+ import static org .junit .jupiter .api .Assertions .fail ;
1011
1112public 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