Class MockRestClient
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- HttpClient,- HttpClientConnection,- HttpConnection,- AnnotationProvider
RestClient.
 
   This class is used for performing serverless unit testing of @Rest-annotated and @Remote-annotated classes.
 
   The class itself extends from RestClient providing it with the rich feature set of that API and combines
   it with the Apache HttpClient HttpClientConnection interface for processing requests.
  The class converts HttpRequest objects to instances of MockServletRequest and MockServletResponse which are passed directly
  to the call handler on the resource class RestContext.execute(Object,HttpServletRequest,HttpServletResponse).
  In effect, you're fully testing your REST API as if it were running in a live servlet container, yet not
  actually having to run in a servlet container.
  All aspects of the client and server side code are tested, yet no servlet container is required.  The actual
  over-the-wire transmission is the only aspect being bypassed.
 
The following shows a simple example of invoking a PUT method on a simple REST interface and asserting the correct status code and response body:
Example:
   
Breaking apart the fluent method call above will help you understand how this works.
   
   The 
   The MockRestRequest object has convenience methods provided to allow you to set any properties
   directly on the underlying HttpServletRequest object.  The following example shows how
   this can be used to directly set roles on the request object to perform security testing.
 
Example:
   
Debug mode is provided that will cause your HTTP requests and responses to be sent to the console:
Example:
   MockRestClient 
   The class can also be used for testing of @Remote-annotated interfaces against @Rest-annotated resources.
 
Example:
   
Notes:
- This class is thread safe and reusable.
See Also:
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields inherited from class org.apache.juneau.ContextCONTEXT_APPLY_FILTERFields inherited from interface org.apache.juneau.AnnotationProviderDEFAULT, DISABLE_ANNOTATION_CACHING
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic MockRestClientCreates a newRestClientwith no registered serializer or parser.static MockRestClientCreates a newRestClientwith JSON marshalling support.static MockRestClientbuildJson5(Object impl) Creates a newRestClientwith Simplified-JSON marshalling support.static MockRestClientbuildJson5Lax(Object impl) Creates a newRestClientwith Simplified-JSON marshalling support.static MockRestClientbuildJsonLax(Object impl) Creates a newRestClientwith JSON marshalling support.static MockRestClientCreates a newRestClientwith no registered serializer or parser.Performs a REST call where the entire call is specified in a simple string.voidclose()CallsCloseable.close()on the underlyingCloseableHttpClient.static MockRestClient.BuilderCreates a newRestClient.Builderconfigured with the specified REST implementation bean or bean class.static MockRestClient.BuilderCreates a newRestClient.Builderconfigured with the specified REST implementation bean or bean class.protected MockRestRequestcreateRequest(URI uri, String method, boolean hasBody) Creates aRestRequestobject from the specifiedHttpRequestobject.protected MockRestResponsecreateResponse(RestRequest req, HttpResponse httpResponse, Parser parser) Creates aRestResponseobject from the specifiedHttpResponseobject.Perform aDELETE request against the specified URI.voidflush()Same asRestClient.formPost(Object, Object)but doesn't specify the input yet.Perform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.formPostPairs(Object url, String... parameters) Perform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.get()Perform aGET request against the root URI.Perform aGET request against the specified URI.Returns the current client-side REST request.Returns the current client-side REST response.Returns the current server-side REST request.Returns the current server-side REST response.intPerform aHEAD request against the specified URI.booleanisOpen()booleanisResponseAvailable(int timeout) booleanisStale()Perform anOPTIONS request against the specified URI.Same asRestClient.patch(Object, Object)but don't specify the input yet.Perform aPATCH request against the specified URI.patch(Object url, String body, ContentType contentType) Perform aPATCH request against the specified URI as a plain text body bypassing the serializer.Same asRestClient.post(Object, Object)but don't specify the input yet.Perform aPOST request against the specified URI.post(Object url, String body, ContentType contentType) Perform aPOST request against the specified URI as a plain text body bypassing the serializer.Same asRestClient.put(Object, Object)but don't specify the input yet.Perform aPUT request against the specified URI.put(Object url, String body, ContentType contentType) Perform aPUT request against the specified URI using a plain text body bypassing the serializer.voidreceiveResponseEntity(HttpResponse response) Perform a generic REST call.Perform a generic REST call.Perform a generic REST call.request(RestOperation op) Perform an arbitrary request against the specified URI.voidvoidsendRequestHeader(HttpRequest request) voidsetSocketTimeout(int timeout) voidshutdown()Methods inherited from class org.apache.juneau.rest.client.RestClientcloseQuietly, copy, create, createFormData, createHeaderData, createPathData, createQueryData, execute, execute, execute, execute, execute, execute, execute, execute, finalize, getConnectionManager, getHttpClientConnectionManager, getParams, getPartParser, getPartParser, getPartSerializer, getPartSerializer, getRemote, getRemote, getRemote, getRrpcInterface, getRrpcInterface, getRrpcInterface, init, init, isSkipEmptyFormData, isSkipEmptyHeaderData, isSkipEmptyQueryData, log, log, onCallClose, onCallConnect, onCallInit, properties, runMethods inherited from class org.apache.juneau.BeanContextablegetBeanContextMethods inherited from class org.apache.juneau.ContextcreateBuilder, createSession, firstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, getSession, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, init, isDebug, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation, toString
- 
Constructor Details- 
MockRestClientConstructor.- Parameters:
- builder- The builder for this object.
 
 
- 
- 
Method Details- 
createCreates a newRestClient.Builderconfigured with the specified REST implementation bean or bean class.- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
createLaxCreates a newRestClient.Builderconfigured with the specified REST implementation bean or bean class.Same as create(Object)but HTTP 400+ codes don't triggerRestCallExceptions.- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
buildCreates a newRestClientwith no registered serializer or parser.Equivalent to calling: MockRestClient. create (impl ).build();- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
buildLaxCreates a newRestClientwith no registered serializer or parser.Same as build(Object)but HTTP 400+ codes don't triggerRestCallExceptions.Equivalent to calling: MockRestClient. create (impl ).ignoreErrors().noTrace().build();- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
buildJsonCreates a newRestClientwith JSON marshalling support.Equivalent to calling: MockRestClient. create (impl ).json().build();- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
buildJsonLaxCreates a newRestClientwith JSON marshalling support.Same as buildJson(Object)but HTTP 400+ codes don't triggerRestCallExceptions.Equivalent to calling: MockRestClient. create (impl ).json().ignoreErrors().build();- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
buildJson5Creates a newRestClientwith Simplified-JSON marshalling support.Equivalent to calling: MockRestClient. create (impl ).json().build();- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
buildJson5LaxCreates a newRestClientwith Simplified-JSON marshalling support.Same as buildJson5(Object)but HTTP 400+ codes don't triggerRestCallExceptions.Equivalent to calling: MockRestClient. create (impl ).json().ignoreErrors().build();- Parameters:
- impl- The REST bean or bean class annotated with- @Rest.
 If a class, it must have a no-arg constructor.
