/** * Reads all data from given input stream. * * @param stream * Stream to read data from * @throws IOException * in case of problems while reading from the stream */ public void load(final InputStream stream) throws IOException { final ExecutionDataReader reader = new ExecutionDataReader( new BufferedInputStream(stream)); reader.setExecutionDataVisitor(executionData); reader.setSessionInfoVisitor(sessionInfos); reader.read(); }
/** * Collects execution data from the given reader. * * @param reader * reader to read execution data from */ public void readFrom(ExecutionDataReader reader) throws IOException { reader.setSessionInfoVisitor(sessionInfoStore); reader.setExecutionDataVisitor(executionDataStore); reader.read(); }
private void read(InputStream stream, IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionVisitor) { ExecutionDataReader reader = new ExecutionDataReader(stream); reader.setExecutionDataVisitor(executionDataVisitor); reader.setSessionInfoVisitor(sessionVisitor); try { reader.read(); } catch (IOException e) { throw new RuntimeException("Could not read data to ExecutionDataStore from InputStream", e); } finally { if (stream != null) { try { stream.close(); } catch (Exception e2) { e2.printStackTrace(); } } } } }
private void read(InputStream stream, IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionVisitor) { ExecutionDataReader reader = new ExecutionDataReader(stream); reader.setExecutionDataVisitor(executionDataVisitor); reader.setSessionInfoVisitor(sessionVisitor); try { reader.read(); } catch (IOException e) { throw new RuntimeException("Could not read data to ExecutionDataStore from InputStream", e); } finally { if (stream != null) { try { stream.close(); } catch (Exception e2) { e2.printStackTrace(); } } } } }
public void accept(IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionInfoVisitor) throws CoreException { try { final InputStream in = new BufferedInputStream(url.openStream()); final ExecutionDataReader reader = new ExecutionDataReader(in); reader.setExecutionDataVisitor(executionDataVisitor); reader.setSessionInfoVisitor(sessionInfoVisitor); reader.read(); in.close(); } catch (IOException e) { throw new CoreException(EclEmmaStatus.EXEC_FILE_READ_ERROR.getStatus(url, e)); } }
private void loadSourceFiles(SessionInfoStore infoStore, ExecutionDataStore dataStore, File... reports) { for (File report : reports) { if(report.isFile()) { InputStream resourceStream = null; try { resourceStream = new BufferedInputStream(new FileInputStream(report)); ExecutionDataReader reader = new ExecutionDataReader(resourceStream); reader.setSessionInfoVisitor(infoStore); reader.setExecutionDataVisitor(dataStore); reader.read(); } catch (IOException e) { throw new SonarException(String.format("Unable to read %s", report.getAbsolutePath()), e); } finally { Closeables.closeQuietly(resourceStream); } } } }
private void loadSourceFiles(SessionInfoStore infoStore, ExecutionDataStore dataStore, File... reports) { for (File report : reports) { InputStream resourceStream = null; try { resourceStream = new BufferedInputStream(new FileInputStream(report)); ExecutionDataReader reader = new ExecutionDataReader(resourceStream); reader.setSessionInfoVisitor(infoStore); reader.setExecutionDataVisitor(dataStore); reader.read(); } catch (IOException e) { throw new SonarException(String.format("Unable to read %s", report.getAbsolutePath()), e); } finally { Closeables.closeQuietly(resourceStream); } } }
private void loadSourceFiles(SessionInfoStore infoStore, ExecutionDataStore dataStore, File... reports) { for (File report : reports) { if (report.isFile()) { InputStream resourceStream = null; try { resourceStream = new BufferedInputStream(new FileInputStream(report)); ExecutionDataReader reader = new ExecutionDataReader(resourceStream); reader.setSessionInfoVisitor(infoStore); reader.setExecutionDataVisitor(dataStore); reader.read(); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to read %s", report.getAbsolutePath()), e); } finally { Closeables.closeQuietly(resourceStream); } } } }
private void dump(final File file, final PrintWriter out) throws IOException { out.printf("[INFO] Loading exec file %s.%n", file); out.println("CLASS ID HITS/PROBES CLASS NAME"); final FileInputStream in = new FileInputStream(file); final ExecutionDataReader reader = new ExecutionDataReader(in); reader.setSessionInfoVisitor(new ISessionInfoVisitor() { public void visitSessionInfo(final SessionInfo info) { out.printf("Session \"%s\": %s - %s%n", info.getId(), new Date(info.getStartTimeStamp()), new Date(info.getDumpTimeStamp())); } }); reader.setExecutionDataVisitor(new IExecutionDataVisitor() { public void visitClassExecution(final ExecutionData data) { out.printf("%016x %3d of %3d %s%n", Long.valueOf(data.getId()), Integer.valueOf(getHitCount(data.getProbes())), Integer.valueOf(data.getProbes().length), data.getName()); } }); reader.read(); in.close(); out.println(); }
private void loadExecutionData() throws IOException { File executionDataFile = new File(execFile.getRemote()); final FileInputStream fis = new FileInputStream(executionDataFile); final ExecutionDataReader executionDataReader = new ExecutionDataReader( fis); executionDataStore = new ExecutionDataStore(); sessionInfoStore = new SessionInfoStore(); executionDataReader.setExecutionDataVisitor(executionDataStore); executionDataReader.setSessionInfoVisitor(sessionInfoStore); while (executionDataReader.read()) { } fis.close(); } private IBundleCoverage analyzeStructure() throws IOException {
/** * Read JaCoCo report determining the format to be used. * @param executionDataVisitor visitor to store execution data. * @param sessionInfoStore visitor to store info session. * @return true if binary format is the latest one. * @throws IOException in case of error or binary format not supported. */ public JacocoReportReader readJacocoReport(IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionInfoStore) { if (jacocoExecutionData == null) { return this; } LOG.info("Analysing {}", jacocoExecutionData); try (InputStream inputStream = new BufferedInputStream(new FileInputStream(jacocoExecutionData))) { ExecutionDataReader reader = new ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(sessionInfoStore); reader.setExecutionDataVisitor(executionDataVisitor); reader.read(); } catch (IOException e) { throw new AnalysisException(String.format("Unable to read %s", jacocoExecutionData.getAbsolutePath()), e); } return this; }
private void loadExecutionData() throws IOException { executionDataStore = new ExecutionDataStore(); sessionInfoStore = new SessionInfoStore(); for (FilePath filePath : execFiles) { File executionDataFile = new File(filePath.getRemote()); try { try (final InputStream inputStream = new BufferedInputStream( new FileInputStream(executionDataFile))) { final ExecutionDataReader reader = new ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(sessionInfoStore); reader.setExecutionDataVisitor(executionDataStore); reader.read(); } } catch (final IOException e) { throw new IOException("While reading execution data-file: " + executionDataFile, e); } } } private IBundleCoverage analyzeStructure() throws IOException {
/** * Read JaCoCo report determining the format to be used. * @param executionDataVisitor visitor to store execution data. * @param sessionInfoStore visitor to store info session. * @return true if binary format is the latest one. * @throws IOException in case of error or binary format not supported. */ public JaCoCoReportReader readJacocoReport(IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionInfoStore) { if (jacocoExecutionData == null) { return this; } JaCoCoExtensions.logger().info("Analysing {}", jacocoExecutionData); try (InputStream inputStream = new BufferedInputStream(new FileInputStream(jacocoExecutionData))) { if (useCurrentBinaryFormat) { ExecutionDataReader reader = new ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(sessionInfoStore); reader.setExecutionDataVisitor(executionDataVisitor); reader.read(); } else { org.jacoco.previous.core.data.ExecutionDataReader reader = new org.jacoco.previous.core.data.ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(sessionInfoStore); reader.setExecutionDataVisitor(executionDataVisitor); reader.read(); } } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to read %s", jacocoExecutionData.getAbsolutePath()), e); } return this; }
try { inputStream = new BufferedInputStream(new FileInputStream(jacocoExecutionData)); ExecutionDataReader reader = new ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(executionDataVisitor); reader.setExecutionDataVisitor(executionDataVisitor); reader.read(); } finally { Closeables.closeQuietly(inputStream);
try { inputStream = new BufferedInputStream(new FileInputStream(jacocoExecutionData)); ExecutionDataReader reader = new ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(executionDataVisitor); reader.setExecutionDataVisitor(executionDataVisitor); reader.read(); } finally { Closeables.closeQuietly(inputStream);
JaCoCoUtils.LOG.info("Analysing {}", jacocoExecutionData); ExecutionDataReader reader = new ExecutionDataReader(new FileInputStream(jacocoExecutionData)); reader.setSessionInfoVisitor(executionDataVisitor); reader.setExecutionDataVisitor(executionDataVisitor); reader.read();