Class DropwizardAppExtension<C extends Configuration>

java.lang.Object
io.dropwizard.testing.junit5.DropwizardAppExtension<C>
Type Parameters:
C - the configuration type
All Implemented Interfaces:
DropwizardExtension, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension

public class DropwizardAppExtension<C extends Configuration> extends Object implements DropwizardExtension, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
An extension for starting and stopping your application at the start and end of a test class.

By default, the Application will be constructed using reflection to invoke the nullary constructor. If your application does not provide a public nullary constructor, you will need to override the newApplication() method to provide your application instance(s).

  • Constructor Details

  • Method Details

    • addListener

    • manage

      public DropwizardAppExtension<C> manage(Managed managed)
    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception
      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      Throws:
      Exception
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
    • before

      public void before() throws Exception
      Description copied from interface: DropwizardExtension
      Executed before test method or class.
      Specified by:
      before in interface DropwizardExtension
      Throws:
      Exception
    • after

      public void after()
      Description copied from interface: DropwizardExtension
      Executed after test method or class.
      Specified by:
      after in interface DropwizardExtension
    • getConfiguration

      public C getConfiguration()
    • getLocalPort

      public int getLocalPort()
    • getPort

      public int getPort(int connectorIndex)
    • getAdminPort

      public int getAdminPort()
    • newApplication

      public Application<C> newApplication()
    • getApplication

      public <A extends Application<C>> A getApplication()
    • getEnvironment

      public Environment getEnvironment()
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getTestSupport

      public DropwizardTestSupport<C> getTestSupport()
    • client

      public jakarta.ws.rs.client.Client client()
      Returns a new HTTP Jersey Client for performing HTTP requests against the tested Dropwizard server. The client can be reused across different tests and automatically closed along with the server. The client can be augmented by overriding the clientBuilder() method.
      Returns:
      a new Client managed by the extension.
    • clientBuilder

      protected org.glassfish.jersey.client.JerseyClientBuilder clientBuilder()