- Returns:
- A new builder.
 
- 
requestDescription copied from class:RestClientPerform an arbitrary request against the specified URI.All requests feed through this method so it can be used to intercept request creations and make modifications (such as add headers). - Overrides:
- requestin class- RestClient
- Parameters:
- op- The operation that identifies the HTTP method, URL, and optional payload.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
getDescription copied from class:RestClientPerform aGET request against the specified URI.- Overrides:
- getin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
getDescription copied from class:RestClientPerform aGET request against the root URI.- Overrides:
- getin class- RestClient
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
putDescription copied from class:RestClientPerform aPUT request against the specified URI.- Overrides:
- putin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request. Can be of the following types:- 
         Reader- Raw contents ofReaderwill be serialized to remote resource.
- 
         InputStream- Raw contents ofInputStreamwill be serialized to remote resource.
- 
         Object- POJO to be converted to text using theSerializerregistered with theRestClient.
- 
         HttpEntity/HttpResource- Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
- 
         PartList- Converted to a URL-encoded FORM post.
- 
         Supplier- A supplier of anything on this list.
 
- 
         
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
putpublic MockRestRequest put(Object url, String body, ContentType contentType) throws RestCallException Description copied from class:RestClientPerform aPUT request against the specified URI using a plain text body bypassing the serializer.- Overrides:
- putin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request bypassing the serializer.
- contentType- The content type of the request.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
putDescription copied from class:RestClientSame asRestClient.put(Object, Object)but don't specify the input yet.You must call either RestRequest.content(Object)orRestRequest.formData(String, Object)to set the contents on the result object.- Overrides:
- putin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- REST call failed.
 
- 
postDescription copied from class:RestClientPerform aPOST request against the specified URI.Notes:- Use RestClient.formPost(Object, Object)forapplication/x-www-form-urlencoded form posts.
 - Overrides:
- postin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request. Can be of the following types:- 
         Reader- Raw contents ofReaderwill be serialized to remote resource.
- 
         InputStream- Raw contents ofInputStreamwill be serialized to remote resource.
- 
         Object- POJO to be converted to text using theSerializerregistered with theRestClient.
- 
         HttpEntity/HttpResource- Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
- 
         PartList- Converted to a URL-encoded FORM post.
- 
         Supplier- A supplier of anything on this list.
 
