use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class TcpConnectionTest method testRemoteClose.
/**
* Remote endpoint is closed after a valid header has been send.
*/
@Test
public void testRemoteClose() throws Exception {
final OutputStream remoteOut = mockConnection.getSocketB().getOutputStream();
new ExecutionDataWriter(remoteOut);
final TcpConnection con = new TcpConnection(mockConnection.getSocketA(), data);
con.init();
final Future<Void> f = executor.submit(new Callable<Void>() {
public Void call() throws Exception {
con.run();
return null;
}
});
assertBlocks(f);
mockConnection.getSocketA().waitUntilInputBufferIsEmpty();
mockConnection.getSocketB().close();
f.get();
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class FileOutput method writeExecutionData.
public void writeExecutionData(final boolean reset) throws IOException {
final OutputStream output = openFile();
try {
final ExecutionDataWriter writer = new ExecutionDataWriter(output);
data.collect(writer, writer, reset);
} finally {
output.close();
}
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class CreateExecFiles method main.
public static void main(String[] args) throws IOException {
OutputStream out;
out = new FileOutputStream(BASE_LOCATION + "sample1.exec");
new ExecutionDataWriter(out);
out.close();
out = new FileOutputStream(BASE_LOCATION + "sample2.exec");
new ExecutionDataWriter(out);
out.close();
out = new FileOutputStream(BASE_LOCATION + "nomatch.exec");
ExecutionDataWriter writer = new ExecutionDataWriter(out);
writer.visitClassExecution(new ExecutionData(0, "org/jacoco/ant/TestTarget", new boolean[0]));
out.close();
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ExecInfoTest method createExecFile.
private File createExecFile() throws IOException {
File f = new File(tmp.getRoot(), "test.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 }));
out.close();
return f;
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ReportTest method should_print_warning_when_exec_data_does_not_match.
@Test
public void should_print_warning_when_exec_data_does_not_match() throws Exception {
File exec = new File(tmp.getRoot(), "jacoco.exec");
final FileOutputStream execout = new FileOutputStream(exec);
ExecutionDataWriter writer = new ExecutionDataWriter(execout);
// Add probably invalid id for this test class:
writer.visitClassExecution(new ExecutionData(0x123, getClass().getName().replace('.', '/'), new boolean[] { true }));
execout.close();
execute("report", exec.getAbsolutePath(), "--classfiles", getClassPath());
assertOk();
assertContains("[WARN] Some classes do not match with execution data.", out);
assertContains("[WARN] For report generation the same class files must be used as at runtime.", out);
assertContains("[WARN] Execution data for class org/jacoco/cli/internal/commands/ReportTest does not match.", out);
}
Aggregations