TraceFileReader { public TraceFileReader readTrace(ExecutionDataVisitor executionDataVisitor) { if (traceFile == null) { return this; } CodeCoverageExtension.LOG.info("Analysing {}", traceFile); try (FileInputStream fis = new FileInputStream(traceFile)) { BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); String firstLine = reader.readLine(); if (firstLine.startsWith("<?xml")) { readXML(); } else { readLine(firstLine); while (reader.ready()) { readLine(reader.readLine()); } } reader.close(); } catch (IOException e) { throw new RuntimeException(String.format("Unable to read %s", traceFile.getAbsolutePath()), e); } for (ModuleExecutionData data : moduleCache.values()) { executionDataVisitor.visitModuleExecution(data); } return this; } TraceFileReader(File traceFile); TraceFileReader readTrace(ExecutionDataVisitor executionDataVisitor); String inputStreamToString(InputStream is); int getModuleCount(); ModuleExecutionData getModuleExecutionData(String moduleName);  }
@Test(expected=RuntimeException.class) public void testReaderWithNotExistingFile(){ new TraceFileReader(new File("src/test/resources/codecoverage/doesNotExist.txt")).readTrace(testVisitor); }
@Test(expected=RuntimeException.class) public void xmlReaderTestCorruptFile(){ new TraceFileReader(new File("src/test/resources/codecoverage/corruptTrace.xml")) .readTrace(testVisitor); }
@Test public void indexOutOfBounds112() throws IOException { TraceFileReader trace = new TraceFileReader(new File("src/test/resources/codecoverage/tests/usertrace_112.xml")).readTrace(new ExecutionDataVisitor() { @Override public void visitModuleExecution(ModuleExecutionData data) { } }); assertThat(trace).isNotNull(); }