ConfigurationHostSupplierProvider implements Provider<HostSupplier> { @Override public HostSupplier get() { return () -> parseHostsFromConfig(configuration); } @Inject  ConfigurationHostSupplierProvider(DynomiteConfiguration configuration); @Override HostSupplier get();  }
@Test public void getHost() { configuration.setProperty("workflow.dynomite.cluster.hosts", "dyno1:8102:us-east-1c"); List<Host> hosts = provider.get().getHosts(); Assert.assertEquals(1, hosts.size()); Host firstHost = hosts.get(0); Assert.assertEquals("dyno1", firstHost.getHostName()); Assert.assertEquals(8102, firstHost.getPort()); Assert.assertEquals("us-east-1c", firstHost.getRack()); Assert.assertTrue(firstHost.isUp()); }
@Test public void getMultipleHosts() { configuration.setProperty("workflow.dynomite.cluster.hosts", "dyno1:8102:us-east-1c;dyno2:8103:us-east-1c"); List<Host> hosts = provider.get().getHosts(); Assert.assertEquals(2, hosts.size()); Host firstHost = hosts.get(0); Assert.assertEquals("dyno1", firstHost.getHostName()); Assert.assertEquals(8102, firstHost.getPort()); Assert.assertEquals("us-east-1c", firstHost.getRack()); Assert.assertTrue(firstHost.isUp()); Host secondHost = hosts.get(1); Assert.assertEquals("dyno2", secondHost.getHostName()); Assert.assertEquals(8103, secondHost.getPort()); Assert.assertEquals("us-east-1c", secondHost.getRack()); Assert.assertTrue(secondHost.isUp()); }
@Test public void getAuthenticatedHost() { configuration .setProperty("workflow.dynomite.cluster.hosts", "redis1:6432:us-east-1c:password"); List<Host> hosts = provider.get().getHosts(); Assert.assertEquals(1, hosts.size()); Host firstHost = hosts.get(0); Assert.assertEquals("redis1", firstHost.getHostName()); Assert.assertEquals(6432, firstHost.getPort()); Assert.assertEquals("us-east-1c", firstHost.getRack()); Assert.assertEquals("password", firstHost.getPassword()); Assert.assertTrue(firstHost.isUp()); }