private void startServerChannels() { String[] hosts = TransportConfiguration.splitHosts(host); for (String h : hosts) { SocketAddress address; if (useInvm) { address = new LocalAddress(h); } else { address = new InetSocketAddress(h, port); } Channel serverChannel = bootstrap.bind(address).syncUninterruptibly().channel(); serverChannelGroup.add(serverChannel); } }
@Test public void testSplitNullAddress() throws Exception { String[] addresses = TransportConfiguration.splitHosts(null); Assert.assertNotNull(addresses); Assert.assertEquals(0, addresses.length); }
@Test public void testSplitSingleAddress() throws Exception { String[] addresses = TransportConfiguration.splitHosts("localhost"); Assert.assertNotNull(addresses); Assert.assertEquals(1, addresses.length); Assert.assertEquals("localhost", addresses[0]); }
@Test public void testSplitManyAddresses() throws Exception { String[] addresses = TransportConfiguration.splitHosts("localhost, 127.0.0.1, 192.168.0.10"); Assert.assertNotNull(addresses); Assert.assertEquals(3, addresses.length); Assert.assertEquals("localhost", addresses[0]); Assert.assertEquals("127.0.0.1", addresses[1]); Assert.assertEquals("192.168.0.10", addresses[2]); }