- 
         
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- Use 
- 
postpublic MockRestRequest post(Object url, String body, ContentType contentType) throws RestCallException Description copied from class:RestClientPerform aPOST request against the specified URI as a plain text body bypassing the serializer.- Overrides:
- postin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request bypassing the serializer.
- contentType- The content type of the request.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
postDescription copied from class:RestClientSame asRestClient.post(Object, Object)but don't specify the input yet.You must call either RestRequest.content(Object)orRestRequest.formData(String, Object)to set the contents on the result object.Notes:- Use RestClient.formPost(Object, Object)forapplication/x-www-form-urlencoded form posts.
 - Overrides:
- postin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- REST call failed.
 
- Use 
- 
deleteDescription copied from class:RestClientPerform aDELETE request against the specified URI.- Overrides:
- deletein class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
optionsDescription copied from class:RestClientPerform anOPTIONS request against the specified URI.- Overrides:
- optionsin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
headDescription copied from class:RestClientPerform aHEAD request against the specified URI.- Overrides:
- headin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
formPostDescription copied from class:RestClientPerform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.- Overrides:
- formPostin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request.- NameValuePair- URL-encoded as a single name-value pair.
- NameValuePairarray - URL-encoded as name value pairs.
- PartList- URL-encoded as name value pairs.
- Reader/- InputStream- Streamed directly and- Content-Type set to- "application/x-www-form-urlencoded" 
- HttpResource- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request.
- HttpEntity- Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
- Object- Converted to a- SerializedEntityusing- UrlEncodingSerializerto serialize.
- Supplier- A supplier of anything on this list.
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
formPostDescription copied from class:RestClientSame asRestClient.formPost(Object, Object)but doesn't specify the input yet.- Overrides:
- formPostin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
formPostPairsDescription copied from class:RestClientPerform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.- Overrides:
- formPostPairsin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- parameters- The parameters of the form post.
 The parameters represent name/value pairs and must be an even number of arguments.
 Parameters are converted to- BasicPartobjects.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
patchDescription copied from class:RestClientPerform aPATCH request against the specified URI.- Overrides:
- patchin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request. Can be of the following types:- 
         Reader- Raw contents ofReaderwill be serialized to remote resource.
- 
         InputStream- Raw contents ofInputStreamwill be serialized to remote resource.
- 
         HttpResource- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request.
- 
         HttpEntity- Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
- 
         Object- POJO to be converted to text using theSerializerregistered with theRestClient.
- 
         PartList- Converted to a URL-encoded FORM post.
- 
         Supplier- A supplier of anything on this list.
 
- 
         
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
patchpublic MockRestRequest patch(Object url, String body, ContentType contentType) throws RestCallException Description copied from class:RestClientPerform aPATCH request against the specified URI as a plain text body bypassing the serializer.- Overrides:
- patchin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The object to serialize and transmit to the URI as the body of the request bypassing the serializer.
- contentType- The content type of the request.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
patchDescription copied from class:RestClientSame asRestClient.patch(Object, Object)but don't specify the input yet.You must call RestRequest.content(Object)to set the contents on the result object.- Overrides:
- patchin class- RestClient
- Parameters:
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- REST call failed.
 
- 
callbackDescription copied from class:RestClientPerforms a REST call where the entire call is specified in a simple string.This method is useful for performing callbacks when the target of a callback is passed in on an initial request, for example to signal when a long-running process has completed. The call string can be any of the following formats: - 
      "[method] [uri]" - e.g."GET http://localhost/callback" 
- 
      "[method] [uri] [payload]" - e.g."POST http://localhost/callback some text payload" 
- 
      "[method] [headers] [uri] [payload]" - e.g."POST {'Content-Type':'text/json'} http://localhost/callback {'some':'json'}" 
 The payload will always be sent using a simple StringEntity.- Overrides:
- callbackin class- RestClient
- Parameters:
- callString- The call string.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- REST call failed.
 
- 
      
- 
requestDescription copied from class:RestClientPerform a generic REST call.- Overrides:
- requestin class- RestClient
- Parameters:
- method- The HTTP method.
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- body- The HTTP body content. Can be of the following types:- 
         Reader- Raw contents ofReaderwill be serialized to remote resource.
- 
         InputStream- Raw contents ofInputStreamwill be serialized to remote resource.
- 
         HttpResource- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request.
- 
         HttpEntity- Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
- 
         Object- POJO to be converted to text using theSerializerregistered with theRestClient.
- 
         PartList- Converted to a URL-encoded FORM post.
- 
         Supplier- A supplier of anything on this list.
 
