mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Merge branch '7.0.x'
This commit is contained in:
+2
-1
@@ -90,7 +90,8 @@ public class LiteWebJarsResourceResolver extends AbstractResourceResolver {
|
||||
.switchIfEmpty(Mono.defer(() -> {
|
||||
String webJarResourcePath = findWebJarResourcePath(resourceUrlPath);
|
||||
if (webJarResourcePath != null) {
|
||||
return chain.resolveUrlPath(webJarResourcePath, locations);
|
||||
Mono<String> fallback = (webJarResourcePath.endsWith("/")) ? Mono.just(webJarResourcePath) : Mono.empty();
|
||||
return chain.resolveUrlPath(webJarResourcePath, locations).switchIfEmpty(fallback);
|
||||
}
|
||||
else {
|
||||
return Mono.empty();
|
||||
|
||||
+22
-6
@@ -29,6 +29,8 @@ import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRe
|
||||
import org.springframework.web.testfixture.server.MockServerWebExchange;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -80,8 +82,8 @@ class LiteWebJarsResourceResolverTests {
|
||||
|
||||
@Test
|
||||
void resolveUrlWebJarResource() {
|
||||
String file = "underscorejs/underscore.js";
|
||||
String expected = "underscorejs/1.8.3/underscore.js";
|
||||
String file = "momentjs/momentjs.js";
|
||||
String expected = "momentjs/2.29.4/momentjs.js";
|
||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(Mono.empty());
|
||||
given(this.chain.resolveUrlPath(expected, this.locations)).willReturn(Mono.just(expected));
|
||||
|
||||
@@ -92,10 +94,24 @@ class LiteWebJarsResourceResolverTests {
|
||||
verify(this.chain, times(1)).resolveUrlPath(expected, this.locations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveUrlWebJarDirectory() {
|
||||
String folder = "momentjs/locale/";
|
||||
String expected = "momentjs/2.29.4/locale/";
|
||||
given(this.chain.resolveUrlPath(folder, this.locations)).willReturn(Mono.empty());
|
||||
given(this.chain.resolveUrlPath(expected, this.locations)).willReturn(Mono.empty());
|
||||
|
||||
String actual = this.resolver.resolveUrlPath(folder, this.locations, this.chain).block(TIMEOUT);
|
||||
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
verify(this.chain, times(1)).resolveUrlPath(folder, 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(Mono.empty());
|
||||
String file = "momentjs/locale/unknown.js";
|
||||
given(this.chain.resolveUrlPath(anyString(), eq(this.locations))).willReturn(Mono.empty());
|
||||
|
||||
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain).block(TIMEOUT);
|
||||
|
||||
@@ -134,11 +150,11 @@ class LiteWebJarsResourceResolverTests {
|
||||
|
||||
@Test
|
||||
void resolveResourceWebJar() {
|
||||
String file = "underscorejs/underscore.js";
|
||||
String file = "momentjs/momentjs.js";
|
||||
given(this.chain.resolveResource(this.exchange, file, this.locations)).willReturn(Mono.empty());
|
||||
|
||||
Resource expected = mock();
|
||||
String expectedPath = "underscorejs/1.8.3/underscore.js";
|
||||
String expectedPath = "momentjs/2.29.4/momentjs.js";
|
||||
given(this.chain.resolveResource(this.exchange, expectedPath, this.locations))
|
||||
.willReturn(Mono.just(expected));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user