|
|
|
@ -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"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -26,6 +26,7 @@ import reactor.core.publisher.Mono; |
|
|
|
import reactor.test.StepVerifier; |
|
|
|
import reactor.test.StepVerifier; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
|
|
|
|
import org.springframework.core.io.FileSystemResource; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; |
|
|
|
import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; |
|
|
|
import org.springframework.web.testfixture.server.MockServerWebExchange; |
|
|
|
import org.springframework.web.testfixture.server.MockServerWebExchange; |
|
|
|
@ -39,8 +40,7 @@ class PathResourceLookupFunctionTests { |
|
|
|
void normal() throws Exception { |
|
|
|
void normal() throws Exception { |
|
|
|
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/"); |
|
|
|
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/"); |
|
|
|
|
|
|
|
|
|
|
|
PathResourceLookupFunction |
|
|
|
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); |
|
|
|
function = new PathResourceLookupFunction("/resources/**", location); |
|
|
|
|
|
|
|
MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://localhost/resources/response.txt").build(); |
|
|
|
MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://localhost/resources/response.txt").build(); |
|
|
|
ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList()); |
|
|
|
ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList()); |
|
|
|
Mono<Resource> result = function.apply(request); |
|
|
|
Mono<Resource> result = function.apply(request); |
|
|
|
@ -124,4 +124,17 @@ class PathResourceLookupFunctionTests { |
|
|
|
.verify(); |
|
|
|
.verify(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
@SuppressWarnings("removal") |
|
|
|
|
|
|
|
void withPathResource() { |
|
|
|
|
|
|
|
org.springframework.core.io.PathResource location = new org.springframework.core.io.PathResource("/static/"); |
|
|
|
|
|
|
|
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void withFileSystemResource() { |
|
|
|
|
|
|
|
FileSystemResource location = new FileSystemResource("/static/"); |
|
|
|
|
|
|
|
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|