use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ExecFileLoader method save.
/**
* Saves the current content into the given output stream.
*
* @param stream
* stream to save content to
* @throws IOException
* in case of problems while writing to the stream
*/
public void save(final OutputStream stream) throws IOException {
final ExecutionDataWriter dataWriter = new ExecutionDataWriter(stream);
sessionInfos.accept(dataWriter);
executionData.accept(dataWriter);
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ExecDumpTest method createExecFile.
private String createExecFile() throws IOException {
File f = File.createTempFile("jacoco", ".exec");
final FileOutputStream out = new FileOutputStream(f);
final ExecutionDataWriter writer = new ExecutionDataWriter(out);
writer.visitSessionInfo(new SessionInfo("testid", 1, 2));
writer.visitClassExecution(new ExecutionData(0x1234, "foo/MyClass", new boolean[] { false, true, true }));
writer.flush();
out.close();
return f.getPath();
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ExecutionDataClient method main.
/**
* Starts the execution data request.
*
* @param args
* @throws IOException
*/
public static void main(final String[] args) throws IOException {
final FileOutputStream localFile = new FileOutputStream(DESTFILE);
final ExecutionDataWriter localWriter = new ExecutionDataWriter(localFile);
// Open a socket to the coverage agent:
final Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT);
final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());
reader.setSessionInfoVisitor(localWriter);
reader.setExecutionDataVisitor(localWriter);
// Send a dump command and read the response:
writer.visitDumpCommand(true, false);
if (!reader.read()) {
throw new IOException("Socket closed unexpectedly.");
}
socket.close();
localFile.close();
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ExecutionDataServer method main.
/**
* Start the server as a standalone program.
*
* @param args
* @throws IOException
*/
public static void main(final String[] args) throws IOException {
final ExecutionDataWriter fileWriter = new ExecutionDataWriter(new FileOutputStream(DESTFILE));
final ServerSocket server = new ServerSocket(PORT, 0, InetAddress.getByName(ADDRESS));
while (true) {
final Handler handler = new Handler(server.accept(), fileWriter);
new Thread(handler).start();
}
}
use of org.jacoco.core.data.ExecutionDataWriter in project sonar-java by SonarSource.
the class JaCoCoReportMerger method mergeReports.
/**
* Merge all reports in reportOverall.
* @param reportOverall destination file of merge.
* @param reports files to be merged.
*/
public static void mergeReports(File reportOverall, File... reports) {
ExecutionDataVisitor edv = new ExecutionDataVisitor();
boolean isCurrentVersionFormat = loadSourceFiles(edv, reports);
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall))) {
Object visitor;
if (isCurrentVersionFormat) {
visitor = new ExecutionDataWriter(outputStream);
} else {
visitor = new org.jacoco.previous.core.data.ExecutionDataWriter(outputStream);
}
for (Map.Entry<String, ExecutionDataStore> entry : edv.getSessions().entrySet()) {
SessionInfo sessionInfo = new SessionInfo(entry.getKey(), 0, 0);
((ISessionInfoVisitor) visitor).visitSessionInfo(sessionInfo);
entry.getValue().accept((IExecutionDataVisitor) visitor);
}
} catch (IOException e) {
throw new AnalysisException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e);
}
}
Aggregations