Class JerseyTestNg

    • Constructor Detail

      • JerseyTestNg

        public JerseyTestNg​(TestContainerFactory testContainerFactory)
        Initialize JerseyTestNg instance and specify the test container factory to be used by this test. This constructor can be used from an extending subclass. When this constructor is used, the extending concrete subclass must implement configureStrategy() method.

        When this constructor is used, the extending concrete subclass must implement one of the JerseyTest.configure() or JerseyTest.configureDeployment() methods to provide the tested application configuration and deployment context.

        Parameters:
        testContainerFactory - the test container factory to use for testing.
      • JerseyTestNg

        public JerseyTestNg​(Application jaxrsApplication)
                     throws TestContainerException
        Initialize JerseyTestNg instance. This constructor can be used from an extending subclass.

        When this constructor is used, the extending concrete subclass the JerseyTest.configure() or JerseyTest.configureDeployment() method are ignored. However it must implement configureStrategy() method.

        Please note that when this constructor is used, recording of startup logs as well as configuring other JerseyTestNg properties and features may not work properly. While using this constructor should generally be avoided, in certain scenarios it may be necessary to use this constructor.

        Parameters:
        jaxrsApplication - tested application.
        Throws:
        TestContainerException
    • Method Detail

      • getClient

        protected final Client getClient()
        Description copied from class: JerseyTest
        Get the JAX-RS test client that is pre-configured for this test. This method can be overridden.
        Overrides:
        getClient in class JerseyTest
        Returns:
        the configured test client.
      • setClient

        protected final Client setClient​(Client client)
        Description copied from class: JerseyTest
        Get the old JAX-RS test client and set a new one. This method can be overridden.
        Overrides:
        setClient in class JerseyTest
        Parameters:
        client - the configured test client.
        Returns:
        old configured test client.
      • configureStrategy

        protected TestNgStrategy configureStrategy()
        Configure strategy for this TestNG JerseyTest. The strategy defines how a test container / client is stored (per class, per thread) and is also responsible for disposing stored instances.
        Returns:
        TestNG strategy instance.