@Test public void testWriteExecutionData() throws Exception { data.getExecutionData(Long.valueOf(0x12345678), "Foo", 42); 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(); }
@Test public void testShutdownWithConnection() throws Exception { serverSocket.waitForAccept(); new ExecutionDataWriter(serverSocket.connect().getOutputStream()); controller.shutdown(); logger.assertNoException(); }
@Test public void testInvalidHeader() throws Exception { final Socket socket = serverSocket.connect(); final OutputStream out = socket.getOutputStream(); out.write(0xca); out.write(0xfe); out.write(0xba); out.write(0xbe); serverSocket.waitForAccept(); logger.assertException(IOException.class, "Invalid execution data file."); controller.shutdown(); }
@Test public void testShutdownWithoutConnection() throws Exception { serverSocket.waitForAccept(); controller.shutdown(); logger.assertNoException(); }