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

public class JaxrsWebTestCase extends WebTestCase
Replaces WebTestCase to be used with JAXRS client instead of apache client
Author:
supol
  • Field Details

    • request

      protected jakarta.ws.rs.core.Request request
      The JAXRS request instance
    • response

      protected jakarta.ws.rs.core.Response response
      The JAXRS response instance
    • requestType

      protected String requestType
      GET, PUT, OPTIONS, ...
    • urlRequest

      protected String urlRequest
      The URL of the Request
    • entity

      protected Object 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 port
      port of the server
    • hostname

      protected String hostname
      host name of the server
    • headerMap

      protected Map<String,String> headerMap
      HTTP header list
    • _response

      protected HttpResponse _response
      Apache HTTP response mock
    • printEntity

      protected boolean printEntity
      print the response entity
    • bufferEntity

      protected boolean bufferEntity
      buffer the returned entity
    • loggingFilter

      protected Object loggingFilter
      Provider logging the request and response
    • providersToRegister

      protected List<Object> providersToRegister
      other providers, such as MessageBodyReader, or MessageBodyWriter
    • strategy

      protected ValidationStrategy strategy
      Strategy to use when validating the test case against the server's response.
    • printClientCall

      protected boolean printClientCall
      Show the call client code, used to be printed when report issues
    • textCaser

      protected TextCaser textCaser
      Upper case, lower case, or exact text matching?
    • asyncRunnable

      protected Runnable asyncRunnable
      Runnable to run while asynchronous
    • executionType

      protected JaxrsWebTestCase.Execution executionType
      Execution type instance
    • client

      protected jakarta.ws.rs.client.Client client
      Client instance here not to be garbage collected before end of test.
  • Constructor Details

    • JaxrsWebTestCase

      public JaxrsWebTestCase()
  • Method Details

    • setStrategy

      public void setStrategy(String validator)
      Sets the validation strategy for this test case instance.
      Overrides:
      setStrategy in class WebTestCase
      Parameters:
      validator - - the fully qualified class name of the response validator to use.
    • execute

      public void execute() throws TestFailureException
      Executes the test case.
      Specified by:
      execute in interface TestCase
      Overrides:
      execute in class WebTestCase
      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

      protected void verifySettings() throws TestFailureException
      Throws:
      TestFailureException
    • getClientWithRegisteredProviders

      protected jakarta.ws.rs.client.Client getClientWithRegisteredProviders()
      Returns:
      Client with all providers already registered
    • logClientRequestAndGetUrl

      protected String logClientRequestAndGetUrl()
    • printClientCall

      protected StringBuilder 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

      protected String getAcceptMediaType()
      Get media type in Request Content Type
    • getContentType

      protected String getContentType()
      Get media type in Request Content Type
    • getRequest

      public HttpRequest getRequest()
      Description copied from class: WebTestCase
      Returns the HttpRequest for this particular test case.
      Overrides:
      getRequest in class WebTestCase
      Returns:
      HttpRequest of this test case
    • getResponse

      public HttpResponse getResponse()
      Description copied from class: WebTestCase
      Returns the response for this particular test case.
      Overrides:
      getResponse in class WebTestCase
      Returns:
      an HttpResponse object
    • setRequestType

      public void setRequestType(String requestType)
    • getPort

      public int getPort()
    • setPort

      public void setPort(int port)
    • getHostname

      public String getHostname()
    • setHostname

      public void setHostname(String hostname)
    • getUrlRequest

      public String getUrlRequest()
    • setUrlRequest

      public void setUrlRequest(String urlRequest)
    • addHeader

      public void addHeader(String name, String value)
    • getJaxrsResponse

      public jakarta.ws.rs.core.Response getJaxrsResponse()
    • setEntity

      public void setEntity(Object entity)
    • 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

      public List<Object> getProvidersToRegister()
    • addProviderToRegister

      public void addProviderToRegister(Object providerToRegister)
    • setPrintClientCall

      public void setPrintClientCall(boolean print)
    • setProcessingType

      public void setProcessingType(JaxrsWebTestCase.Execution type)
    • getTextCaser

      public TextCaser getTextCaser()
    • setTextCaser

      public void setTextCaser(TextCaser textCaser)