test/javax/xml/jaxp/parsers/8022548/XOMParserTest.java

Print this page

        

@@ -20,11 +20,12 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
 /**
- * @test @bug 8022548
+ * @test 
+ * @bug 8022548
  * @summary test that a parser can use DTDConfiguration
  * @run main XOMParserTest
  */
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.parsers.*;

@@ -58,34 +59,31 @@
         test.testTransform();
         test.tearDown();
     }
 
     public final void testTransform() {
-
-        try {
-
             String inFilename = filePath + "/JDK8022548.xml";
             String xslFilename = filePath + "/JDK8022548.xsl";
             String outFilename = "JDK8022548.out";
 
+        try (InputStream xslInput = new FileInputStream(xslFilename);
+             InputStream xmlInput = new FileInputStream(inFilename);
+             OutputStream out = new FileOutputStream(outFilename);
+        ) {
+
+
             StringWriter sw = new StringWriter();
             // Create transformer factory
             TransformerFactory factory = TransformerFactory.newInstance();
-            // set the translet name
-//            factory.setAttribute("translet-name", "myTranslet");
 
-            // set the destination directory
-//            factory.setAttribute("destination-directory", "c:\\temp");
-//            factory.setAttribute("generate-translet", Boolean.TRUE);
-
             // Use the factory to create a template containing the xsl file
-            Templates template = factory.newTemplates(new StreamSource(new FileInputStream(xslFilename)));
+            Templates template = factory.newTemplates(new StreamSource(xslInput));
             // Use the template to create a transformer
             Transformer xformer = template.newTransformer();
             // Prepare the input and output files
-            Source source = new StreamSource(new FileInputStream(inFilename));
-            Result result = new StreamResult(new FileOutputStream(outFilename));
+            Source source = new StreamSource(xmlInput);
+            Result result = new StreamResult(outFilename);
             //Result result = new StreamResult(sw);
             // Apply the xsl file to the source file and write the result to the output file
             xformer.transform(source, result);
 
             /**