Skip to content

Commit 31578c4

Browse files
committed
Remove deprecated web APIs in spring-test
See gh-33809
1 parent 2ed281f commit 31578c4

File tree

9 files changed

+9
-114
lines changed

9 files changed

+9
-114
lines changed

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

-31
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,6 @@ public static BodyBuilder method(HttpMethod method, String uri, @Nullable Object
209209
return method(method, toUri(uri, vars));
210210
}
211211

212-
/**
213-
* Create a builder with a raw HTTP method value that is outside the
214-
* range of {@link HttpMethod} enum values.
215-
* @param httpMethod the HTTP methodValue value
216-
* @param uri the URI template for target the URL
217-
* @param vars variables to expand into the template
218-
* @return the created builder
219-
* @since 5.2.7
220-
* @deprecated as of Spring Framework 6.0 in favor of {@link #method(HttpMethod, String, Object...)}
221-
*/
222-
@Deprecated(since = "6.0")
223-
public static BodyBuilder method(String httpMethod, String uri, @Nullable Object... vars) {
224-
Assert.hasText(httpMethod, "HTTP method is required.");
225-
return new DefaultBodyBuilder(HttpMethod.valueOf(httpMethod), toUri(uri, vars));
226-
}
227-
228212
private static URI toUri(String uri, @Nullable Object[] vars) {
229213
return UriComponentsBuilder.fromUriString(uri).buildAndExpand(vars).encode().toUri();
230214
}
@@ -295,14 +279,6 @@ public interface BaseBuilder<B extends BaseBuilder<B>> {
295279
*/
296280
B header(String headerName, String... headerValues);
297281

298-
/**
299-
* Add the given header values.
300-
* @param headers the header values
301-
* @deprecated Use {@link #headers(HttpHeaders)}
302-
*/
303-
@Deprecated
304-
B headers(MultiValueMap<String, String> headers);
305-
306282
/**
307283
* Add the given header values.
308284
* @param headers the header values
@@ -491,13 +467,6 @@ public BodyBuilder header(String headerName, String... headerValues) {
491467
return this;
492468
}
493469

494-
@Override
495-
@Deprecated
496-
public BodyBuilder headers(MultiValueMap<String, String> headers) {
497-
this.headers.putAll(headers);
498-
return this;
499-
}
500-
501470
@Override
502471
public BodyBuilder headers(HttpHeaders headers) {
503472
this.headers.putAll(headers);

spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java

-6
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,6 @@ public RequestHeadersSpec<?> body(BodyInserter<?, ? super ClientHttpRequest> ins
347347
return this;
348348
}
349349

350-
@Override
351-
@Deprecated
352-
public RequestHeadersSpec<?> syncBody(Object body) {
353-
return bodyValue(body);
354-
}
355-
356350
@Override
357351
public ResponseSpec exchange() {
358352
ClientRequest request = (this.inserter != null ?

spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -246,16 +246,6 @@ public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) {
246246
return this;
247247
}
248248

249-
@Override
250-
@Deprecated
251-
public WebTestClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer) {
252-
if (this.strategiesConfigurers == null) {
253-
this.strategiesConfigurers = new ArrayList<>(4);
254-
}
255-
this.strategiesConfigurers.add(configurer);
256-
return this;
257-
}
258-
259249
@Override
260250
public WebTestClient.Builder apply(WebTestClientConfigurer configurer) {
261251
configurer.afterConfigurerAdded(this, this.httpHandlerBuilder, this.connector);

spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java

-19
Original file line numberDiff line numberDiff line change
@@ -490,16 +490,6 @@ interface Builder {
490490
*/
491491
Builder exchangeStrategies(ExchangeStrategies strategies);
492492

493-
/**
494-
* Customize the strategies configured via
495-
* {@link #exchangeStrategies(ExchangeStrategies)}. This method is
496-
* designed for use in scenarios where multiple parties wish to update
497-
* the {@code ExchangeStrategies}.
498-
* @deprecated as of 5.1.13 in favor of {@link #codecs(Consumer)}
499-
*/
500-
@Deprecated
501-
Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer);
502-
503493
/**
504494
* Max amount of time to wait for responses.
505495
* <p>By default 5 seconds.
@@ -771,15 +761,6 @@ <T, S extends Publisher<T>> RequestHeadersSpec<?> body(
771761
* @see org.springframework.web.reactive.function.BodyInserters
772762
*/
773763
RequestHeadersSpec<?> body(BodyInserter<?, ? super ClientHttpRequest> inserter);
774-
775-
/**
776-
* Shortcut for {@link #body(BodyInserter)} with a
777-
* {@linkplain BodyInserters#fromValue value inserter}.
778-
* As of 5.2 this method delegates to {@link #bodyValue(Object)}.
779-
* @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)}
780-
*/
781-
@Deprecated
782-
RequestHeadersSpec<?> syncBody(Object body);
783764
}
784765

