Remove deprecated web APIs in spring-test

See gh-33809
This commit is contained in:
rstoyanchev 2025-01-16 15:44:56 +00:00
parent 2ed281f6a8
commit 31578c4170
9 changed files with 9 additions and 114 deletions

View File

@ -209,22 +209,6 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
return method(method, toUri(uri, vars));
}
/**
* Create a builder with a raw HTTP method value that is outside the
* range of {@link HttpMethod} enum values.
* @param httpMethod the HTTP methodValue value
* @param uri the URI template for target the URL
* @param vars variables to expand into the template
* @return the created builder
* @since 5.2.7
* @deprecated as of Spring Framework 6.0 in favor of {@link #method(HttpMethod, String, Object...)}
*/
@Deprecated(since = "6.0")
public static BodyBuilder method(String httpMethod, String uri, @Nullable Object... vars) {
Assert.hasText(httpMethod, "HTTP method is required.");
return new DefaultBodyBuilder(HttpMethod.valueOf(httpMethod), toUri(uri, vars));
}
private static URI toUri(String uri, @Nullable Object[] vars) {
return UriComponentsBuilder.fromUriString(uri).buildAndExpand(vars).encode().toUri();
}
@ -295,14 +279,6 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
*/
B header(String headerName, String... headerValues);
/**
* Add the given header values.
* @param headers the header values
* @deprecated Use {@link #headers(HttpHeaders)}
*/
@Deprecated
B headers(MultiValueMap<String, String> headers);
/**
* Add the given header values.
* @param headers the header values
@ -491,13 +467,6 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
return this;
}
@Override
@Deprecated
public BodyBuilder headers(MultiValueMap<String, String> headers) {
this.headers.putAll(headers);
return this;
}
@Override
public BodyBuilder headers(HttpHeaders headers) {
this.headers.putAll(headers);

View File

@ -347,12 +347,6 @@ class DefaultWebTestClient implements WebTestClient {
return this;
}
@Override
@Deprecated
public RequestHeadersSpec<?> syncBody(Object body) {
return bodyValue(body);
}
@Override
public ResponseSpec exchange() {
ClientRequest request = (this.inserter != null ?

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -246,16 +246,6 @@ class DefaultWebTestClientBuilder implements WebTestClient.Builder {
return this;
}
@Override
@Deprecated
public WebTestClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer) {
if (this.strategiesConfigurers == null) {
this.strategiesConfigurers = new ArrayList<>(4);
}
this.strategiesConfigurers.add(configurer);
return this;
}
@Override
public WebTestClient.Builder apply(WebTestClientConfigurer configurer) {
configurer.afterConfigurerAdded(this, this.httpHandlerBuilder, this.connector);

View File

@ -490,16 +490,6 @@ public interface WebTestClient {
*/
Builder exchangeStrategies(ExchangeStrategies strategies);
/**
* Customize the strategies configured via
* {@link #exchangeStrategies(ExchangeStrategies)}. This method is
* designed for use in scenarios where multiple parties wish to update
* the {@code ExchangeStrategies}.
* @deprecated as of 5.1.13 in favor of {@link #codecs(Consumer)}
*/
@Deprecated
Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer);
/**
* Max amount of time to wait for responses.
* <p>By default 5 seconds.
@ -771,15 +761,6 @@ public interface WebTestClient {
* @see org.springframework.web.reactive.function.BodyInserters
*/
RequestHeadersSpec<?> body(BodyInserter<?, ? super ClientHttpRequest> inserter);
/**
* Shortcut for {@link #body(BodyInserter)} with a
* {@linkplain BodyInserters#fromValue value inserter}.
* As of 5.2 this method delegates to {@link #bodyValue(Object)}.
* @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)}
*/
@Deprecated
RequestHeadersSpec<?> syncBody(Object body);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2025 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.
@ -57,21 +57,4 @@ public interface ResultMatcher {
*/
void match(MvcResult result) throws Exception;
/**
* Static method for matching with an array of result matchers.
* @param matchers the matchers
* @since 5.1
* @deprecated as of Spring Framework 5.3.10, in favor of
* {@link ResultActions#andExpectAll(ResultMatcher...)}
*/
@Deprecated
static ResultMatcher matchAll(ResultMatcher... matchers) {
return result -> {
for (ResultMatcher matcher : matchers) {
matcher.match(result);
}
};
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.

View File

@ -146,16 +146,6 @@ public class StatusResultMatchers {
return matcher(HttpStatus.PROCESSING);
}
/**
* Assert the response status code is {@code HttpStatus.CHECKPOINT} (103).
* @see #isEarlyHints()
* @deprecated in favor of {@link #isEarlyHints()}
*/
@Deprecated(since = "6.0.5")
public ResultMatcher isCheckpoint() {
return isEarlyHints();
}
/**
* Assert the response status code is {@code HttpStatus.EARLY_HINTS} (103).
* @since 6.0.5

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -114,15 +114,6 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
actions.andExpect(matchers.isProcessing())
}
/**
* @see isEarlyHints
*/
@Deprecated("use isEarlyHints() instead", replaceWith= ReplaceWith("isEarlyHints()"))
fun isCheckpoint() {
@Suppress("DEPRECATION")
actions.andExpect(matchers.isCheckpoint())
}
/**
* @see StatusResultMatchers.isEarlyHints
* @since 6.0.5

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -16,6 +16,7 @@
package org.springframework.mock.http.server.reactive;
import java.net.URI;
import java.util.Arrays;
import java.util.stream.Stream;
@ -27,7 +28,6 @@ import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.http.HttpCookie;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.util.UriComponentsBuilder;
import static org.assertj.core.api.Assertions.assertThat;
@ -74,15 +74,12 @@ class MockServerHttpRequestTests {
.withMessageContaining("HTTP method is required.");
}
@SuppressWarnings("deprecation")
static Stream<Named<ThrowingCallable>> httpMethodNotNullOrEmpty() {
String uriTemplate = "/foo bar?a=b";
URI uri = UriComponentsBuilder.fromUriString(uriTemplate).build().toUri();
return Stream.of(
named("null HttpMethod, URI", () -> MockServerHttpRequest.method(null, UriComponentsBuilder.fromUriString(uriTemplate).build("")).build()),
named("null HttpMethod, uriTemplate", () -> MockServerHttpRequest.method((HttpMethod) null, uriTemplate).build()),
named("null String, uriTemplate", () -> MockServerHttpRequest.method((String) null, uriTemplate).build()),
named("empty String, uriTemplate", () -> MockServerHttpRequest.method("", uriTemplate).build()),
named("blank String, uriTemplate", () -> MockServerHttpRequest.method(" ", uriTemplate).build())
named("null HttpMethod, URI", () -> MockServerHttpRequest.method(null, uri).build()),
named("null HttpMethod, uriTemplate", () -> MockServerHttpRequest.method(null, uriTemplate).build())
);
}