From 4e25e2eb81919891cd810b9fa1c800f7c4cbe609 Mon Sep 17 00:00:00 2001 From: Ryan Baxter Date: Thu, 8 Jun 2017 15:34:57 -0400 Subject: [PATCH] Revert "Trying a plain RestTemplate in an attempt to fix intermittent test failures." This reverts commit f5524263046b19b3dd1cab7ca5d0befb66150dac. --- .../zuul/RetryableZuulProxyApplicationTests.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/RetryableZuulProxyApplicationTests.java b/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/RetryableZuulProxyApplicationTests.java index 538a402b..ff1bdc8f 100644 --- a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/RetryableZuulProxyApplicationTests.java +++ b/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/RetryableZuulProxyApplicationTests.java @@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator; @@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.ServerList; @@ -48,7 +47,8 @@ import com.netflix.zuul.context.RequestContext; @DirtiesContext public class RetryableZuulProxyApplicationTests { - private RestTemplate testRestTemplate; + @Autowired + private TestRestTemplate testRestTemplate; @Autowired @SuppressWarnings("unused") @@ -58,14 +58,10 @@ public class RetryableZuulProxyApplicationTests { @SuppressWarnings("unused") private RoutesEndpoint endpoint; - @LocalServerPort - private int port; - @Before public void setTestRequestContext() { RequestContext context = new RequestContext(); RequestContext.testSetCurrentContext(context); - testRestTemplate = new RestTemplateBuilder().build(); } @Test @@ -75,7 +71,7 @@ public class RetryableZuulProxyApplicationTests { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); ResponseEntity result = testRestTemplate.exchange( - "http://localhost:" + port + "/simple", HttpMethod.POST, + "/simple", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("Posted! {foo=[bar]}", result.getBody());