- 
         
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
requestDescription copied from class:RestClientPerform a generic REST call.- Overrides:
- requestin class- RestClient
- Parameters:
- method- The HTTP method.
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
requestDescription copied from class:RestClientPerform a generic REST call.Typically you're going to use RestClient.request(String, Object)orRestClient.request(String, Object, Object), but this method is provided to allow you to perform non-standard HTTP methods (e.g. HTTP FOO).- Overrides:
- requestin class- RestClient
- Parameters:
- method- The method name (e.g.- "GET" ,- "OPTIONS" ).
- url- The URI of the remote REST resource.
 Can be any of the following types:- URIBuilder
- URI
- URL
- String
- Object- Converted to- String using- toString() 
 
- hasBody- Boolean flag indicating if the specified request has content associated with it.
- Returns:
- A RestRequestobject that can be further tailored before executing the request and getting the response as a parsed object.
- Throws:
- RestCallException- If any authentication errors occurred.
 
- 
getCurrentClientRequestReturns the current client-side REST request.Note that this uses a ThreadLocalobject for storage and so will not work on requests executed in separate threads such as when usingFutures.- Returns:
- The current client-side REST request, or null if not set.
 
- 
getCurrentClientResponseReturns the current client-side REST response.Note that this uses a ThreadLocalobject for storage and so will not work on requests executed in separate threads such as when usingFutures.- Returns:
- The current client-side REST response, or null if not set.
 
- 
getCurrentServerRequestReturns the current server-side REST request.Note that this uses a ThreadLocalobject for storage and so will not work on requests executed in separate threads such as when usingFutures.- Returns:
- The current server-side REST request, or null if not set.
 
- 
getCurrentServerResponseReturns the current server-side REST response.Note that this uses a ThreadLocalobject for storage and so will not work on requests executed in separate threads such as when usingFutures.- Returns:
- The current server-side REST response, or null if not set.
 
- 
createRequestprotected MockRestRequest createRequest(URI uri, String method, boolean hasBody) throws RestCallException Description copied from class:RestClientCreates aRestRequestobject from the specifiedHttpRequestobject.Subclasses can override this method to provide their own specialized RestRequestobjects.- Overrides:
- createRequestin class- RestClient
- Parameters:
- uri- The target.
- method- The HTTP method (uppercase).
- hasBody- Whether this method has a request entity.
- Returns:
- A new RestRequestobject.
- Throws:
- RestCallException- If an exception or non-200 response code occurred during the connection attempt.
 
- 
createResponseprotected MockRestResponse createResponse(RestRequest req, HttpResponse httpResponse, Parser parser) throws RestCallException Description copied from class:RestClientCreates aRestResponseobject from the specifiedHttpResponseobject.Subclasses can override this method to provide their own specialized RestResponseobjects.- Overrides:
- createResponsein class- RestClient
- Parameters:
- req- The request creating this response.
- httpResponse- The response object to wrap.
- parser- The parser to use to parse the response.
- Returns:
- A new RestResponseobject.
- Throws:
- RestCallException- If an exception or non-200 response code occurred during the connection attempt.
 
- 
closeDescription copied from class:RestClientCallsCloseable.close()on the underlyingCloseableHttpClient.It's good practice to call this method after the client is no longer used. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- HttpConnection
- Overrides:
- closein class- RestClient
- Throws:
- IOException- Thrown by underlying stream.
 
- 
isOpen- Specified by:
- isOpenin interface- HttpConnection
 
- 
isStale- Specified by:
- isStalein interface- HttpConnection
 
- 
setSocketTimeout- Specified by:
- setSocketTimeoutin interface- HttpConnection
 
- 
getSocketTimeout- Specified by:
- getSocketTimeoutin interface- HttpConnection
 
- 
shutdown- Specified by:
- shutdownin interface- HttpConnection
- Throws:
- IOException
 
- 
getMetrics- Specified by:
- getMetricsin interface- HttpConnection
 
- 
isResponseAvailable- Specified by:
- isResponseAvailablein interface- HttpClientConnection
- Throws:
- IOException
 
- 
sendRequestHeader- Specified by:
- sendRequestHeaderin interface- HttpClientConnection
- Throws:
- HttpException
- IOException
 
- 
sendRequestEntity- Specified by:
- sendRequestEntityin interface- HttpClientConnection
- Throws:
- HttpException
- IOException
 
- 
receiveResponseHeader- Specified by:
- receiveResponseHeaderin interface- HttpClientConnection
- Throws:
- HttpException
- IOException
 
- 
receiveResponseEntity- Specified by:
- receiveResponseEntityin interface- HttpClientConnection
- Throws:
- HttpException
- IOException
 
- 
flush- Specified by:
- flushin interface- HttpClientConnection
- Throws:
- IOException
 
 
-