Polishing

This commit is contained in:
Juergen Hoeller
2018-06-29 19:44:15 +02:00
parent df6b01a329
commit e22466e9d5
42 changed files with 300 additions and 326 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import org.springframework.web.util.UriComponentsBuilder;
/**
* Mock implementation of {@link ClientHttpRequest}.
*
* @author Brian Clozel
* @author Rossen Stoyanchev
* @since 5.0
@@ -97,11 +98,9 @@ public class MockClientHttpRequest extends AbstractClientHttpRequest {
/**
* Configure a custom handler for writing the request body.
*
* <p>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.
*
* @param writeHandler the write handler to use returning {@code Mono<Void>}
* when the body has been "written" (i.e. consumed).
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -125,10 +125,8 @@ public class MockServerHttpResponse extends AbstractServerHttpResponse {
* charset or "UTF-8" by default.
*/
public Mono<String> getBodyAsString() {
Charset charset = Optional.ofNullable(getHeaders().getContentType()).map(MimeType::getCharset)
.orElse(StandardCharsets.UTF_8);
return getBody()
.reduce(bufferFactory().allocateBuffer(), (previous, current) -> {
previous.write(current);
@@ -139,7 +137,6 @@ public class MockServerHttpResponse extends AbstractServerHttpResponse {
}
private static String bufferToString(DataBuffer buffer, Charset charset) {
Assert.notNull(charset, "'charset' must not be null");
byte[] bytes = new byte[buffer.readableByteCount()];
buffer.read(bytes);
return new String(bytes, charset);

View File

@@ -239,13 +239,16 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
/**
* Add expectations to this group.
* @deprecated as of 5.0.3 please use {@link #addAllExpectations(Collection)} instead.
* @deprecated as of 5.0.3, if favor of {@link #addAllExpectations}
*/
@Deprecated
public void updateAll(Collection<RequestExpectation> expectations) {
expectations.forEach(this::updateInternal);
}
/**
* Reset all expectations for this group.
*/
public void reset() {
this.expectations.clear();
}