Source:
private void testConsoleCommunicationSetting(long timeout, boolean needTimeoutState) throws Exception { AgentIdentity agentIdentity = getAgentIdentity(allAvailableAgents, 0); ConsoleCommunicationSetting consoleCommunicationSetting = ConsoleCommunicationSetting.asDefault(); consoleCommunicationSetting.setInactiveClientTimeOut(timeout); final SingleConsole console1 = new SingleConsole("", getFreePort(), consoleCommunicationSetting, ConsolePropertiesFactory.createEmptyConsoleProperties(), ""); console1.start(); console1.startSampling(); GrinderProperties grinderProperties = new GrinderProperties(); grinderProperties.setInt(GrinderProperties.CONSOLE_PORT, console1.getConsolePort()); agentControllerServerDaemon.startAgent(grinderProperties, agentIdentity); sleep(3000); assertThat(console1.getAllAttachedAgentsCount(), is(1)); final Set<String> result = new HashSet<String>(); URL scriptUrl = this.getClass().getResource("/long-time-prepare-test.properties"); File scriptFile = new File(scriptUrl.getFile()); GrinderProperties properties = new GrinderProperties(scriptFile); console1.addListener(new SingleConsole.ConsoleShutdownListener() { @Override public void readyToStop(StopReason stopReason) { if (stopReason.getDisplay().equals("Script error")) { result.add("timeout"); } } }); console1.startTest(properties); for (int i = 0; i < 20; i++) { if (result.contains("timeout")) { break; } try { Thread.sleep(1000); } catch (InterruptedException e) { } } if (needTimeoutState && !result.contains("timeout") || !needTimeoutState && result.contains("timeout")) { assertTrue(false); } agentControllerServerDaemon.stopAgent(agentIdentity); sleep(10000); assertThat(console1.getAllAttachedAgentsCount(), is(0)); }

Target:
private void testConsoleCommunicationSetting(long timeout, boolean needTimeoutState) throws Exception { AgentIdentity agentIdentity = getAgentIdentity(allAvailableAgents, 0); ConsoleCommunicationSetting consoleCommunicationSetting = ConsoleCommunicationSetting.asDefault(); consoleCommunicationSetting.setInactiveClientTimeOut(timeout); final SingleConsole console1 = new SingleConsole("", getFreePort(), consoleCommunicationSetting, ConsolePropertiesFactory.createEmptyConsoleProperties()); console1.start(); console1.startSampling(); GrinderProperties grinderProperties = new GrinderProperties(); grinderProperties.setInt(GrinderProperties.CONSOLE_PORT, console1.getConsolePort()); agentControllerServerDaemon.startAgent(grinderProperties, agentIdentity); sleep(3000); assertThat(console1.getAllAttachedAgentsCount(), is(1)); final Set<String> result = new HashSet<String>(); URL scriptUrl = this.getClass().getResource("/long-time-prepare-test.properties"); File scriptFile = new File(scriptUrl.getFile()); GrinderProperties properties = new GrinderProperties(scriptFile); console1.addListener(new SingleConsole.ConsoleShutdownListener() { @Override public void readyToStop(StopReason stopReason) { if (stopReason.getDisplay().equals("Script error")) { result.add("timeout"); } } }); console1.startTest(properties); for (int i = 0; i < 20; i++) { if (result.contains("timeout")) { break; } try { Thread.sleep(1000); } catch (InterruptedException e) { } } if (needTimeoutState && !result.contains("timeout") || !needTimeoutState && result.contains("timeout")) { assertTrue(false); } agentControllerServerDaemon.stopAgent(agentIdentity); sleep(10000); assertThat(console1.getAllAttachedAgentsCount(), is(0)); }