Polish use of LookupPath

This commit is contained in:
Rossen Stoyanchev
2017-06-02 14:46:34 -04:00
parent 90df7dd279
commit a7020e419a
11 changed files with 67 additions and 63 deletions

View File

@@ -41,7 +41,7 @@ public class UrlBasedCorsConfigurationSourceTests {
@Test
public void empty() {
ServerWebExchange exchange = MockServerHttpRequest.get("/bar/test.html").toExchange();
setLookupPathAttribute(exchange);
initLookupPath(exchange);
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();
setLookupPathAttribute(exchange);
initLookupPath(exchange);
assertNull(this.configSource.getCorsConfiguration(exchange));
exchange = MockServerHttpRequest.get("/bar/test.html").toExchange();
setLookupPathAttribute(exchange);
initLookupPath(exchange);
assertEquals(config, this.configSource.getCorsConfiguration(exchange));
}
@@ -64,10 +64,9 @@ public class UrlBasedCorsConfigurationSourceTests {
this.configSource.getCorsConfigurations().put("/**", new CorsConfiguration());
}
public void setLookupPathAttribute(ServerWebExchange exchange) {
HttpRequestPathHelper helper = new HttpRequestPathHelper();
private void initLookupPath(ServerWebExchange exchange) {
exchange.getAttributes().put(LookupPath.LOOKUP_PATH_ATTRIBUTE,
helper.getLookupPathForRequest(exchange));
new HttpRequestPathHelper().getLookupPathForRequest(exchange));
}
}