Exemplo n.º 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));
  }
Exemplo n.º 2
0
 @After
 public void stopServer() {
   if (server != null) {
     server.stop();
     server = null;
   }
 }
Exemplo n.º 3
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
  }
Exemplo n.º 4
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!
    }
  }