@Test public void shouldNotFailIfStartupTakesLessTimeThanTimeout() throws IOException { Configurator configurator = buildProperties(); configurator.configuration().setProperty(Configurator.STARTUP_TIMEOUT, 100); server = new CommunityNeoServer(configurator) { @Override protected Iterable<ServerModule> createServerModules() { return Arrays.asList(); } }; // When try { server.start(); } catch (ServerStartupException e) { fail("Should not have been interupted."); } // Then InterruptThreadTimer timer = server.getDependencyResolver().resolveDependency(InterruptThreadTimer.class); assertThat(timer.getState(), is(InterruptThreadTimer.State.IDLE)); }
@After public void stopServer() { if (server != null) { server.stop(); server = null; } }
@Test public void shouldNotTimeOutIfTimeoutDisabled() throws IOException { Configurator configurator = buildProperties(); configurator.configuration().setProperty(Configurator.STARTUP_TIMEOUT, 0); server = createSlowServer(configurator); // When server.start(); // Then // No exceptions should have been thrown }
@Test public void shouldTimeoutIfStartupTakesLongerThanTimeout() throws IOException { Configurator configurator = buildProperties(); configurator.configuration().setProperty(Configurator.STARTUP_TIMEOUT, 1); server = createSlowServer(configurator); try { server.start(); fail("Should have been interrupted."); } catch (ServerStartupException e) { // ok! } }