Class DeploymentContext

  • Direct Known Subclasses:
    ServletDeploymentContext

    public class DeploymentContext
    extends Object
    Basic application deployment context.

    An instance of this class is created by creating using DeploymentContext.Builder, that allows to configure the deployment context state, and finally building the context by invoking the DeploymentContext.Builder.build() method.

    This deployment context is compatible with basic non-Servlet test containers. The following test container factories support the descriptor:

    • org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory for testing with the Grizzly HTTP container.
    • org.glassfish.jersey.test.jetty.JettyTestContainerFactory for testing with the Jetty HTTP container.
    • org.glassfish.jersey.test.simple.SimpleTestContainerFactory for testing with the Simple HTTP container.
    • org.glassfish.jersey.test.jdkhttp.JdkHttpServerTestContainerFactory for testing with the Light Weight HTTP server distributed with Java SE.
    • org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory for testing in memory without using underlying HTTP client and server side functionality to send requests and receive responses.
    • org.glassfish.jersey.test.external.ExternalTestContainerFactory for testing Java EE Web applications deployed independently in a separate JVM to that of the tests. For example, the application may be deployed to the GlassFish or WebLogic application server.

    Since:
    2.8
    Author:
    Paul Sandoz, Marek Potociar
    • Method Detail

      • builder

        public static DeploymentContext.Builder builder​(Application application)
        Create a new deployment context builder for a JAX-RS / Jersey application instance.
        Parameters:
        application - a JAX-RS / Jersey application to be tested.
        Returns:
        new deployment context builder instance associated with the JAX-RS / Jersey application to be tested.
        Throws:
        NullPointerException - in case the application is null.
      • builder

        public static DeploymentContext.Builder builder​(Class<? extends Application> applicationClass)
        Create a new deployment context builder for a JAX-RS / Jersey application instance.
        Parameters:
        applicationClass - a JAX-RS / Jersey application to be tested.
        Returns:
        new deployment context builder instance associated with the JAX-RS / Jersey application to be tested.
        Throws:
        NullPointerException - in case the applicationClass is null.
      • newInstance

        public static DeploymentContext newInstance​(Application application)
        Create a new deployment context for a JAX-RS / Jersey application instance.

        The created deployment context will be configured to use default values.

        Parameters:
        application - a JAX-RS / Jersey application to be tested.
        Returns:
        new deployment context instance associated with the JAX-RS / Jersey application to be tested.
        Throws:
        NullPointerException - in case the application is null.
      • newInstance

        public static DeploymentContext newInstance​(Class<? extends Application> applicationClass)
        Create a new deployment context for a JAX-RS / Jersey application instance.

        The created deployment context will be configured to use default values.

        Parameters:
        applicationClass - a JAX-RS / Jersey application to be tested.
        Returns:
        new deployment context instance associated with the JAX-RS / Jersey application to be tested.
        Throws:
        NullPointerException - in case the applicationClass is null.
      • getResourceConfig

        public ResourceConfig getResourceConfig()
        Get the deployed application resource configuration.

        This method can be overridden in a subclass to support conversion of non-resource config initialization scenario (e.g. via Servlet init parameters) into a resource configuration.

        Returns:
        the deployed application resource configuration.
      • getContextPath

        public final String getContextPath()
        Get the deployed application context path.
        Returns:
        the deployed application context path.
      • getSslContext

        public Optional<SSLContext> getSslContext()
        Get the deployed application ssl context.
        Returns:
        the deployed application ssl context.
      • getSslParameters

        public Optional<SSLParameters> getSslParameters()
        Get the deployed application ssl parameters.
        Returns:
        the deployed application ssl parameters.