Example #1
0
  @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));
  }
Example #2
0
  @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
  }
Example #3
0
  @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!
    }
  }