Skip to content

Commit

Permalink
Remove deprecated web APIs in spring-test
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoyanchev committed Jan 16, 2025
1 parent 2ed281f commit 31578c4
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,6 @@ public static BodyBuilder method(HttpMethod method, String uri, @Nullable Object
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();
}
Expand Down Expand Up @@ -295,14 +279,6 @@ public interface BaseBuilder<B extends BaseBuilder<B>> {
*/
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
Expand Down Expand Up @@ -491,13 +467,6 @@ public BodyBuilder header(String headerName, String... headerValues) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,6 @@ public RequestHeadersSpec<?> body(BodyInserter<?, ? super ClientHttpRequest> ins
return this;
}

@Override
@Deprecated
public RequestHeadersSpec<?> syncBody(Object body) {
return bodyValue(body);
}

@Override
public ResponseSpec exchange() {
ClientRequest request = (this.inserter != null ?
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -246,16 +246,6 @@ public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,6 @@ interface Builder {
*/
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.
Expand Down Expand Up @@ -771,15 +761,6 @@ <T, S extends Publisher<T>> RequestHeadersSpec<?> body(
* @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);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
}
};
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,6 @@ public ResultMatcher isProcessing() {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,6 +16,7 @@

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

import java.net.URI;
import java.util.Arrays;
import java.util.stream.Stream;

Expand All @@ -27,7 +28,6 @@

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;
Expand Down Expand Up @@ -74,15 +74,12 @@ void httpMethodNotNullOrEmpty(ThrowingCallable callable) {
.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())
);
}

Expand Down

0 comments on commit 31578c4

Please sign in to comment.