Add static factory/accessor methods to LookupPath

Issue: SPR-15397
This commit is contained in:
Rossen Stoyanchev
2017-06-02 15:15:42 -04:00
parent a7020e419a
commit d2685dfe67
12 changed files with 64 additions and 70 deletions

View File

@@ -41,7 +41,7 @@ public class UrlBasedCorsConfigurationSourceTests {
@Test
public void empty() {
ServerWebExchange exchange = MockServerHttpRequest.get("/bar/test.html").toExchange();
initLookupPath(exchange);
LookupPath.getOrCreate(exchange, new HttpRequestPathHelper());
assertNull(this.configSource.getCorsConfiguration(exchange));
}
@@ -51,11 +51,11 @@ public class UrlBasedCorsConfigurationSourceTests {
this.configSource.registerCorsConfiguration("/bar/**", config);
ServerWebExchange exchange = MockServerHttpRequest.get("/foo/test.html").toExchange();
initLookupPath(exchange);
LookupPath.getOrCreate(exchange, new HttpRequestPathHelper());
assertNull(this.configSource.getCorsConfiguration(exchange));
exchange = MockServerHttpRequest.get("/bar/test.html").toExchange();
initLookupPath(exchange);
LookupPath.getOrCreate(exchange, new HttpRequestPathHelper());
assertEquals(config, this.configSource.getCorsConfiguration(exchange));
}
@@ -64,9 +64,4 @@ public class UrlBasedCorsConfigurationSourceTests {
this.configSource.getCorsConfigurations().put("/**", new CorsConfiguration());
}
private void initLookupPath(ServerWebExchange exchange) {
exchange.getAttributes().put(LookupPath.LOOKUP_PATH_ATTRIBUTE,
new HttpRequestPathHelper().getLookupPathForRequest(exchange));
}
}