@Test public void reports_an_internal_error_if_the_daemon_fails_to_connect_within_a_timeout() throws InterruptedException { SpyListener<SuiteListener> spy = new SpyListener<>(SuiteListener.class); SuiteListener expect = spy.getListener(); CountDownLatch expectedMessagesArrived = new CountDownLatch(3); expect.onSuiteStarted(); expect.onInternalError("Failed to start the test runner daemon process", StackTrace.from(new RuntimeException("Could not connect to the daemon: timed out after 0 ms"))); expect.onSuiteFinished(); spy.replay(); daemonSummoner.connectToDaemon( dummySuiteConfig, new DaemonConfigurationBuilder() .setStartupTimeout(0) .freeze(), actorRef(new FakeDaemonListener(countMessages(expect, expectedMessagesArrived)))); expectedMessagesArrived.await(TIMEOUT / 2, TimeUnit.MILLISECONDS); spy.verify(); }
@Override public void connectToDaemon(SuiteConfiguration suite, DaemonConfiguration daemon, ActorRef<DaemonListener> listener) { int port = daemonConnector.listenOnAnyPort( new OneTimeDaemonListenerFactory( withInitialMessageTimeout(listener.tell(), daemon.getStartupTimeout()))); daemon = daemon.melt() .setDaemonDir(steward.createDaemonDir(daemon.getJumiHome())) .setLauncherPort(port) .freeze(); try { JvmArgs jvmArgs = new JvmArgsBuilder() .setExecutableJar(steward.getDaemonJar(daemon.getJumiHome())) .setWorkingDir(Paths.get(suite.getWorkingDirectory())) .setJvmOptions(suite.getJvmOptions()) .setSystemProperties(daemon.toSystemProperties()) .setProgramArgs(daemon.toProgramArgs()) .freeze(); Process process = processStarter.startJavaProcess(jvmArgs); copyInBackground(process.getInputStream(), outputListener); } catch (Exception e) { throw Boilerplate.rethrow(e); } }
ProcessStartingDaemonSummoner implements DaemonSummoner { @Override public void connectToDaemon(SuiteConfiguration suite, DaemonConfiguration daemon, ActorRef<DaemonListener> listener) { int port = daemonConnector.listenOnAnyPort( new OneTimeDaemonListenerFactory( withInitialMessageTimeout(listener.tell(), daemon.getStartupTimeout()))); daemon = daemon.melt() .setDaemonDir(steward.createDaemonDir(daemon.getJumiHome())) .setLauncherPort(port) .freeze(); try { JvmArgs jvmArgs = new JvmArgsBuilder() .setExecutableJar(steward.getDaemonJar(daemon.getJumiHome())) .setWorkingDir(Paths.get(suite.getWorkingDirectory())) .setJvmOptions(suite.getJvmOptions()) .setSystemProperties(daemon.toSystemProperties()) .setProgramArgs(daemon.toProgramArgs()) .freeze(); Process process = processStarter.startJavaProcess(jvmArgs); copyInBackground(process.getInputStream(), outputListener); } catch (Exception e) { throw Boilerplate.rethrow(e); } } }
ProcessStartingDaemonSummoner implements DaemonSummoner { @Override public void connectToDaemon(SuiteConfiguration suite, DaemonConfiguration daemon, ActorRef<DaemonListener> listener) { int port = daemonConnector.listenOnAnyPort( new OneTimeDaemonListenerFactory( withInitialMessageTimeout(listener.tell(), daemon.getStartupTimeout()))); daemon = daemon.melt() .setDaemonDir(steward.createDaemonDir(daemon.getJumiHome())) .setLauncherPort(port) .freeze(); try { JvmArgs jvmArgs = new JvmArgsBuilder() .setExecutableJar(steward.getDaemonJar(daemon.getJumiHome())) .setWorkingDir(Paths.get(suite.getWorkingDirectory())) .setJvmOptions(suite.getJvmOptions()) .setSystemProperties(daemon.toSystemProperties()) .setProgramArgs(daemon.toProgramArgs()) .freeze(); Process process = processStarter.startJavaProcess(jvmArgs); copyInBackground(process.getInputStream(), outputListener); } catch (Exception e) { throw Boilerplate.rethrow(e); } } ProcessStartingDaemonSummoner(Steward steward,
                                         ProcessStarter processStarter,
                                         NetworkServer daemonConnector,
                                         @WillClose OutputStream outputListener); }
ProcessStartingDaemonSummoner implements DaemonSummoner { @Override public void connectToDaemon(SuiteConfiguration suite, DaemonConfiguration daemon, ActorRef<DaemonListener> listener) { int port = daemonConnector.listenOnAnyPort( new OneTimeDaemonListenerFactory( withInitialMessageTimeout(listener.tell(), daemon.getStartupTimeout()))); daemon = daemon.melt() .setDaemonDir(steward.createDaemonDir(daemon.getJumiHome())) .setLauncherPort(port) .freeze(); try { JvmArgs jvmArgs = new JvmArgsBuilder() .setExecutableJar(steward.getDaemonJar(daemon.getJumiHome())) .setWorkingDir(Paths.get(suite.getWorkingDirectory())) .setJvmOptions(suite.getJvmOptions()) .setSystemProperties(daemon.toSystemProperties()) .setProgramArgs(daemon.toProgramArgs()) .freeze(); Process process = processStarter.startJavaProcess(jvmArgs); copyInBackground(process.getInputStream(), outputListener); } catch (Exception e) { throw Boilerplate.rethrow(e); } } ProcessStartingDaemonSummoner(Steward steward,
                                         ProcessStarter processStarter,
                                         NetworkServer daemonConnector,
                                         @WillClose OutputStream outputListener); @Override void connectToDaemon(SuiteConfiguration suite,
                                DaemonConfiguration daemon,
                                ActorRef<DaemonListener> listener); }
ProcessStartingDaemonSummoner implements DaemonSummoner { @Override public void connectToDaemon(SuiteConfiguration suite, DaemonConfiguration daemon, ActorRef<DaemonListener> listener) { int port = daemonConnector.listenOnAnyPort( new OneTimeDaemonListenerFactory( withInitialMessageTimeout(listener.tell(), daemon.getStartupTimeout()))); daemon = daemon.melt() .setDaemonDir(steward.createDaemonDir(daemon.getJumiHome())) .setLauncherPort(port) .freeze(); try { JvmArgs jvmArgs = new JvmArgsBuilder() .setExecutableJar(steward.getDaemonJar(daemon.getJumiHome())) .setWorkingDir(Paths.get(suite.getWorkingDirectory())) .setJvmOptions(suite.getJvmOptions()) .setSystemProperties(daemon.toSystemProperties()) .setProgramArgs(daemon.toProgramArgs()) .freeze(); Process process = processStarter.startJavaProcess(jvmArgs); copyInBackground(process.getInputStream(), outputListener); } catch (Exception e) { throw Boilerplate.rethrow(e); } } ProcessStartingDaemonSummoner(Steward steward,
                                         ProcessStarter processStarter,
                                         NetworkServer daemonConnector,
                                         @WillClose OutputStream outputListener); @Override void connectToDaemon(SuiteConfiguration suite,
                                DaemonConfiguration daemon,
                                ActorRef<DaemonListener> listener);  }