Class MockClientHttpRequest

java.lang.Object
org.springframework.http.client.reactive.AbstractClientHttpRequest
org.springframework.mock.http.client.reactive.MockClientHttpRequest
All Implemented Interfaces:
org.springframework.http.client.reactive.ClientHttpRequest, org.springframework.http.HttpMessage, org.springframework.http.ReactiveHttpOutputMessage

public class MockClientHttpRequest extends org.springframework.http.client.reactive.AbstractClientHttpRequest
Mock implementation of ClientHttpRequest.
Since:
5.0
Author:
Brian Clozel, Rossen Stoyanchev
  • Constructor Details

    • MockClientHttpRequest

      public MockClientHttpRequest(org.springframework.http.HttpMethod httpMethod, String urlTemplate, Object... vars)
    • MockClientHttpRequest

      public MockClientHttpRequest(org.springframework.http.HttpMethod httpMethod, URI url)
  • Method Details

    • setWriteHandler

      public void setWriteHandler(Function<reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)
      Configure a custom handler for writing the request body.

      The default write handler consumes and caches the request body so it may be accessed subsequently, e.g. in test assertions. Use this property when the request body is an infinite stream.

      Parameters:
      writeHandler - the write handler to use returning Mono<Void> when the body has been "written" (i.e. consumed).
    • getMethod

      public org.springframework.http.HttpMethod getMethod()
    • getURI

      public URI getURI()
    • bufferFactory

      public org.springframework.core.io.buffer.DataBufferFactory bufferFactory()
    • getNativeRequest

      public <T> T getNativeRequest()
    • applyHeaders

      protected void applyHeaders()
      Specified by:
      applyHeaders in class org.springframework.http.client.reactive.AbstractClientHttpRequest
    • applyCookies

      protected void applyCookies()
      Specified by:
      applyCookies in class org.springframework.http.client.reactive.AbstractClientHttpRequest
    • writeWith

      public reactor.core.publisher.Mono<Void> writeWith(Publisher<? extends org.springframework.core.io.buffer.DataBuffer> body)
    • writeAndFlushWith

      public reactor.core.publisher.Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends org.springframework.core.io.buffer.DataBuffer>> body)
    • setComplete

      public reactor.core.publisher.Mono<Void> setComplete()
    • getBody

      public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> getBody()
    • getBodyAsString

      public reactor.core.publisher.Mono<String> getBodyAsString()
      Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.