Search in sources :

Example 1 with Builder

use of io.scalecube.cluster.ClusterConfig.Builder in project scalecube by scalecube.

the class ServiceTest method test_services_contribute_to_cluster_metadata.

@Test
public void test_services_contribute_to_cluster_metadata() {
    Map<String, String> metadata = new HashMap<>();
    metadata.put("HOSTNAME", "host1");
    Builder clusterConfig = ClusterConfig.builder().metadata(metadata);
    Microservices ms = Microservices.builder().clusterConfig(clusterConfig).services(new GreetingServiceImpl()).build();
    assertTrue(ms.cluster().member().metadata().containsKey("HOSTNAME"));
    assertTrue(ServiceInfo.from(ms.cluster().member().metadata().entrySet().stream().filter(item -> item.getValue().equals("service")).findFirst().get().getKey()).getServiceName().equals("io.scalecube.services.GreetingService"));
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) CanaryTestingRouter(io.scalecube.services.a.b.testing.CanaryTestingRouter) GreetingServiceImplA(io.scalecube.services.a.b.testing.GreetingServiceImplA) Assert.assertTrue(org.junit.Assert.assertTrue) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) GreetingServiceImplB(io.scalecube.services.a.b.testing.GreetingServiceImplB) Executors(java.util.concurrent.Executors) Builder(io.scalecube.cluster.ClusterConfig.Builder) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterConfig(io.scalecube.cluster.ClusterConfig) CanaryService(io.scalecube.services.a.b.testing.CanaryService) Ignore(org.junit.Ignore) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) Map(java.util.Map) Assert.fail(org.junit.Assert.fail) Message(io.scalecube.transport.Message) BaseTest(io.scalecube.testlib.BaseTest) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) Builder(io.scalecube.cluster.ClusterConfig.Builder) Test(org.junit.Test) BaseTest(io.scalecube.testlib.BaseTest)

Aggregations

ClusterConfig (io.scalecube.cluster.ClusterConfig)1 Builder (io.scalecube.cluster.ClusterConfig.Builder)1 CanaryService (io.scalecube.services.a.b.testing.CanaryService)1 CanaryTestingRouter (io.scalecube.services.a.b.testing.CanaryTestingRouter)1 GreetingServiceImplA (io.scalecube.services.a.b.testing.GreetingServiceImplA)1 GreetingServiceImplB (io.scalecube.services.a.b.testing.GreetingServiceImplB)1 BaseTest (io.scalecube.testlib.BaseTest)1 Message (io.scalecube.transport.Message)1 Duration (java.time.Duration)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutionException (java.util.concurrent.ExecutionException)1 Executors (java.util.concurrent.Executors)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Assert.assertEquals (org.junit.Assert.assertEquals)1