Class JerseyTestNg
- java.lang.Object
-
- org.glassfish.jersey.test.JerseyTest
-
- org.glassfish.jersey.test.JerseyTestNg
-
- Direct Known Subclasses:
JerseyTestNg.ContainerPerClassTest
,JerseyTestNg.ContainerPerMethodTest
public abstract class JerseyTestNg extends JerseyTest
Parent class for testing JAX-RS and Jersey-based applications using Jersey test framework and TestNG framework.- Author:
- Michal Gajdos
- See Also:
JerseyTest
,TestNgStrategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JerseyTestNg.ContainerPerClassTest
Parent for TestNg tests that needs to create a test container only once per a test class.static class
JerseyTestNg.ContainerPerMethodTest
Parent for TestNg tests that needs to create a separate test container for each test in a test class.
-
Constructor Summary
Constructors Constructor Description JerseyTestNg()
Initialize JerseyTestNg instance.JerseyTestNg(Application jaxrsApplication)
Initialize JerseyTestNg instance.JerseyTestNg(TestContainerFactory testContainerFactory)
Initialize JerseyTestNg instance and specify the test container factory to be used by this test.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TestNgStrategy
configureStrategy()
Configurestrategy
for this TestNG JerseyTest.protected Client
getClient()
Get the JAX-RS test client that ispre-configured
for this test.protected Client
setClient(Client client)
Get the old JAX-RS test client and set a new one.-
Methods inherited from class org.glassfish.jersey.test.JerseyTest
client, close, closeIfNotNull, configure, configureClient, configureDeployment, disable, enable, forceDisable, forceEnable, forceSet, getAsyncTimeoutMultiplier, getBaseUri, getLastLoggedRecord, getLoggedRecords, getPort, getSslContext, getSslParameters, getTestContainerFactory, isEnabled, set, set, setUp, target, target, tearDown
-
-
-
-
Constructor Detail
-
JerseyTestNg
public JerseyTestNg() throws TestContainerException
Initialize JerseyTestNg instance. This constructor can be used from an extending subclass. When this constructor is used, the extending concrete subclass must implementconfigureStrategy()
method.When this constructor is used, the extending concrete subclass must implement one of the
JerseyTest.configure()
orJerseyTest.configureDeployment()
methods to provide the tested application configuration and deployment context.- Throws:
TestContainerException
-
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 implementconfigureStrategy()
method.When this constructor is used, the extending concrete subclass must implement one of the
JerseyTest.configure()
orJerseyTest.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()
orJerseyTest.configureDeployment()
method are ignored. However it must implementconfigureStrategy()
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 ispre-configured
for this test. This method can be overridden.- Overrides:
getClient
in classJerseyTest
- 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 classJerseyTest
- Parameters:
client
- the configured test client.- Returns:
- old configured test client.
-
configureStrategy
protected TestNgStrategy configureStrategy()
Configurestrategy
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.
-
-