mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Remove APIs marked as deprecated for removal
Closes gh-33809
This commit is contained in:
+2
-3
@@ -114,6 +114,7 @@ import org.springframework.web.servlet.resource.CssLinkResourceTransformer;
|
||||
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
|
||||
import org.springframework.web.servlet.resource.EncodedResourceResolver;
|
||||
import org.springframework.web.servlet.resource.FixedVersionStrategy;
|
||||
import org.springframework.web.servlet.resource.LiteWebJarsResourceResolver;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
import org.springframework.web.servlet.resource.PathResourceResolver;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
@@ -122,7 +123,6 @@ import org.springframework.web.servlet.resource.ResourceTransformer;
|
||||
import org.springframework.web.servlet.resource.ResourceUrlProvider;
|
||||
import org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor;
|
||||
import org.springframework.web.servlet.resource.VersionResourceResolver;
|
||||
import org.springframework.web.servlet.resource.WebJarsResourceResolver;
|
||||
import org.springframework.web.servlet.support.SessionFlashMapManager;
|
||||
import org.springframework.web.servlet.theme.CookieThemeResolver;
|
||||
import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
|
||||
@@ -439,7 +439,6 @@ public class MvcNamespaceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void testResourcesWithResolversTransformers() {
|
||||
loadBeanDefinitions("mvc-config-resources-chain.xml");
|
||||
|
||||
@@ -456,7 +455,7 @@ public class MvcNamespaceTests {
|
||||
assertThat(resolvers).hasSize(4);
|
||||
assertThat(resolvers).element(0).isInstanceOf(CachingResourceResolver.class);
|
||||
assertThat(resolvers).element(1).isInstanceOf(VersionResourceResolver.class);
|
||||
assertThat(resolvers).element(2).isInstanceOf(WebJarsResourceResolver.class);
|
||||
assertThat(resolvers).element(2).isInstanceOf(LiteWebJarsResourceResolver.class);
|
||||
assertThat(resolvers).element(3).isInstanceOf(PathResourceResolver.class);
|
||||
|
||||
CachingResourceResolver cachingResolver = (CachingResourceResolver) resolvers.get(0);
|
||||
|
||||
+1
-2
@@ -48,6 +48,7 @@ class DefaultEntityResponseBuilderTests {
|
||||
|
||||
static final ServerResponse.Context EMPTY_CONTEXT = Collections::emptyList;
|
||||
|
||||
|
||||
@Test
|
||||
void fromObject() {
|
||||
String body = "foo";
|
||||
@@ -66,14 +67,12 @@ class DefaultEntityResponseBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void status() {
|
||||
String body = "foo";
|
||||
EntityResponse<String> result =
|
||||
EntityResponse.fromObject(body).status(HttpStatus.CREATED).build();
|
||||
|
||||
assertThat(result.statusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
assertThat(result.rawStatusCode()).isEqualTo(201);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-3
@@ -54,12 +54,11 @@ class DefaultServerResponseBuilderTests {
|
||||
|
||||
static final ServerResponse.Context EMPTY_CONTEXT = Collections::emptyList;
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void status() {
|
||||
ServerResponse response = ServerResponse.status(HttpStatus.CREATED).build();
|
||||
assertThat(response.statusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
assertThat(response.rawStatusCode()).isEqualTo(201);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,7 +74,6 @@ class DefaultServerResponseBuilderTests {
|
||||
assertThat(result.cookies().getFirst("foo")).isEqualTo(cookie);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void ok() {
|
||||
ServerResponse response = ServerResponse.ok().build();
|
||||
|
||||
-26
@@ -63,14 +63,10 @@ class DeferredResultReturnValueHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public void supportsReturnType() throws Exception {
|
||||
assertThat(this.handler.supportsReturnType(
|
||||
on(TestController.class).resolveReturnType(DeferredResult.class, String.class))).isTrue();
|
||||
|
||||
assertThat(this.handler.supportsReturnType(
|
||||
on(TestController.class).resolveReturnType(org.springframework.util.concurrent.ListenableFuture.class, String.class))).isTrue();
|
||||
|
||||
assertThat(this.handler.supportsReturnType(
|
||||
on(TestController.class).resolveReturnType(CompletableFuture.class, String.class))).isTrue();
|
||||
}
|
||||
@@ -87,15 +83,6 @@ class DeferredResultReturnValueHandlerTests {
|
||||
testHandle(result, DeferredResult.class, () -> result.setErrorResult(ex), ex);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public void listenableFuture() throws Exception {
|
||||
org.springframework.util.concurrent.SettableListenableFuture<String> future =
|
||||
new org.springframework.util.concurrent.SettableListenableFuture<>();
|
||||
testHandle(future, org.springframework.util.concurrent.ListenableFuture.class,
|
||||
() -> future.set("foo"), "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void completableFuture() throws Exception {
|
||||
CompletableFuture<String> future = new CompletableFuture<>();
|
||||
@@ -108,16 +95,6 @@ class DeferredResultReturnValueHandlerTests {
|
||||
testHandle(result, DeferredResult.class, () -> result.setResult("foo"), "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public void listenableFutureWithError() throws Exception {
|
||||
org.springframework.util.concurrent.SettableListenableFuture<String> future =
|
||||
new org.springframework.util.concurrent.SettableListenableFuture<>();
|
||||
IllegalStateException ex = new IllegalStateException();
|
||||
testHandle(future, org.springframework.util.concurrent.ListenableFuture.class,
|
||||
() -> future.setException(ex), ex);
|
||||
}
|
||||
|
||||
@Test
|
||||
void completableFutureWithError() throws Exception {
|
||||
CompletableFuture<String> future = new CompletableFuture<>();
|
||||
@@ -150,9 +127,6 @@ class DeferredResultReturnValueHandlerTests {
|
||||
|
||||
DeferredResult<String> handleDeferredResult() { return null; }
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
org.springframework.util.concurrent.ListenableFuture<String> handleListenableFuture() { return null; }
|
||||
|
||||
CompletableFuture<String> handleCompletableFuture() { return null; }
|
||||
}
|
||||
|
||||
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link WebJarsResourceResolver}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class WebJarsResourceResolverTests {
|
||||
|
||||
private List<Resource> locations = List.of(new ClassPathResource("/META-INF/resources/webjars"));
|
||||
|
||||
// for this to work, an actual WebJar must be on the test classpath
|
||||
private WebJarsResourceResolver resolver = new WebJarsResourceResolver();
|
||||
|
||||
private ResourceResolverChain chain = mock();
|
||||
|
||||
private HttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
|
||||
@Test
|
||||
void resolveUrlExisting() {
|
||||
String file = "/foo/2.3/foo.txt";
|
||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(file);
|
||||
|
||||
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isEqualTo(file);
|
||||
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveUrlExistingNotInJarFile() {
|
||||
String file = "foo/foo.txt";
|
||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
||||
|
||||
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isNull();
|
||||
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
|
||||
verify(this.chain, never()).resolveUrlPath("foo/2.3/foo.txt", this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveUrlWebJarResource() {
|
||||
String file = "underscorejs/underscore.js";
|
||||
String expected = "underscorejs/1.8.3/underscore.js";
|
||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
||||
given(this.chain.resolveUrlPath(expected, this.locations)).willReturn(expected);
|
||||
|
||||
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
|
||||
verify(this.chain, times(1)).resolveUrlPath(expected, this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveUrlWebJarResourceNotFound() {
|
||||
String file = "something/something.js";
|
||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
||||
|
||||
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isNull();
|
||||
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
|
||||
verify(this.chain, never()).resolveUrlPath(null, this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveResourceExisting() {
|
||||
Resource expected = mock();
|
||||
String file = "foo/2.3/foo.txt";
|
||||
given(this.chain.resolveResource(this.request, file, this.locations)).willReturn(expected);
|
||||
|
||||
Resource actual = this.resolver.resolveResource(this.request, file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
verify(this.chain, times(1)).resolveResource(this.request, file, this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveResourceNotFound() {
|
||||
String file = "something/something.js";
|
||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
||||
|
||||
Resource actual = this.resolver.resolveResource(this.request, file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isNull();
|
||||
verify(this.chain, times(1)).resolveResource(this.request, file, this.locations);
|
||||
verify(this.chain, never()).resolveResource(this.request, null, this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveResourceWebJar() {
|
||||
Resource expected = mock();
|
||||
String file = "underscorejs/underscore.js";
|
||||
String expectedPath = "underscorejs/1.8.3/underscore.js";
|
||||
given(this.chain.resolveResource(this.request, expectedPath, this.locations)).willReturn(expected);
|
||||
|
||||
Resource actual = this.resolver.resolveResource(this.request, file, this.locations, this.chain);
|
||||
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
verify(this.chain, times(1)).resolveResource(this.request, file, this.locations);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user