Unit testing: confirm that Analyzer can parse some sample XML
[cfb.git] / prod / net / jaekl / cfb / analyze / Analysis.java
index 4e289e2366c4816a679dd0b39019b118b90fb2b7..ab9fffbe798e90b8d23d52a3347008ec931316e3 100644 (file)
@@ -2,22 +2,19 @@ package net.jaekl.cfb.analyze;
 
 // Copyright (C) 2015 Christian Jaekl
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintWriter;
 
+import net.jaekl.cfb.xml.BugCollection;
+import net.jaekl.qd.xml.ParseErrorHandler;
+import net.jaekl.qd.xml.ParseHandler;
+
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
 
-import net.jaekl.cfb.xml.BugCollection;
-import net.jaekl.qd.util.InputStreamWrapper;
-import net.jaekl.qd.xml.ParseErrorHandler;
-import net.jaekl.qd.xml.ParseHandler;
-
 public class Analysis {
        BugCollection m_bugCollection;
        
@@ -27,19 +24,16 @@ public class Analysis {
        
        public BugCollection getBugCollection() { return m_bugCollection; }
        
-       public void parse(File xml) throws FileNotFoundException, IOException, SAXException 
+       public void parse(InputSource xml) throws FileNotFoundException, IOException, SAXException 
        {
                m_bugCollection = new BugCollection();
                
-               try (InputStreamWrapper isw = new InputStreamWrapper(new FileInputStream(xml))) 
-               {
-                   XMLReader reader = XMLReaderFactory.createXMLReader();
-                   ParseHandler ph = new ParseHandler(m_bugCollection);
-                   ParseErrorHandler peh = new ParseErrorHandler();
-                   reader.setContentHandler(ph);
-                   reader.setErrorHandler(peh);
-                   reader.parse(new InputSource(isw));
-               }
+           XMLReader reader = XMLReaderFactory.createXMLReader();
+           ParseHandler ph = new ParseHandler(m_bugCollection);
+           ParseErrorHandler peh = new ParseErrorHandler();
+           reader.setContentHandler(ph);
+           reader.setErrorHandler(peh);
+           reader.parse(xml);
        }
        
        public void dump(PrintWriter pw)