Search in sources :

Example 1 with ServiceConfig

use of io.scalecube.services.ServicesConfig.Builder.ServiceConfig in project scalecube by scalecube.

the class ServiceInstanceTest method test_localService_instance.

@Test
public void test_localService_instance() {
    Address address = Address.create("localhost", 4000);
    ServiceConfig conf = new ServiceConfig(new GreetingServiceImpl());
    LocalServiceInstance instance = new LocalServiceInstance(conf, address, "a", "b", new HashMap<>());
    assertEquals(instance.toString(), "LocalServiceInstance [serviceObject=GreetingServiceImpl [], memberId=a]");
    assertTrue(instance.tags().isEmpty());
    assertEquals(instance.memberId(), "a");
    assertEquals(instance.serviceName(), "b");
    try {
        new LocalServiceInstance(null, address, "a", "b", new HashMap<>());
    } catch (Exception ex) {
        assertEquals(ex.toString(), "java.lang.IllegalArgumentException: serviceConfig can't be null");
    }
    try {
        new LocalServiceInstance(conf, null, "a", "b", new HashMap<>());
    } catch (Exception ex) {
        assertEquals(ex.toString(), "java.lang.IllegalArgumentException: address can't be null");
    }
    try {
        new LocalServiceInstance(conf, address, null, "b", new HashMap<>());
    } catch (Exception ex) {
        assertEquals(ex.toString(), "java.lang.IllegalArgumentException: memberId can't be null");
    }
    try {
        new LocalServiceInstance(conf, address, "a", null, new HashMap<>());
    } catch (Exception ex) {
        assertEquals(ex.toString(), "java.lang.IllegalArgumentException: serviceName can't be null");
    }
    try {
        new LocalServiceInstance(conf, address, "a", "b", null);
    } catch (Exception ex) {
        assertEquals(ex.toString(), "java.lang.IllegalArgumentException: methods can't be null");
    }
    try {
        new LocalServiceInstance(conf, address, "a", "b", new HashMap<>()).invoke(null);
    } catch (Exception ex) {
        assertEquals(ex.toString(), "java.lang.IllegalArgumentException: message can't be null");
    }
}
Also used : Address(io.scalecube.transport.Address) ServiceConfig(io.scalecube.services.ServicesConfig.Builder.ServiceConfig) HashMap(java.util.HashMap) Test(org.junit.Test) BaseTest(io.scalecube.testlib.BaseTest)

Aggregations

ServiceConfig (io.scalecube.services.ServicesConfig.Builder.ServiceConfig)1 BaseTest (io.scalecube.testlib.BaseTest)1 Address (io.scalecube.transport.Address)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1