Search in sources :

Example 6 with CacheEndpoint

use of io.servicecomb.serviceregistry.cache.CacheEndpoint in project java-chassis by ServiceComb.

the class TestIpPortManager method testNextAddressesSize.

@Test
public void testNextAddressesSize() {
    new MockUp<IpPortManager>() {

        @Mock
        public List<CacheEndpoint> getAddressCaches() {
            List<CacheEndpoint> addressCaches = new ArrayList<>();
            addressCaches.add(new CacheEndpoint("http://127.0.0.3:8080", null));
            addressCaches.add(new CacheEndpoint("http://127.0.0.3:8080", null));
            return addressCaches;
        }
    };
    Map<Integer, Boolean> addressCanUsed = new HashMap<Integer, Boolean>();
    addressCanUsed.get(0);
    addressCanUsed.put(0, true);
    Deencapsulation.setField(manager, "addressCanUsed", addressCanUsed);
    Assert.assertEquals(manager.next().getHostOrIp(), "127.0.0.3");
}
Also used : CacheEndpoint(io.servicecomb.serviceregistry.cache.CacheEndpoint) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

CacheEndpoint (io.servicecomb.serviceregistry.cache.CacheEndpoint)6 Test (org.junit.Test)3 Server (com.netflix.loadbalancer.Server)2 Transport (io.servicecomb.core.Transport)2 URIEndpointObject (io.servicecomb.foundation.common.net.URIEndpointObject)2 ArrayList (java.util.ArrayList)2 LoadBalancerStats (com.netflix.loadbalancer.LoadBalancerStats)1 HashMap (java.util.HashMap)1 List (java.util.List)1 MockUp (mockit.MockUp)1