org.springframework.mock.http.client.reactive

Class MockClientHttpRequest

    • Constructor Detail

      • MockClientHttpRequest

        public MockClientHttpRequest(HttpMethod httpMethod,
                                     java.lang.String urlTemplate,
                                     java.lang.Object... vars)
      • MockClientHttpRequest

        public MockClientHttpRequest(HttpMethod httpMethod,
                                     java.net.URI url)
    • Method Detail

      • setWriteHandler

        public void setWriteHandler(java.util.function.Function<reactor.core.publisher.Flux<DataBuffer>,reactor.core.publisher.Mono<java.lang.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 HttpMethod getMethod()
        Description copied from interface: ClientHttpRequest
        Return the HTTP method of the request.
      • getURI

        public java.net.URI getURI()
        Description copied from interface: ClientHttpRequest
        Return the URI of the request.
      • writeWith

        public reactor.core.publisher.Mono<java.lang.Void> writeWith(org.reactivestreams.Publisher<? extends DataBuffer> body)
        Description copied from interface: ReactiveHttpOutputMessage
        Use the given Publisher to write the body of the message to the underlying HTTP layer.
        Parameters:
        body - the body content publisher
        Returns:
        a Mono that indicates completion or error
      • writeAndFlushWith

        public reactor.core.publisher.Mono<java.lang.Void> writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
        Description copied from interface: ReactiveHttpOutputMessage
        Use the given Publisher of Publishers to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after each Publisher<DataBuffer>.
        Parameters:
        body - the body content publisher
        Returns:
        a Mono that indicates completion or error
      • setComplete

        public reactor.core.publisher.Mono<java.lang.Void> setComplete()
        Description copied from interface: ReactiveHttpOutputMessage
        Indicate that message handling is complete, allowing for any cleanup or end-of-processing tasks to be performed such as applying header changes made via HttpMessage.getHeaders() to the underlying HTTP message (if not applied already).

        This method should be automatically invoked at the end of message processing so typically applications should not have to invoke it. If invoked multiple times it should have no side effects.

        Returns:
        a Mono that indicates completion or error
      • getBodyAsString

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