@@ -908,8 +908,7 @@ public void formatXml() {
908908 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <root><element>1</element>"
909909 + "<element>2</element></root>" ));
910910 assertEquals (
911- "<a>\n <b></b>\n <b></b>\n </a>" ,
912- U .formatXml ("<a>\n <b></b>\n <b></b>\n </a>" ));
911+ "<a>\n <b></b>\n <b></b>\n </a>" , U .formatXml ("<a>\n <b></b>\n <b></b>\n </a>" ));
913912 assertEquals (
914913 "<a>\n <b></b>\n <b></b>\n </a>" ,
915914 U .formatXml (
@@ -998,6 +997,66 @@ public void replaceNullWithEmptyValue() {
998997 U .replaceNullWithEmptyValue (map2 );
999998 }
1000999
1000+ @ Test
1001+ public void replaceNilWithNull () {
1002+ assertEquals (
1003+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1004+ + "<RootElm>\n "
1005+ + " <author>\n "
1006+ + " <DOB nil=\" true\" ></DOB>\n "
1007+ + " <value null=\" true\" />\n "
1008+ + " </author>\n "
1009+ + "</RootElm>" ,
1010+ U .toXml (
1011+ U .replaceNilWithNull (
1012+ U .fromXmlMap (
1013+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1014+ + "<RootElm>\n "
1015+ + " <author>\n "
1016+ + " <DOB nil=\" true\" ></DOB>\n "
1017+ + " <value nil=\" true\" />\n "
1018+ + " </author>\n "
1019+ + "</RootElm>" ))));
1020+ assertEquals (
1021+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1022+ + "<RootElm xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" >\n "
1023+ + " <author>\n "
1024+ + " <DOB xsi:nil=\" true\" ></DOB>\n "
1025+ + " <value null=\" true\" />\n "
1026+ + " <DOB2 xsi:nil=\" true1\" ></DOB2>\n "
1027+ + " <value2 xsi:nil=\" true1\" />\n "
1028+ + " </author>\n "
1029+ + "</RootElm>" ,
1030+ U .toXml (
1031+ U .replaceNilWithNull (
1032+ U .fromXmlMap (
1033+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1034+ + "<RootElm xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" >\n "
1035+ + " <author>\n "
1036+ + " <DOB xsi:nil=\" true\" ></DOB>\n "
1037+ + " <value xsi:nil=\" true\" />\n "
1038+ + " <DOB2 xsi:nil=\" true1\" ></DOB2>\n "
1039+ + " <value2 xsi:nil=\" true1\" />\n "
1040+ + " </author>\n "
1041+ + "</RootElm>" ))));
1042+ Map <String , Object > map = U .newLinkedHashMap ();
1043+ List <Object > list = U .newArrayList ();
1044+ list .add (U .newLinkedHashMap ());
1045+ map .put ("list" , list );
1046+ U .replaceNilWithNull (map );
1047+ Map <String , Object > map2 = U .newLinkedHashMap ();
1048+ List <Object > list2 = U .newArrayList ();
1049+ list2 .add (U .newArrayList ());
1050+ map2 .put ("list" , list2 );
1051+ U .replaceNilWithNull (map2 );
1052+ Map <String , Object > map3 = U .newLinkedHashMap ();
1053+ map3 .put ("-nil" , "true" );
1054+ map3 .put ("-self-closing" , "true1" );
1055+ Map <String , Object > map4 = U .newLinkedHashMap ();
1056+ map4 .put ("map" , map3 );
1057+ U .replaceNilWithNull (map4 );
1058+ }
1059+
10011060 @ Test
10021061 public void replaceEmptyStringWithEmptyValue () {
10031062 assertEquals (
0 commit comments