Search in sources :

Example 66 with Server

use of com.netflix.loadbalancer.Server in project java-chassis by ServiceComb.

the class TestServerListCache method testCreateEndpointTransportString.

@Test
public void testCreateEndpointTransportString() {
    Server server = instance.createEndpoint(transport, new CacheEndpoint("stringAddress", null));
    Assert.assertNotNull(server);
}
Also used : Server(com.netflix.loadbalancer.Server) CacheEndpoint(io.servicecomb.serviceregistry.cache.CacheEndpoint) Test(org.junit.Test)

Example 67 with Server

use of com.netflix.loadbalancer.Server in project java-chassis by ServiceComb.

the class TestLoadBalancer method testMarkServerDownException.

@Test
public void testMarkServerDownException() {
    boolean status = true;
    List<Server> newServers = new ArrayList<Server>();
    Server server = Mockito.mock(Server.class);
    newServers.add(server);
    try {
        loadBalancer.markServerDown(server);
    } catch (Exception e) {
        status = false;
        Assert.assertEquals("Not implemented.", e.getMessage());
    }
    Assert.assertFalse(status);
}
Also used : Server(com.netflix.loadbalancer.Server) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 68 with Server

use of com.netflix.loadbalancer.Server in project java-chassis by ServiceComb.

the class TestLoadBalancer method testAddServerException.

@Test
public void testAddServerException() {
    boolean status = true;
    List<Server> newServers = new ArrayList<Server>();
    Server server = Mockito.mock(Server.class);
    newServers.add(server);
    try {
        loadBalancer.addServers(newServers);
    } catch (Exception e) {
        status = false;
        Assert.assertEquals("Not implemented.", e.getMessage());
    }
    Assert.assertFalse(status);
}
Also used : Server(com.netflix.loadbalancer.Server) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 69 with Server

use of com.netflix.loadbalancer.Server in project java-chassis by ServiceComb.

the class TestLoadBalancer method testServerListException.

@Test
public void testServerListException() {
    boolean status = true;
    List<Server> newServers = new ArrayList<Server>();
    Server server = Mockito.mock(Server.class);
    newServers.add(server);
    try {
        loadBalancer.getServerList(ServerGroup.ALL);
    } catch (Exception e) {
        status = false;
        Assert.assertEquals("Not implemented.", e.getMessage());
    }
    Assert.assertFalse(status);
}
Also used : Server(com.netflix.loadbalancer.Server) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 70 with Server

use of com.netflix.loadbalancer.Server in project java-chassis by ServiceComb.

the class TestSessionSticknessRule method testServerWithoutTimeoutException.

@Test
public void testServerWithoutTimeoutException() {
    boolean status = true;
    SessionStickinessRule ss = new SessionStickinessRule();
    Object key = new Object();
    Server s = new Server("test");
    Deencapsulation.setField(ss, "lastServer", s);
    new MockUp<SessionStickinessRule>() {

        @Mock
        private boolean isTimeOut() {
            return false;
        }
    };
    try {
        ss.choose(key);
    } catch (Exception e) {
        status = false;
    }
    Assert.assertFalse(status);
}
Also used : Server(com.netflix.loadbalancer.Server) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

Server (com.netflix.loadbalancer.Server)72 Test (org.junit.Test)56 ByteBuf (io.netty.buffer.ByteBuf)26 MockWebServer (com.google.mockwebserver.MockWebServer)25 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)24 IClientConfig (com.netflix.client.config.IClientConfig)20 AvailabilityFilteringRule (com.netflix.loadbalancer.AvailabilityFilteringRule)19 DummyPing (com.netflix.loadbalancer.DummyPing)18 HttpServer (com.sun.net.httpserver.HttpServer)18 ArrayList (java.util.ArrayList)13 Person (com.netflix.ribbon.test.resources.EmbeddedResources.Person)12 URI (java.net.URI)11 ServerStats (com.netflix.loadbalancer.ServerStats)10 ClientException (com.netflix.client.ClientException)9 HttpClientResponse (io.reactivex.netty.protocol.http.client.HttpClientResponse)9 ExecutionListener (com.netflix.loadbalancer.reactive.ExecutionListener)8 MockResponse (com.google.mockwebserver.MockResponse)7 AbortExecutionException (com.netflix.loadbalancer.reactive.ExecutionListener.AbortExecutionException)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 DynamicServerListLoadBalancer (com.netflix.loadbalancer.DynamicServerListLoadBalancer)5