use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.
the class TestHttpServiceSelectorBinder method testHttpSelectorString.
@Test
public void testHttpSelectorString() {
Injector injector = Guice.createInjector(new ConfigurationModule(new ConfigurationFactory(ImmutableMap.<String, String>of())), new TestingNodeModule(), new TestingDiscoveryModule(), binder -> discoveryBinder(binder).bindHttpSelector("apple"));
InMemoryDiscoveryClient discoveryClient = injector.getInstance(InMemoryDiscoveryClient.class);
discoveryClient.announce(ImmutableSet.of(serviceAnnouncement("apple").addProperty("http", "fake://server-http").build()));
HttpServiceSelector selector = injector.getInstance(Key.get(HttpServiceSelector.class, serviceType("apple")));
assertEquals(selector.selectHttpService().stream().collect(onlyElement()), URI.create("fake://server-http"));
}
use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.
the class TestHttpServiceSelectorBinder method testNoHttpServices.
@Test
public void testNoHttpServices() {
Injector injector = Guice.createInjector(new ConfigurationModule(new ConfigurationFactory(ImmutableMap.<String, String>of())), new TestingNodeModule(), new TestingDiscoveryModule(), binder -> discoveryBinder(binder).bindHttpSelector("apple"));
InMemoryDiscoveryClient discoveryClient = injector.getInstance(InMemoryDiscoveryClient.class);
discoveryClient.announce(ImmutableSet.of(serviceAnnouncement("apple").addProperty("foo", "fake://server-https").build()));
HttpServiceSelector selector = injector.getInstance(Key.get(HttpServiceSelector.class, serviceType("apple")));
assertEquals(selector.selectHttpService(), ImmutableList.of());
}
Aggregations