Search in sources :

Example 1 with SimpleMicroserviceInstancePing

use of org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing in project java-chassis by ServiceComb.

the class TestSimpleMicroserviceInstancePing method testPing.

@Test
public void testPing() throws IOException {
    SimpleMicroserviceInstancePing ping = new SimpleMicroserviceInstancePing();
    Assert.assertEquals(ping.getOrder(), 100);
    MicroserviceInstance instance = new MicroserviceInstance();
    List<String> endpoints = new ArrayList<>();
    ServerSocket ss = new ServerSocket(35677);
    endpoints.add("http://localhost:35677");
    instance.setEndpoints(endpoints);
    Assert.assertTrue(ping.ping(instance));
    MicroserviceInstance instance2 = new MicroserviceInstance();
    Assert.assertFalse(ping.ping(instance2));
    ss.close();
    Assert.assertFalse(ping.ping(instance));
}
Also used : ArrayList(java.util.ArrayList) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) ServerSocket(java.net.ServerSocket) SimpleMicroserviceInstancePing(org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing) Test(org.junit.Test)

Example 2 with SimpleMicroserviceInstancePing

use of org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing in project java-chassis by ServiceComb.

the class TestSimpleMicroserviceInstancePing method testPing_more_endpoin.

@Test
public void testPing_more_endpoin() throws IOException {
    SimpleMicroserviceInstancePing ping = new SimpleMicroserviceInstancePing();
    MicroserviceInstance instance = new MicroserviceInstance();
    List<String> endpoints = new ArrayList<>();
    ServerSocket ss = new ServerSocket(35677);
    endpoints.add("http://localhost:35676");
    endpoints.add("http://localhost:35677");
    instance.setEndpoints(endpoints);
    Assert.assertTrue(ping.ping(instance));
    ss.close();
    Assert.assertFalse(ping.ping(instance));
}
Also used : ArrayList(java.util.ArrayList) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) ServerSocket(java.net.ServerSocket) SimpleMicroserviceInstancePing(org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing) Test(org.junit.Test)

Example 3 with SimpleMicroserviceInstancePing

use of org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing in project incubator-servicecomb-java-chassis by apache.

the class TestSimpleMicroserviceInstancePing method testPing_more_endpoin.

@Test
public void testPing_more_endpoin() throws IOException {
    SimpleMicroserviceInstancePing ping = new SimpleMicroserviceInstancePing();
    MicroserviceInstance instance = new MicroserviceInstance();
    List<String> endpoints = new ArrayList<>();
    ServerSocket ss = new ServerSocket(35677);
    endpoints.add("http://localhost:35676");
    endpoints.add("http://localhost:35677");
    instance.setEndpoints(endpoints);
    Assert.assertTrue(ping.ping(instance));
    ss.close();
    Assert.assertFalse(ping.ping(instance));
}
Also used : ArrayList(java.util.ArrayList) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) ServerSocket(java.net.ServerSocket) SimpleMicroserviceInstancePing(org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing) Test(org.junit.Test)

Example 4 with SimpleMicroserviceInstancePing

use of org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing in project incubator-servicecomb-java-chassis by apache.

the class TestSimpleMicroserviceInstancePing method testPing.

@Test
public void testPing() throws IOException {
    SimpleMicroserviceInstancePing ping = new SimpleMicroserviceInstancePing();
    Assert.assertEquals(ping.getOrder(), 100);
    MicroserviceInstance instance = new MicroserviceInstance();
    List<String> endpoints = new ArrayList<>();
    ServerSocket ss = new ServerSocket(35677);
    endpoints.add("http://localhost:35677");
    instance.setEndpoints(endpoints);
    Assert.assertTrue(ping.ping(instance));
    MicroserviceInstance instance2 = new MicroserviceInstance();
    Assert.assertFalse(ping.ping(instance2));
    ss.close();
    Assert.assertFalse(ping.ping(instance));
}
Also used : ArrayList(java.util.ArrayList) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) ServerSocket(java.net.ServerSocket) SimpleMicroserviceInstancePing(org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing) Test(org.junit.Test)

Aggregations

ServerSocket (java.net.ServerSocket)4 ArrayList (java.util.ArrayList)4 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)4 SimpleMicroserviceInstancePing (org.apache.servicecomb.registry.consumer.SimpleMicroserviceInstancePing)4 Test (org.junit.Test)4