Search in sources :

Example 1 with LoadBalancerRequest

use of org.springframework.cloud.client.loadbalancer.LoadBalancerRequest in project spring-cloud-netflix by spring-cloud.

the class RibbonLoadBalancerClientTests method testExecute.

@Test
public void testExecute() throws IOException {
    final RibbonServer server = getRibbonServer();
    RibbonLoadBalancerClient client = getRibbonLoadBalancerClient(server);
    final String returnVal = "myval";
    Object actualReturn = client.execute(server.getServiceId(), (LoadBalancerRequest<Object>) instance -> {
        assertServiceInstance(server, instance);
        return returnVal;
    });
    verifyServerStats();
    assertEquals("retVal was wrong", returnVal, actualReturn);
}
Also used : LoadBalancerRequest(org.springframework.cloud.client.loadbalancer.LoadBalancerRequest) ServerStats(com.netflix.loadbalancer.ServerStats) URL(java.net.URL) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RibbonServer(org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.RibbonServer) BaseLoadBalancer(com.netflix.loadbalancer.BaseLoadBalancer) Matchers.anyString(org.mockito.Matchers.anyString) MockitoAnnotations(org.mockito.MockitoAnnotations) BDDMockito.given(org.mockito.BDDMockito.given) Matchers.eq(org.mockito.Matchers.eq) Map(java.util.Map) Matchers.anyObject(org.mockito.Matchers.anyObject) DefaultUriBuilderFactory(org.springframework.web.util.DefaultUriBuilderFactory) Assert.fail(org.junit.Assert.fail) URI(java.net.URI) LoadBalancerStats(com.netflix.loadbalancer.LoadBalancerStats) Before(org.junit.Before) Server(com.netflix.loadbalancer.Server) Assert.assertNotNull(org.junit.Assert.assertNotNull) IClientConfig(com.netflix.client.config.IClientConfig) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Matchers.anyDouble(org.mockito.Matchers.anyDouble) Mockito.verify(org.mockito.Mockito.verify) CommonClientConfigKey(com.netflix.client.config.CommonClientConfigKey) Assert.assertNull(org.junit.Assert.assertNull) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) RibbonServer(org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.RibbonServer) Matchers.anyObject(org.mockito.Matchers.anyObject) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

CommonClientConfigKey (com.netflix.client.config.CommonClientConfigKey)1 IClientConfig (com.netflix.client.config.IClientConfig)1 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)1 LoadBalancerStats (com.netflix.loadbalancer.LoadBalancerStats)1 Server (com.netflix.loadbalancer.Server)1 ServerStats (com.netflix.loadbalancer.ServerStats)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URL (java.net.URL)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 Test (org.junit.Test)1 BDDMockito.given (org.mockito.BDDMockito.given)1 Matchers.anyDouble (org.mockito.Matchers.anyDouble)1