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
ConstructorDescriptionMockClientHttpRequest
(org.springframework.http.HttpMethod httpMethod, String urlTemplate, Object... vars) MockClientHttpRequest
(org.springframework.http.HttpMethod httpMethod, URI url) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
org.springframework.core.io.buffer.DataBufferFactory
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.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> T
getURI()
reactor.core.publisher.Mono<Void>
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.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, 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, e.g. 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:
applyHeaders
in classorg.springframework.http.client.reactive.AbstractClientHttpRequest
-
applyCookies
protected void applyCookies()- Specified by:
applyCookies
in 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.
-