use of org.jacoco.core.runtime.RemoteControlWriter in project jacoco by jacoco.
the class ExecDumpClientTest method handleConnection.
private void handleConnection(Socket socket) throws IOException {
final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());
reader.setRemoteCommandVisitor(new IRemoteCommandVisitor() {
public void visitDumpCommand(boolean dump, boolean reset) throws IOException {
dumpRequested = dump;
resetRequested = reset;
if (dump) {
writer.visitSessionInfo(new SessionInfo("TestId", 100, 200));
}
writer.sendCmdOk();
}
});
reader.read();
}
use of org.jacoco.core.runtime.RemoteControlWriter in project jacoco by jacoco.
the class TcpConnectionTest method testRemoteDump.
@Test
public void testRemoteDump() throws Exception {
data.getExecutionData(Long.valueOf(0x12345678), "Foo", 42).getProbes()[0] = true;
data.setSessionId("stubid");
final RemoteControlWriter remoteWriter = new RemoteControlWriter(mockConnection.getSocketB().getOutputStream());
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);
remoteWriter.visitDumpCommand(true, false);
readAndAssertData();
con.close();
f.get();
}
use of org.jacoco.core.runtime.RemoteControlWriter in project jacoco by jacoco.
the class ExecDumpClient method dump.
/**
* Requests a dump from the given end-point.
*
* @param address
* host name or IP-Address to connect to
* @param port
* port to connect to
* @return container for the dumped data
* @throws IOException
* in case the dump can not be requested
*/
public ExecFileLoader dump(final InetAddress address, final int port) throws IOException {
final ExecFileLoader loader = new ExecFileLoader();
final Socket socket = tryConnect(address, port);
try {
final RemoteControlWriter remoteWriter = new RemoteControlWriter(socket.getOutputStream());
final RemoteControlReader remoteReader = new RemoteControlReader(socket.getInputStream());
remoteReader.setSessionInfoVisitor(loader.getSessionInfoStore());
remoteReader.setExecutionDataVisitor(loader.getExecutionDataStore());
remoteWriter.visitDumpCommand(dump, reset);
if (!remoteReader.read()) {
throw new IOException("Socket closed unexpectedly.");
}
} finally {
socket.close();
}
return loader;
}
use of org.jacoco.core.runtime.RemoteControlWriter 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();
}
Aggregations