< prev index next >

test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java

Print this page

        

@@ -24,19 +24,15 @@
 
 import java.io.BufferedWriter;
 import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
+import jaxp.library.JAXPFileBaseTest;
 import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static jaxp.library.JAXPTestUtilities.failCleanup;
-import static jaxp.library.JAXPTestUtilities.failUnexpected;
 import static org.testng.Assert.assertTrue;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLFilterImpl;

@@ -46,15 +42,23 @@
 
 /**
  * Entity resolver should be invoked in XML parse. This test verifies parsing
  * process by checking the output with golden file.
  */
-public class ResolverTest {
+public class ResolverTest extends JAXPFileBaseTest {
     /**
      * Unit test for entityResolver setter.
+     * 
+     * @throws SAXException If there is a problem processing the document.
+     * @throws IOException if the file exists but is a directory rather than
+     *         a regular file, does not exist but cannot be created, or cannot 
+     *         be opened for any other reason.
+     * @throws ParserConfigurationException if a DocumentBuilder cannot be 
+     *         created which satisfies the configuration requested.
      */
-    public void testResolver() {
+    public void testResolver() throws IOException, SAXException, 
+            ParserConfigurationException {
         String outputFile = CLASS_DIR + "EntityResolver.out";
         String goldFile = GOLDEN_DIR + "EntityResolverGF.out";
         String xmlFile = XML_DIR + "publish.xml";
 
         try(FileInputStream instream = new FileInputStream(xmlFile);

@@ -62,27 +66,12 @@
             SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
             XMLReader xmlReader = saxParser.getXMLReader();
             xmlReader.setEntityResolver(eResolver);
             InputSource is = new InputSource(instream);
             xmlReader.parse(is);
-        } catch(IOException | SAXException | ParserConfigurationException ex ) {
-            failUnexpected(ex);
         }
-        // Need close the output file before we compare it with golden file.
-        try {
             assertTrue(compareWithGold(goldFile, outputFile));
-        } catch (IOException ex) {
-            failUnexpected(ex);
-        } finally {
-            try {
-                Path outputPath = Paths.get(outputFile);
-                if(Files.exists(outputPath))
-                    Files.delete(outputPath);
-            } catch (IOException ex) {
-                failCleanup(ex, outputFile);
-            }
-        }
     }
 }
 
 /**
  * Simple entity resolver to write every entity to an output file.
< prev index next >