Search in sources :

Example 1 with AbstractLifeCycle

use of org.eclipse.jetty.util.component.AbstractLifeCycle in project dropwizard by dropwizard.

the class ServerCommandTest method stopsAServerIfThereIsAnErrorStartingIt.

@Test
public void stopsAServerIfThereIsAnErrorStartingIt() throws Exception {
    this.throwException = true;
    server.addBean(new AbstractLifeCycle() {

        @Override
        protected void doStart() throws Exception {
            throw new IOException("oh crap");
        }
    });
    try {
        command.run(environment, namespace, configuration);
        failBecauseExceptionWasNotThrown(IOException.class);
    } catch (IOException e) {
        assertThat(e.getMessage()).isEqualTo("oh crap");
    }
    assertThat(server.isStarted()).isFalse();
    this.throwException = false;
}
Also used : AbstractLifeCycle(org.eclipse.jetty.util.component.AbstractLifeCycle) IOException(java.io.IOException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 AbstractLifeCycle (org.eclipse.jetty.util.component.AbstractLifeCycle)1 Test (org.junit.Test)1