Class JaxrsWebTestCase
java.lang.Object
ee.jakarta.tck.ws.rs.common.webclient.WebTestCase
ee.jakarta.tck.ws.rs.common.client.JaxrsWebTestCase
- All Implemented Interfaces:
TestCase
Replaces WebTestCase to be used with JAXRS client instead of apache client
- Author:
- supol
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enum
Type of execution -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HttpResponse
Apache HTTP response mockprotected Runnable
Runnable to run while asynchronousprotected boolean
buffer the returned entityprotected jakarta.ws.rs.client.Client
Client instance here not to be garbage collected before end of test.protected Object
The HTTP content entity.protected JaxrsWebTestCase.Execution
Execution type instanceHTTP header listprotected String
host name of the serverprotected Object
Provider logging the request and responseprotected int
port of the serverprotected boolean
Show the call client code, used to be printed when report issuesprotected boolean
print the response entityother providers, such as MessageBodyReader, or MessageBodyWriterprotected jakarta.ws.rs.core.Request
The JAXRS request instanceprotected String
GET, PUT, OPTIONS, ...protected jakarta.ws.rs.core.Response
The JAXRS response instanceprotected ValidationStrategy
Strategy to use when validating the test case against the server's response.protected TextCaser
Upper case, lower case, or exact text matching?protected String
The URL of the RequestFields inherited from class ee.jakarta.tck.ws.rs.common.webclient.WebTestCase
TOKENIZED_STRATEGY, WHITESPACE_STRATEGY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addProviderToRegister
(Object providerToRegister) void
bufferEntity
(boolean bufferEntity) protected jakarta.ws.rs.client.Invocation
buildRequest
(jakarta.ws.rs.client.WebTarget target) Build Invocationvoid
void
execute()
Executes the test case.protected String
Get media type in Request Content Typeprotected jakarta.ws.rs.client.Client
protected String
Get media type in Request Content Typejakarta.ws.rs.core.Request
Returns the Request for this particular test case.jakarta.ws.rs.core.Response
int
getPort()
Returns the HttpRequest for this particular test case.Returns the response for this particular test case.protected jakarta.ws.rs.core.Response
invoke
(jakarta.ws.rs.client.Invocation invocation) Invoke the invocation synchronously, or asynchronouslyboolean
protected String
protected StringBuilder
Log java code executedvoid
void
setHostname
(String hostname) void
setPort
(int port) void
setPrintClientCall
(boolean print) void
setPrintEntity
(boolean printEntity) Set whether the entity is to be printed in trace log or not;void
void
setRequestType
(String requestType) void
setStrategy
(String validator) Sets the validation strategy for this test case instance.void
setTextCaser
(TextCaser textCaser) void
setUrlRequest
(String urlRequest) protected void
protected void
Methods inherited from class ee.jakarta.tck.ws.rs.common.webclient.WebTestCase
addExpectedHeader, addUnexpectedHeader, getExpectedHeaders, getExpectResponseBody, getGoldenfilePath, getName, getReasonPhrase, getSearchStrings, getSearchStringsNoCase, getState, getStatusCode, getStrategy, getUnexpectedHeaders, getUnexpectedSearchStrings, getUnorderedSearchStrings, setAssertNoResponseBody, setExpectedReasonPhrase, setExpectedStatusCode, setGoldenFilePath, setName, setRequest, setResponseSearchString, setResponseSearchStringIgnoreCase, setState, setUnexpectedResponseSearchString, setUnorderedSearchString
-
Field Details
-
request
protected jakarta.ws.rs.core.Request requestThe JAXRS request instance -
response
protected jakarta.ws.rs.core.Response responseThe JAXRS response instance -
requestType
GET, PUT, OPTIONS, ... -
urlRequest
The URL of the Request -
entity
The HTTP content entity. A MessageBodyWriter<entity.getClass()> needs to be registered if not a standard entity type supported by JAXRS -
port
protected int portport of the server -
hostname
host name of the server -
headerMap
HTTP header list -
_response
Apache HTTP response mock -
printEntity
protected boolean printEntityprint the response entity -
bufferEntity
protected boolean bufferEntitybuffer the returned entity -
loggingFilter
Provider logging the request and response -
providersToRegister
other providers, such as MessageBodyReader, or MessageBodyWriter -
strategy
Strategy to use when validating the test case against the server's response. -
printClientCall
protected boolean printClientCallShow the call client code, used to be printed when report issues -
textCaser
Upper case, lower case, or exact text matching? -
asyncRunnable
Runnable to run while asynchronous -
executionType
Execution type instance -
client
protected jakarta.ws.rs.client.Client clientClient instance here not to be garbage collected before end of test.
-
-
Constructor Details
-
JaxrsWebTestCase
public JaxrsWebTestCase()
-
-
Method Details
-
setStrategy
Sets the validation strategy for this test case instance.- Overrides:
setStrategy
in classWebTestCase
- Parameters:
validator
- - the fully qualified class name of the response validator to use.
-
execute
Executes the test case.- Specified by:
execute
in interfaceTestCase
- Overrides:
execute
in classWebTestCase
- Throws:
TestFailureException
- if the test fails for any reason.IllegalStateException
- if no request was configured or if no Validator is available at runtime.
-
closeClient
public void closeClient() -
verifyValidationStrategy
protected void verifyValidationStrategy() -
verifySettings
- Throws:
TestFailureException
-
getClientWithRegisteredProviders
protected jakarta.ws.rs.client.Client getClientWithRegisteredProviders()- Returns:
- Client with all providers already registered
-
logClientRequestAndGetUrl
-
printClientCall
Log java code executed -
buildRequest
protected jakarta.ws.rs.client.Invocation buildRequest(jakarta.ws.rs.client.WebTarget target) Build Invocation -
invoke
protected jakarta.ws.rs.core.Response invoke(jakarta.ws.rs.client.Invocation invocation) throws TestFailureException Invoke the invocation synchronously, or asynchronously- Throws:
TestFailureException
-
getAcceptMediaType
Get media type in Request Content Type -
getContentType
Get media type in Request Content Type -
getRequest
Description copied from class:WebTestCase
Returns the HttpRequest for this particular test case.- Overrides:
getRequest
in classWebTestCase
- Returns:
- HttpRequest of this test case
-
getResponse
Description copied from class:WebTestCase
Returns the response for this particular test case.- Overrides:
getResponse
in classWebTestCase
- Returns:
- an HttpResponse object
-
setRequestType
-
getPort
public int getPort() -
setPort
public void setPort(int port) -
getHostname
-
setHostname
-
getUrlRequest
-
setUrlRequest
-
addHeader
-
getJaxrsResponse
public jakarta.ws.rs.core.Response getJaxrsResponse() -
setEntity
-
getJaxrsRequest
public jakarta.ws.rs.core.Request getJaxrsRequest()Returns the Request for this particular test case.- Returns:
- Request of this test case
-
isPrintedEntity
public boolean isPrintedEntity() -
setPrintEntity
public void setPrintEntity(boolean printEntity) Set whether the entity is to be printed in trace log or not; -
bufferEntity
public void bufferEntity(boolean bufferEntity) -
getProvidersToRegister
-
addProviderToRegister
-
setPrintClientCall
public void setPrintClientCall(boolean print) -
setProcessingType
-
getTextCaser
-
setTextCaser
-