use of org.jacoco.core.runtime.RemoteControlWriter in project jacoco by jacoco.
the class TcpConnectionTest method testRemoteReset.
@Test
public void testRemoteReset() throws Exception {
data.getExecutionData(Long.valueOf(123), "Foo", 1).getProbes()[0] = true;
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(false, true);
final RemoteControlReader remoteReader = new RemoteControlReader(mockConnection.getSocketB().getInputStream());
final ExecutionDataStore execStore = new ExecutionDataStore();
remoteReader.setExecutionDataVisitor(execStore);
final SessionInfoStore infoStore = new SessionInfoStore();
remoteReader.setSessionInfoVisitor(infoStore);
assertTrue(remoteReader.read());
assertTrue(infoStore.getInfos().isEmpty());
assertTrue(execStore.getContents().isEmpty());
assertFalse(data.getExecutionData(Long.valueOf(123), "Foo", 1).getProbes()[0]);
con.close();
f.get();
}
use of org.jacoco.core.runtime.RemoteControlWriter 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.RemoteControlWriter in project jacoco by jacoco.
the class TcpConnection method init.
public void init() throws IOException {
this.writer = new RemoteControlWriter(socket.getOutputStream());
this.reader = new RemoteControlReader(socket.getInputStream());
this.reader.setRemoteCommandVisitor(this);
this.initialized = true;
}
use of org.jacoco.core.runtime.RemoteControlWriter in project jacoco by jacoco.
the class TcpClientOutputTest method setup.
@Before
public void setup() throws Exception {
logger = new ExceptionRecorder();
final MockSocketConnection con = new MockSocketConnection();
localSocket = con.getSocketA();
remoteSocket = con.getSocketB();
remoteWriter = new RemoteControlWriter(remoteSocket.getOutputStream());
controller = new TcpClientOutput(logger) {
@Override
protected Socket createSocket(AgentOptions options) throws IOException {
return localSocket;
}
};
data = new RuntimeData();
controller.startup(new AgentOptions(), data);
remoteReader = new RemoteControlReader(remoteSocket.getInputStream());
}
use of org.jacoco.core.runtime.RemoteControlWriter in project jacoco by jacoco.
the class TcpServerOutputTest method testWriteExecutionData.
@Test
public void testWriteExecutionData() throws Exception {
data.getExecutionData(Long.valueOf(0x12345678), "Foo", 42).getProbes()[0] = true;
data.setSessionId("stubid");
final Socket socket = serverSocket.connect();
final RemoteControlWriter remoteWriter = new RemoteControlWriter(socket.getOutputStream());
final RemoteControlReader remoteReader = new RemoteControlReader(socket.getInputStream());
// First process a NOP command to ensure the connection is initialized:
remoteWriter.visitDumpCommand(false, false);
remoteReader.read();
// Now the actual test starts:
controller.writeExecutionData(false);
final ExecutionDataStore execStore = new ExecutionDataStore();
remoteReader.setExecutionDataVisitor(execStore);
final SessionInfoStore infoStore = new SessionInfoStore();
remoteReader.setSessionInfoVisitor(infoStore);
remoteReader.read();
assertEquals("Foo", execStore.get(0x12345678).getName());
final List<SessionInfo> infos = infoStore.getInfos();
assertEquals(1, infos.size());
assertEquals("stubid", infos.get(0).getId());
logger.assertNoException();
controller.shutdown();
}
Aggregations