From 707ba28a04188fd4773be3d742ccbb0792db6aaf Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 22 Apr 2015 12:14:49 +0200 Subject: [PATCH] Fix test broken by @LoadBalanced changes in s-c-netflix core --- .../java/demo/RibbonClientApplicationTests.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java b/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java index ef1f9c5..e15f098 100644 --- a/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java +++ b/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java @@ -12,8 +12,11 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor; +import org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -24,9 +27,12 @@ import org.springframework.web.client.RestTemplate; public class RibbonClientApplicationTests { @Autowired + @LoadBalanced private OAuth2RestTemplate oauth2RestTemplate; @Autowired + @Qualifier("loadBalancedRestTemplate") + @LoadBalanced private RestTemplate restTemplate; @Rule @@ -34,9 +40,9 @@ public class RibbonClientApplicationTests { @Test public void restTemplateHasLoadBalancer() { - // Just to prove that the interceptor is present... - assertThat(new ArrayList(restTemplate.getInterceptors()), - hasItem(instanceOf(LoadBalancerInterceptor.class))); + // Just to prove that the request factory changed... + assertThat(restTemplate.getRequestFactory(), + instanceOf(RibbonClientHttpRequestFactory.class)); } @Test @@ -47,7 +53,7 @@ public class RibbonClientApplicationTests { } @Test - //FIXME: why is this broken + // FIXME: why is this broken @Ignore public void useRestTemplate() throws Exception { // There's nowhere to get an access token so it should fail, but in a sensible way