use of org.jacoco.core.runtime.RemoteControlReader in project jacoco by jacoco.
the class DumpTest method serveRequest.
private void serveRequest(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 {
writer.sendCmdOk();
}
});
while (reader.read()) {
}
}
use of org.jacoco.core.runtime.RemoteControlReader 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.RemoteControlReader 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.RemoteControlReader 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