File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 3434import org .springframework .web .bind .annotation .GetMapping ;
3535import org .springframework .web .bind .annotation .RequestParam ;
3636import org .springframework .web .bind .annotation .RestController ;
37+ import org .springframework .web .util .DefaultUriBuilderFactory ;
3738
3839import static org .springframework .boot .test .context .SpringBootTest .WebEnvironment .RANDOM_PORT ;
3940
@@ -56,8 +57,10 @@ public static void afterClass() {
5657
5758 @ Test
5859 public void requestsToManagementPortReturn404 () {
60+ String baseUrl = "http://localhost:" + managementPort ;
5961 testClient .mutate ()
60- .baseUrl ("http://localhost:" + managementPort )
62+ .uriBuilderFactory (new DefaultUriBuilderFactory (baseUrl ))
63+ .baseUrl (baseUrl )
6164 .build ()
6265 .get ()
6366 .uri ("/get" )
@@ -69,8 +72,10 @@ public void requestsToManagementPortReturn404() {
6972 @ Test
7073 public void requestsToManagementPortAndHostHeaderReturn404 () {
7174 String host = "example.com:8888" ;
75+ String baseUrl = "http://localhost:" + managementPort ;
7276 testClient .mutate ()
73- .baseUrl ("http://localhost:" + managementPort )
77+ .uriBuilderFactory (new DefaultUriBuilderFactory (baseUrl ))
78+ .baseUrl (baseUrl )
7479 .build ()
7580 .get ()
7681 .uri ("/get" )
Original file line number Diff line number Diff line change 4242import org .springframework .test .web .reactive .server .WebTestClient ;
4343import org .springframework .web .reactive .function .client .WebClient ;
4444import org .springframework .web .server .ServerWebExchange ;
45+ import org .springframework .web .util .DefaultUriBuilderFactory ;
46+ import org .springframework .web .util .UriComponentsBuilder ;
4547
4648import static org .springframework .cloud .gateway .support .ServerWebExchangeUtils .GATEWAY_HANDLER_MAPPER_ATTR ;
4749import static org .springframework .cloud .gateway .support .ServerWebExchangeUtils .GATEWAY_ROUTE_ATTR ;
@@ -76,7 +78,12 @@ public void setup() throws Exception {
7678 protected void setup (ClientHttpConnector httpConnector , String baseUri ) {
7779 this .baseUri = baseUri ;
7880 this .webClient = WebClient .builder ().clientConnector (httpConnector ).baseUrl (this .baseUri ).build ();
79- this .testClient = WebTestClient .bindToServer (httpConnector ).baseUrl (this .baseUri ).build ();
81+ DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory (this .baseUri );
82+ uriBuilderFactory .setParserType (UriComponentsBuilder .ParserType .WHAT_WG );
83+ this .testClient = WebTestClient .bindToServer (httpConnector )
84+ .uriBuilderFactory (uriBuilderFactory )
85+ .baseUrl (this .baseUri )
86+ .build ();
8087 }
8188
8289 @ Configuration (proxyBeanMethods = false )
You can’t perform that action at this time.
0 commit comments