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 enumType of execution -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HttpResponseApache HTTP response mockprotected RunnableRunnable to run while asynchronousprotected booleanbuffer the returned entityprotected jakarta.ws.rs.client.ClientClient instance here not to be garbage collected before end of test.protected ObjectThe HTTP content entity.protected JaxrsWebTestCase.ExecutionExecution type instanceHTTP header listprotected Stringhost name of the serverprotected ObjectProvider logging the request and responseprotected intport of the serverprotected booleanShow the call client code, used to be printed when report issuesprotected booleanprint the response entityother providers, such as MessageBodyReader, or MessageBodyWriterprotected jakarta.ws.rs.core.RequestThe JAXRS request instanceprotected StringGET, PUT, OPTIONS, ...protected jakarta.ws.rs.core.ResponseThe JAXRS response instanceprotected ValidationStrategyStrategy to use when validating the test case against the server's response.protected TextCaserUpper case, lower case, or exact text matching?protected StringThe 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 TypeMethodDescriptionvoidvoidaddProviderToRegister(Object providerToRegister) voidbufferEntity(boolean bufferEntity) protected jakarta.ws.rs.client.InvocationbuildRequest(jakarta.ws.rs.client.WebTarget target) Build Invocationvoidvoidexecute()Executes the test case.protected StringGet media type in Request Content Typeprotected jakarta.ws.rs.client.Clientprotected StringGet media type in Request Content Typejakarta.ws.rs.core.RequestReturns the Request for this particular test case.jakarta.ws.rs.core.ResponseintgetPort()Returns the HttpRequest for this particular test case.Returns the response for this particular test case.protected jakarta.ws.rs.core.Responseinvoke(jakarta.ws.rs.client.Invocation invocation) Invoke the invocation synchronously, or asynchronouslybooleanprotected Stringprotected StringBuilderLog java code executedvoidvoidsetHostname(String hostname) voidsetPort(int port) voidsetPrintClientCall(boolean print) voidsetPrintEntity(boolean printEntity) Set whether the entity is to be printed in trace log or not;voidvoidsetRequestType(String requestType) voidsetStrategy(String validator) Sets the validation strategy for this test case instance.voidsetTextCaser(TextCaser textCaser) voidsetUrlRequest(String urlRequest) protected voidprotected voidMethods 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:
setStrategyin classWebTestCase- Parameters:
validator- - the fully qualified class name of the response validator to use.
-
execute
Executes the test case.- Specified by:
executein interfaceTestCase- Overrides:
executein 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:WebTestCaseReturns the HttpRequest for this particular test case.- Overrides:
getRequestin classWebTestCase- Returns:
- HttpRequest of this test case
-
getResponse
Description copied from class:WebTestCaseReturns the response for this particular test case.- Overrides:
getResponsein 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
-