public abstract class SSLJerseyTest extends Object
| Constructor and Description |
|---|
SSLJerseyTest()
Initialize JerseyTest instance.
|
SSLJerseyTest(javax.ws.rs.core.Application jaxrsApplication)
Initialize JerseyTest instance.
|
SSLJerseyTest(org.glassfish.jersey.test.spi.TestContainerFactory testContainerFactory)
Initialize JerseyTest instance and specify the test container factory to be used by this test.
|
| Modifier and Type | Method and Description |
|---|---|
javax.ws.rs.client.Client |
client()
Get the JAX-RS test client that is
pre-configured
for this test. |
void |
close(javax.ws.rs.core.Response... responses)
Utility method that safely closes a response without throwing an exception.
|
static void |
closeIfNotNull(javax.ws.rs.client.Client... clients)
Utility method that safely closes a client instance without throwing an exception.
|
protected javax.ws.rs.core.Application |
configure() |
protected void |
configureClient(org.glassfish.jersey.client.ClientConfig config) |
protected org.glassfish.jersey.test.DeploymentContext |
configureDeployment() |
protected void |
disable(String featureName)
Programmatically disable a feature with a given name.
|
protected void |
enable(String featureName)
Programmatically enable a feature with a given name.
|
protected void |
forceDisable(String featureName)
Programmatically force-disable a feature with a given name.
|
protected void |
forceEnable(String featureName)
Programmatically force-enable a feature with a given name.
|
protected void |
forceSet(String propertyName,
String value)
Programmatically force-set a value of a property with a given name.
|
protected URI |
getBaseUri()
Returns the base URI of the tested application.
|
protected javax.ws.rs.client.Client |
getClient()
Get the JAX-RS test client that is
pre-configured
for this test. |
protected int |
getPort()
Get the port to be used for test application deployments.
|
protected org.glassfish.jersey.test.spi.TestContainerFactory |
getTestContainerFactory() |
protected boolean |
isEnabled(String propertyName)
Check if the Jersey test boolean property (flag) has been set to
true. |
protected void |
set(String propertyName,
Object value)
Programmatically set a value of a property with a given name.
|
protected void |
set(String propertyName,
String value)
Programmatically set a value of a property with a given name.
|
protected javax.ws.rs.client.Client |
setClient(javax.ws.rs.client.Client client)
Get the old JAX-RS test client and set a new one.
|
void |
setUp()
Set up the test by creating a test container instance,
starting it and by creating a new
pre-configured test client. |
javax.ws.rs.client.WebTarget |
target()
Create a JAX-RS web target whose URI refers to the
base URI the tested
JAX-RS / Jersey application is deployed at, plus the path specified in the path argument. |
javax.ws.rs.client.WebTarget |
target(String path)
Create a JAX-RS web target whose URI refers to the
base URI the tested
JAX-RS / Jersey application is deployed at, plus the path specified in the path argument. |
void |
tearDown()
Tear down the test by
stopping the test container obtained from the
test container factory and by closing
and discarding the pre-configured test client
that was set up for the test. |
public SSLJerseyTest()
This constructor can be used from an extending subclass.
When this constructor is used, the extending concrete subclass must implement one of the
configure() or configureDeployment() methods to provide the tested application
configuration and deployment context.
public SSLJerseyTest(org.glassfish.jersey.test.spi.TestContainerFactory testContainerFactory)
This constructor can be used from an extending subclass.
When this constructor is used, the extending concrete subclass must implement one of the
configure() or configureDeployment() methods to provide the tested application
configuration and deployment context.
testContainerFactory - the test container factory to use for testing.public SSLJerseyTest(javax.ws.rs.core.Application jaxrsApplication)
This constructor can be used from an extending subclass.
When this constructor is used, the extending concrete subclass must implement one of the
configure() or configureDeployment() methods are ignored.
Please note that when this constructor is used, recording of startup logs as well as configuring
other JerseyTest 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.
(E.g. when running parameterized tests in which application is created based on test parameters
passed in by JUnit framework via test constructor - in such case it is not possible to propagate
the necessary information to one of the overridden JerseyTest.configure... methods).
jaxrsApplication - tested application.public static void closeIfNotNull(javax.ws.rs.client.Client... clients)
clients - client instances to close. Each instance may be null.protected final void enable(String featureName)
featureName - name of the enabled feature.protected final void disable(String featureName)
featureName - name of the disabled feature.protected final void forceEnable(String featureName)
featureName - name of the force-enabled feature.protected final void forceDisable(String featureName)
featureName - name of the force-disabled feature.protected final void set(String propertyName, Object value)
propertyName - name of the property.value - property value.protected final void set(String propertyName, String value)
propertyName - name of the property.value - property value.protected final void forceSet(String propertyName, String value)
propertyName - name of the property.value - property value.protected final boolean isEnabled(String propertyName)
true.propertyName - name of the Jersey test boolean property.true if the test property has been enabled, false otherwise.protected javax.ws.rs.core.Application configure()
protected org.glassfish.jersey.test.DeploymentContext configureDeployment()
protected org.glassfish.jersey.test.spi.TestContainerFactory getTestContainerFactory()
throws org.glassfish.jersey.test.spi.TestContainerException
org.glassfish.jersey.test.spi.TestContainerExceptionpublic final javax.ws.rs.client.WebTarget target()
base URI the tested
JAX-RS / Jersey application is deployed at, plus the path specified in the path argument.
This method is an equivalent of calling client().target(getBaseUri()).
public final javax.ws.rs.client.WebTarget target(String path)
base URI the tested
JAX-RS / Jersey application is deployed at, plus the path specified in the path argument.
This method is an equivalent of calling target().path(path).
path - relative path (from tested application base URI) this web target should point to.public final javax.ws.rs.client.Client client()
pre-configured
for this test.public void setUp()
throws Exception
starting it and by creating a new
pre-configured test client.
The test container is obtained from the test container factory.org.glassfish.jersey.test.spi.TestContainerException - if the default test container factory cannot be obtained,
or the test application deployment context is not supported
by the test container factory.Exception - if an exception is thrown during setting up the test environment.public void tearDown()
throws Exception
stopping the test container obtained from the
test container factory and by closing
and discarding the pre-configured test client
that was set up for the test.Exception - if an exception is thrown during tearing down the test environment.protected javax.ws.rs.client.Client getClient()
pre-configured
for this test. This method can be overridden.protected javax.ws.rs.client.Client setClient(javax.ws.rs.client.Client client)
client - the configured test client.protected void configureClient(org.glassfish.jersey.client.ClientConfig config)
protected URI getBaseUri()
protected final int getPort()
public final void close(javax.ws.rs.core.Response... responses)
responses - responses to close. Each response may be null.Copyright © 2020. All rights reserved.