Search in sources :

Example 16 with RibbonServer

use of org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.RibbonServer in project spring-cloud-netflix by spring-cloud.

the class RibbonLoadBalancerClientTests method testExecuteException.

@Test
public void testExecuteException() {
    final RibbonServer ribbonServer = getRibbonServer();
    RibbonLoadBalancerClient client = getRibbonLoadBalancerClient(ribbonServer);
    try {
        client.execute(ribbonServer.getServiceId(), instance -> {
            assertServiceInstance(ribbonServer, instance);
            throw new RuntimeException();
        });
        fail("Should have thrown exception");
    } catch (Exception ex) {
        assertNotNull(ex);
    }
    verifyServerStats();
}
Also used : RibbonServer(org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.RibbonServer) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

RibbonServer (org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.RibbonServer)16 Test (org.junit.Test)13 IClientConfig (com.netflix.client.config.IClientConfig)10 ServiceInstance (org.springframework.cloud.client.ServiceInstance)8 HttpRequest (org.springframework.http.HttpRequest)7 LoadBalancedRetryPolicy (org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy)6 DefaultLoadBalancerRetryHandler (com.netflix.client.DefaultLoadBalancerRetryHandler)5 IOException (java.io.IOException)5 URI (java.net.URI)5 LoadBalancedRetryContext (org.springframework.cloud.client.loadbalancer.LoadBalancedRetryContext)5 Server (com.netflix.loadbalancer.Server)4 URL (java.net.URL)4 ServerStats (com.netflix.loadbalancer.ServerStats)2 DefaultUriBuilderFactory (org.springframework.web.util.DefaultUriBuilderFactory)2 CommonClientConfigKey (com.netflix.client.config.CommonClientConfigKey)1 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)1 LoadBalancerStats (com.netflix.loadbalancer.LoadBalancerStats)1 SocketException (java.net.SocketException)1 Collections (java.util.Collections)1 Map (java.util.Map)1