Skip to content

Commit d71957c

Browse files
committed
Polishing
1 parent 7244f03 commit d71957c

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
7878

7979
private MockServerHttpRequest(@Nullable HttpMethod httpMethod, @Nullable String customHttpMethod,
8080
URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies,
81-
@Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress,
81+
@Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress,
8282
@Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) {
8383

8484
super(uri, contextPath, headers);
8585
Assert.isTrue(httpMethod != null || customHttpMethod != null, "HTTP method must not be null");
8686
this.httpMethod = httpMethod;
8787
this.customHttpMethod = customHttpMethod;
8888
this.cookies = cookies;
89-
this.remoteAddress = remoteAddress;
9089
this.localAddress = localAddress;
90+
this.remoteAddress = remoteAddress;
9191
this.sslInfo = sslInfo;
9292
this.body = Flux.from(body);
9393
}
@@ -382,9 +382,9 @@ public interface BaseBuilder<B extends BaseBuilder<B>> {
382382
* @see BodyBuilder#body(String)
383383
*/
384384
MockServerHttpRequest build();
385-
386385
}
387386

387+
388388
/**
389389
* A builder that adds a body to the request.
390390
*/
@@ -423,15 +423,13 @@ public interface BodyBuilder extends BaseBuilder<BodyBuilder> {
423423
* @return the built request entity
424424
*/
425425
MockServerHttpRequest body(String body);
426-
427426
}
428427

429428

430429
private static class DefaultBodyBuilder implements BodyBuilder {
431430

432431
private static final DataBufferFactory BUFFER_FACTORY = new DefaultDataBufferFactory();
433432

434-
435433
@Nullable
436434
private final HttpMethod method;
437435

@@ -612,7 +610,7 @@ private Charset getCharset() {
612610
public MockServerHttpRequest body(Publisher<? extends DataBuffer> body) {
613611
applyCookiesIfNecessary();
614612
return new MockServerHttpRequest(this.method, this.customMethod, getUrlToUse(), this.contextPath,
615-
this.headers, this.cookies, this.remoteAddress, this.localAddress, this.sslInfo, body);
613+
this.headers, this.cookies, this.localAddress, this.remoteAddress, this.sslInfo, body);
616614
}
617615

618616
private void applyCookiesIfNecessary() {
@@ -625,11 +623,9 @@ private void applyCookiesIfNecessary() {
625623
private URI getUrlToUse() {
626624
MultiValueMap<String, String> params =
627625
this.queryParamsBuilder.buildAndExpand().encode().getQueryParams();
628-
629626
if (!params.isEmpty()) {
630627
return UriComponentsBuilder.fromUri(this.url).queryParams(params).build(true).toUri();
631628
}
632-
633629
return this.url;
634630
}
635631
}

spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
7878

7979
private MockServerHttpRequest(@Nullable HttpMethod httpMethod, @Nullable String customHttpMethod,
8080
URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies,
81-
@Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress,
81+
@Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress,
8282
@Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) {
8383

8484
super(uri, contextPath, headers);
8585
Assert.isTrue(httpMethod != null || customHttpMethod != null, "HTTP method must not be null");
8686
this.httpMethod = httpMethod;
8787
this.customHttpMethod = customHttpMethod;
8888
this.cookies = cookies;
89-
this.remoteAddress = remoteAddress;
9089
this.localAddress = localAddress;
90+
this.remoteAddress = remoteAddress;
9191
this.sslInfo = sslInfo;
9292
this.body = Flux.from(body);
9393
}
@@ -382,9 +382,9 @@ public interface BaseBuilder<B extends BaseBuilder<B>> {
382382
* @see BodyBuilder#body(String)
383383
*/
384384
MockServerHttpRequest build();
385-
386385
}
387386

387+
388388
/**
389389
* A builder that adds a body to the request.
390390
*/
@@ -423,15 +423,13 @@ public interface BodyBuilder extends BaseBuilder<BodyBuilder> {
423423
* @return the built request entity
424424
*/
425425
MockServerHttpRequest body(String body);
426-
427426
}
428427

429428

430429
private static class DefaultBodyBuilder implements BodyBuilder {
431430

432431
private static final DataBufferFactory BUFFER_FACTORY = new DefaultDataBufferFactory();
433432

434-
435433
@Nullable
436434
private final HttpMethod method;
437435

@@ -612,7 +610,7 @@ private Charset getCharset() {
612610
public MockServerHttpRequest body(Publisher<? extends DataBuffer> body) {
613611
applyCookiesIfNecessary();
614612
return new MockServerHttpRequest(this.method, this.customMethod, getUrlToUse(), this.contextPath,
615-
this.headers, this.cookies, this.remoteAddress, this.localAddress, this.sslInfo, body);
613+
this.headers, this.cookies, this.localAddress, this.remoteAddress, this.sslInfo, body);
616614
}
617615

618616
private void applyCookiesIfNecessary() {
@@ -625,11 +623,9 @@ private void applyCookiesIfNecessary() {
625623
private URI getUrlToUse() {
626624
MultiValueMap<String, String> params =
627625
this.queryParamsBuilder.buildAndExpand().encode().getQueryParams();
628-
629626
if (!params.isEmpty()) {
630627
return UriComponentsBuilder.fromUri(this.url).queryParams(params).build(true).toUri();
631628
}
632-
633629
return this.url;
634630
}
635631
}

spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurationSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ public RequestMappingHandlerAdapter requestMappingHandlerAdapter(
273273
ServerCodecConfigurer serverCodecConfigurer,
274274
@Qualifier("webFluxConversionService") FormattingConversionService conversionService,
275275
@Qualifier("webFluxValidator") Validator validator) {
276+
276277
RequestMappingHandlerAdapter adapter = createRequestMappingHandlerAdapter();
277278
adapter.setMessageReaders(serverCodecConfigurer.getReaders());
278279
adapter.setWebBindingInitializer(getConfigurableWebBindingInitializer(conversionService, validator));

0 commit comments

Comments
 (0)