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<Flux<org.springframework.core.io.buffer.DataBuffer>, 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, for example, 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
    • applyAttributes

      protected void applyAttributes()
      Overrides:
      applyAttributes in class org.springframework.http.client.reactive.AbstractClientHttpRequest
    • writeWith

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

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

      public Mono<Void> setComplete()
    • getBody

      public Flux<org.springframework.core.io.buffer.DataBuffer> getBody()
      Return the request body, or an error stream if the body was never set or when setWriteHandler(Function) is configured.
    • getBodyAsString

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