use of org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor in project spring-cloud-netflix by spring-cloud.
the class RibbonInterceptorTests method testIntercept.
@Test
public void testIntercept() throws Exception {
RibbonServer server = new RibbonServer("myservice", new Server("myhost", 8080));
LoadBalancerInterceptor interceptor = new LoadBalancerInterceptor(new MyClient(server));
given(this.request.getURI()).willReturn(new URL("http://myservice").toURI());
given(this.execution.execute(isA(HttpRequest.class), isA(byte[].class))).willReturn(this.response);
ArgumentCaptor<HttpRequestWrapper> argument = ArgumentCaptor.forClass(HttpRequestWrapper.class);
ClientHttpResponse response = interceptor.intercept(this.request, new byte[0], this.execution);
assertNotNull("response was null", response);
verify(this.execution).execute(argument.capture(), isA(byte[].class));
HttpRequestWrapper wrapper = argument.getValue();
assertEquals("wrong constructed uri", new URL("http://myhost:8080").toURI(), wrapper.getURI());
}
Aggregations