785766

spring-test/src/main/java/org/springframework/test/web/servlet/ResultMatcher.java

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,21 +57,4 @@ public interface ResultMatcher {
5757
*/
5858
void match(MvcResult result) throws Exception;
5959

60-
61-
/**
62-
* Static method for matching with an array of result matchers.
63-
* @param matchers the matchers
64-
* @since 5.1
65-
* @deprecated as of Spring Framework 5.3.10, in favor of
66-
* {@link ResultActions#andExpectAll(ResultMatcher...)}
67-
*/
68-
@Deprecated
69-
static ResultMatcher matchAll(ResultMatcher... matchers) {
70-
return result -> {
71-
for (ResultMatcher matcher : matchers) {
72-
matcher.match(result);
73-
}
74-
};
75-
}
76-
7760
}

spring-test/src/main/java/org/springframework/test/web/servlet/result/ContentResultMatchers.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java

-10
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,6 @@ public ResultMatcher isProcessing() {
146146
return matcher(HttpStatus.PROCESSING);
147147
}
148148

149-
/**
150-
* Assert the response status code is {@code HttpStatus.CHECKPOINT} (103).
151-
* @see #isEarlyHints()
152-
* @deprecated in favor of {@link #isEarlyHints()}
153-
*/
154-
@Deprecated(since = "6.0.5")
155-
public ResultMatcher isCheckpoint() {
156-
return isEarlyHints();
157-
}
158-
159149
/**
160150
* Assert the response status code is {@code HttpStatus.EARLY_HINTS} (103).
161151
* @since 6.0.5

spring-test/src/main/kotlin/org/springframework/test/web/servlet/result/StatusResultMatchersDsl.kt

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -114,15 +114,6 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
114114
actions.andExpect(matchers.isProcessing())
115115
}
116116

117-
/**
118-
* @see isEarlyHints
119-
*/
120-
@Deprecated("use isEarlyHints() instead", replaceWith= ReplaceWith("isEarlyHints()"))
121-
fun isCheckpoint() {
122-
@Suppress("DEPRECATION")
123-
actions.andExpect(matchers.isCheckpoint())
124-
}
125-
126117
/**
127118
* @see StatusResultMatchers.isEarlyHints
128119
* @since 6.0.5

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.mock.http.server.reactive;
1818

19+
import java.net.URI;
1920
import java.util.Arrays;
2021
import java.util.stream.Stream;
2122

@@ -27,7 +28,6 @@
2728

2829
import org.springframework.http.HttpCookie;
2930
import org.springframework.http.HttpHeaders;
30-
import org.springframework.http.HttpMethod;
3131
import org.springframework.web.util.UriComponentsBuilder;
3232

3333
import static org.assertj.core.api.Assertions.assertThat;
@@ -74,15 +74,12 @@ void httpMethodNotNullOrEmpty(ThrowingCallable callable) {
7474
.withMessageContaining("HTTP method is required.");
7575
}
7676

77-
@SuppressWarnings("deprecation")
7877
static Stream<Named<ThrowingCallable>> httpMethodNotNullOrEmpty() {
7978
String uriTemplate = "/foo bar?a=b";
79+
URI uri = UriComponentsBuilder.fromUriString(uriTemplate).build().toUri();
8080
return Stream.of(
81-
named("null HttpMethod, URI", () -> MockServerHttpRequest.method(null, UriComponentsBuilder.fromUriString(uriTemplate).build("")).build()),
82-
named("null HttpMethod, uriTemplate", () -> MockServerHttpRequest.method((HttpMethod) null, uriTemplate).build()),
83-
named("null String, uriTemplate", () -> MockServerHttpRequest.method((String) null, uriTemplate).build()),
84-
named("empty String, uriTemplate", () -> MockServerHttpRequest.method("", uriTemplate).build()),
85-
named("blank String, uriTemplate", () -> MockServerHttpRequest.method(" ", uriTemplate).build())
81+
named("null HttpMethod, URI", () -> MockServerHttpRequest.method(null, uri).build()),
82+
named("null HttpMethod, uriTemplate", () -> MockServerHttpRequest.method(null, uriTemplate).build())
8683
);
8784
}
8885

0 commit comments

Comments
 (0)