use of io.airlift.configuration.ConfigurationModule 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());
}
use of io.airlift.configuration.ConfigurationModule in project airlift by airlift.
the class TestNodeModule method testFullConfig.
@Test
public void testFullConfig() {
long testStartTime = System.currentTimeMillis();
String environment = "environment";
String pool = "pool";
String nodeId = "nodeId";
String location = "location";
String binarySpec = "binary";
String configSpec = "config";
String publicAddress = "public";
ConfigurationFactory configFactory = new ConfigurationFactory(ImmutableMap.<String, String>builder().put("node.environment", environment).put("node.pool", pool).put("node.id", nodeId).put("node.internal-address", publicAddress).put("node.location", location).put("node.binary-spec", binarySpec).put("node.config-spec", configSpec).build());
Injector injector = Guice.createInjector(new NodeModule(), new ConfigurationModule(configFactory));
NodeInfo nodeInfo = injector.getInstance(NodeInfo.class);
assertNotNull(nodeInfo);
assertEquals(nodeInfo.getEnvironment(), environment);
assertEquals(nodeInfo.getPool(), pool);
assertEquals(nodeInfo.getNodeId(), nodeId);
assertEquals(nodeInfo.getLocation(), location);
assertEquals(nodeInfo.getBinarySpec(), binarySpec);
assertEquals(nodeInfo.getConfigSpec(), configSpec);
assertNotNull(nodeInfo.getInstanceId());
assertNotEquals(nodeInfo.getNodeId(), nodeInfo.getInstanceId());
assertEquals(nodeInfo.getInternalAddress(), publicAddress);
assertEquals(nodeInfo.getBindIp(), InetAddresses.forString("0.0.0.0"));
assertGreaterThanOrEqual(nodeInfo.getStartTime(), testStartTime);
// make sure toString doesn't throw an exception
assertNotNull(nodeInfo.toString());
}
Aggregations