use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class TcpConnectionTest method testInvalidContent.
@Test(expected = IOException.class)
public void testInvalidContent() throws Exception {
final OutputStream remoteOut = mockConnection.getSocketB().getOutputStream();
new ExecutionDataWriter(remoteOut);
final TcpConnection con = new TcpConnection(mockConnection.getSocketA(), data);
con.init();
remoteOut.write(123);
con.run();
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class Agent method getExecutionData.
public byte[] getExecutionData(final boolean reset) {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try {
final ExecutionDataWriter writer = new ExecutionDataWriter(buffer);
data.collect(writer, writer, reset);
} catch (final IOException e) {
// Must not happen with ByteArrayOutputStream
throw new AssertionError(e);
}
return buffer.toByteArray();
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class MergeTest method createExecFile.
private File createExecFile(String name) throws IOException {
File file = new File(tmp.getRoot(), name + ".exec");
final FileOutputStream execout = new FileOutputStream(file);
ExecutionDataWriter writer = new ExecutionDataWriter(execout);
writer.visitClassExecution(new ExecutionData(name.hashCode(), name, new boolean[] { true }));
execout.close();
return file;
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class ExecFileLoaderTest method createFile.
private File createFile(String id) throws IOException {
final File file = new File(sourceFolder.getRoot(), id + ".exec");
final FileOutputStream out = new FileOutputStream(file);
final ExecutionDataWriter writer = new ExecutionDataWriter(out);
final int value = id.length();
writer.visitClassExecution(new ExecutionData(value, id, new boolean[] { true }));
writer.visitSessionInfo(new SessionInfo(id, value, value));
out.close();
return file;
}
use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.
the class TcpConnectionTest method testLocalClose.
/**
* Local socket is closed while waiting for commands.
*
* @throws Exception
*/
@Test
public void testLocalClose() 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);
con.close();
f.get();
}
Aggregations