@@ -499,7 +499,8 @@ void fetchGet() {
499499 void downloadUrl () throws IOException {
500500 long result =
501501 U .downloadUrl (
502- "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" , "test.json" );
502+ "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" ,
503+ "test.json" );
503504 assertEquals (65 , result );
504505 }
505506
@@ -643,6 +644,39 @@ void fetchWrongUrlWithRetry() {
643644 UnsupportedOperationException .class , () -> U .fetch ("ttt" , 30000 , 30000 , 1 , 100 ));
644645 }
645646
647+ @ Test
648+ void toJson () {
649+ Map <String , Object > map = U .newLinkedHashMap ();
650+ map .put (null , 3 );
651+ assertEquals ("{\n \" null\" : 3\n }" , U .toJson (map ));
652+ Map <Object , Object > map2 = U .newLinkedHashMap ();
653+ map2 .put (1 , 3 );
654+ assertEquals ("{\n \" 1\" : 3\n }" , U .toJson (map2 ));
655+ Map <Object , Object > map3 = U .newLinkedHashMap ();
656+ map3 .put (true , 3 );
657+ assertEquals ("{\n \" true\" : 3\n }" , U .toJson (map3 ));
658+ }
659+
660+ @ Test
661+ void toXml () {
662+ Map <String , Object > map = U .newLinkedHashMap ();
663+ map .put (null , 3 );
664+ assertEquals (
665+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <null number=\" true\" >3</null>" ,
666+ U .toXml (map ));
667+ Map <Object , Object > map2 = U .newLinkedHashMap ();
668+ map2 .put (1 , 3 );
669+ assertEquals (
670+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
671+ + "<__GE__ number=\" true\" >3</__GE__>" ,
672+ U .toXml (map2 ));
673+ Map <Object , Object > map3 = U .newLinkedHashMap ();
674+ map3 .put (true , 3 );
675+ assertEquals (
676+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <true number=\" true\" >3</true>" ,
677+ U .toXml (map3 ));
678+ }
679+
646680 @ Test
647681 void xmlToJson () {
648682 assertEquals (
@@ -662,8 +696,9 @@ void xmlToJson() {
662696 + " ],\n "
663697 + " \" #omit-xml-declaration\" : \" yes\" \n "
664698 + "}" ,
665- U .xmlToJson ("<root><element>1</element><element>2</element></root>" ,
666- Json .JsonStringBuilder .Step .TWO_SPACES ));
699+ U .xmlToJson (
700+ "<root><element>1</element><element>2</element></root>" ,
701+ Json .JsonStringBuilder .Step .TWO_SPACES ));
667702 assertEquals (
668703 "{\n "
669704 + " \" root\" : [\n "
@@ -743,6 +778,9 @@ void xmlToJson() {
743778 Map <String , Object > map = U .newLinkedHashMap ();
744779 map .put ("-self-closing" , "false" );
745780 U .replaceSelfClosingWithNull (map );
781+ Map <String , Object > mapEmpty = U .newLinkedHashMap ();
782+ mapEmpty .put ("-self-closing" , "true" );
783+ U .replaceSelfClosingWithEmpty (mapEmpty );
746784 Map <String , Object > map2 = U .newLinkedHashMap ();
747785 List <Object > list = U .newArrayList ();
748786 list .add (U .newArrayList ());
@@ -1204,8 +1242,7 @@ void changeXmlEncoding() {
12041242 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?><a>Test</a>" ,
12051243 Xml .XmlStringBuilder .Step .COMPACT ,
12061244 "windows-1251" ));
1207- assertEquals (
1208- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?><root>null</root>" ,
1245+ assertNull (
12091246 U .changeXmlEncoding (null , Xml .XmlStringBuilder .Step .COMPACT , "windows-1251" ));
12101247 }
12111248
0 commit comments