TraceFileReader { protected UserTraceLog parseTraceXml() throws IOException, ParserConfigurationException, SAXException { TraceParser traceParser = new TraceParser(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); SAXParser parser = factory.newSAXParser(); parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); parser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); XMLReader xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(traceParser); xmlReader.parse(new InputSource(new FileInputStream(traceFile))); return traceParser.getResult(); } TraceFileReader(File traceFile); TraceFileReader readTrace(ExecutionDataVisitor executionDataVisitor); String inputStreamToString(InputStream is); int getModuleCount(); ModuleExecutionData getModuleExecutionData(String moduleName);  }
@Test public void parserTest() throws Exception { assertThat(new UserTraceLog().getUserTraceOrInformation()).isNotNull(); UserTraceLog trace = new TraceFileReader(new File("src/test/resources/codecoverage/trace.xml")).parseTraceXml(); assertThat(trace.getBufferSize()).isEqualTo(0); assertThat(trace.getFileMode()).isEqualTo("safe"); assertThat(trace.getFileSize()).isEqualTo(20480000); assertThat(trace.getTraceFilter()).isEqualTo("none"); assertThat(trace.getTraceLevel()).isEqualTo("none"); assertThat(trace.getUserTraceFilter()).isEqualTo("debugTrace"); assertThat(trace.getUuid()).isEqualTo("UserTraceLog"); assertThat(trace.getUserTraceOrInformation()).hasSize(76); assertThat(new UserTraceType().getInsert()).isNotNull(); UserTraceType trace1 = trace.getUserTraceOrInformation().get(0); assertThat(trace1.getCatalog()).isEqualTo("BIPmsgs"); assertThat(trace1.getFile()).isEqualTo( "F:\\build\\S1000_slot1\\S1000_P\\src\\DataFlowEngine\\Configuration\\ImbConfigurationManager.cpp"); assertThat(trace1.getFunction()).isEqualTo("ImbConfigurationManager::evaluate"); assertThat(trace1.getLabel()).isEqualTo("ConfigurationManager"); assertThat(trace1.getLine()).isEqualTo("956"); assertThat(trace1.getName()).isEqualTo("ConfigurationManager"); assertThat(trace1.getNumber()).isEqualTo("4040"); assertThat(trace1.getText()) .isEqualTo("'Configuration changed successfully and committed to persistent store'"); assertThat(trace1.getThread()).isEqualTo("9328"); assertThat(trace1.getTimestamp()).isEqualTo("2017-09-15 04:28:04.403125"); assertThat(trace1.getType()).isEqualTo("ComIbmConfigurationManager"); assertThat(trace1.getInsert()).hasSize(3); InsertType insert = trace1.getInsert().get(0); assertThat(insert.getType()).isEqualTo("string"); assertThat(insert.getValue()).isEqualTo("'default'"); }