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 Summary
ConstructorsConstructorDescriptionMockClientHttpRequest(org.springframework.http.HttpMethod httpMethod, String urlTemplate, Object... vars) MockClientHttpRequest(org.springframework.http.HttpMethod httpMethod, URI url) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected voidorg.springframework.core.io.buffer.DataBufferFactoryreactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>getBody()Return the request body, or an error stream if the body was never set or whensetWriteHandler(java.util.function.Function<reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>, reactor.core.publisher.Mono<java.lang.Void>>)is configured.reactor.core.publisher.Mono<String>Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.org.springframework.http.HttpMethod<T> TgetURI()reactor.core.publisher.Mono<Void>voidsetWriteHandler(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.reactor.core.publisher.Mono<Void>writeAndFlushWith(Publisher<? extends Publisher<? extends org.springframework.core.io.buffer.DataBuffer>> body) reactor.core.publisher.Mono<Void>Methods inherited from class org.springframework.http.client.reactive.AbstractClientHttpRequest
beforeCommit, doCommit, doCommit, getAttributes, getCookies, getHeaders, initReadOnlyHeaders, isCommitted
-
Constructor Details
-
MockClientHttpRequest
-
MockClientHttpRequest
-
-
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, for example, in test assertions. Use this property when the request body is an infinite stream.
- Parameters:
writeHandler- the write handler to use returningMono<Void>when the body has been "written" (i.e. consumed).
-
getMethod
public org.springframework.http.HttpMethod getMethod() -
getURI
-
bufferFactory
public org.springframework.core.io.buffer.DataBufferFactory bufferFactory() -
getNativeRequest
public <T> T getNativeRequest() -
applyHeaders
protected void applyHeaders()- Specified by:
applyHeadersin classorg.springframework.http.client.reactive.AbstractClientHttpRequest
-
applyCookies
protected void applyCookies()- Specified by:
applyCookiesin classorg.springframework.http.client.reactive.AbstractClientHttpRequest
-
applyAttributes
protected void applyAttributes()- Overrides:
applyAttributesin classorg.springframework.http.client.reactive.AbstractClientHttpRequest
-
writeWith
-
writeAndFlushWith
-
setComplete
-
getBody
public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> getBody()Return the request body, or an error stream if the body was never set or whensetWriteHandler(java.util.function.Function<reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>, reactor.core.publisher.Mono<java.lang.Void>>)is configured. -
getBodyAsString
Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.
-