11package  com .github .bazel_contrib .contrib_rules_jvm .junit5 ;
22
3- import  org .junit .jupiter .api .Test ;
4- import  org .w3c .dom .Document ;
5- import  org .w3c .dom .Node ;
6- import  org .xml .sax .InputSource ;
7- import  org .xml .sax .SAXException ;
3+ import  static  org .junit .jupiter .api .Assertions .assertEquals ;
84
5+ import  java .io .IOException ;
6+ import  java .io .Reader ;
7+ import  java .io .StringReader ;
8+ import  java .io .StringWriter ;
9+ import  java .io .Writer ;
910import  javax .xml .parsers .DocumentBuilder ;
1011import  javax .xml .parsers .DocumentBuilderFactory ;
1112import  javax .xml .parsers .ParserConfigurationException ;
1213import  javax .xml .stream .XMLOutputFactory ;
1314import  javax .xml .stream .XMLStreamException ;
1415import  javax .xml .stream .XMLStreamWriter ;
15- import  java .io .IOException ;
16- import  java .io .Reader ;
17- import  java .io .StringReader ;
18- import  java .io .StringWriter ;
19- import  java .io .Writer ;
20- 
21- import  static  org .junit .jupiter .api .Assertions .assertEquals ;
16+ import  org .junit .jupiter .api .Test ;
17+ import  org .w3c .dom .Document ;
18+ import  org .w3c .dom .Node ;
19+ import  org .xml .sax .InputSource ;
20+ import  org .xml .sax .SAXException ;
2221
2322public  class  SafeXmlTest  {
2423
25-      @ Test 
26-      public  void  properlyEscapesCDataSection ()
27-              throws  XMLStreamException , ParserConfigurationException , IOException , SAXException  {
28-          try  (Writer  writer  = new  StringWriter ()) {
29-              XMLStreamWriter  xml  = XMLOutputFactory .newDefaultFactory ().createXMLStreamWriter (writer );
24+   @ Test 
25+   public  void  properlyEscapesCDataSection ()
26+       throws  XMLStreamException , ParserConfigurationException , IOException , SAXException  {
27+     try  (Writer  writer  = new  StringWriter ()) {
28+       XMLStreamWriter  xml  = XMLOutputFactory .newDefaultFactory ().createXMLStreamWriter (writer );
3029
31-              xml .writeStartDocument ("UTF-8" , "1.0" );
32-              // Output the "end of cdata" marker 
33-              SafeXml .writeTextElement (xml , "container" , "]]>" );
34-              xml .writeEndDocument ();
30+       xml .writeStartDocument ("UTF-8" , "1.0" );
31+       // Output the "end of cdata" marker 
32+       SafeXml .writeTextElement (xml , "container" , "]]>" );
33+       xml .writeEndDocument ();
3534
36-              DocumentBuilderFactory  factory  = DocumentBuilderFactory .newInstance ();
37-              DocumentBuilder  builder ;
38-              try  (Reader  reader  = new  StringReader (writer .toString ())) {
39-                  builder  = factory .newDocumentBuilder ();
40-                  Document  parsed  = builder .parse (new  InputSource (reader ));
35+       DocumentBuilderFactory  factory  = DocumentBuilderFactory .newInstance ();
36+       DocumentBuilder  builder ;
37+       try  (Reader  reader  = new  StringReader (writer .toString ())) {
38+         builder  = factory .newDocumentBuilder ();
39+         Document  parsed  = builder .parse (new  InputSource (reader ));
4140
42-                  Node  container  = parsed .getElementsByTagName ("container" ).item (0 );
41+         Node  container  = parsed .getElementsByTagName ("container" ).item (0 );
4342
44-                 assertEquals ("]]>" , container .getTextContent ());
45-             }
46-         }
43+         assertEquals ("]]>" , container .getTextContent ());
44+       }
4745    }
48- }
46+   }
47+ }
0 commit comments