Try with both multicast and explicit addresses

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@895171 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
antelder 2010-01-02 10:44:14 +00:00
parent 9d9bf40a28
commit 1adc194c28

View file

@ -38,26 +38,26 @@ import com.hazelcast.nio.Address;
public class RegistryTestCase {
@Test
public void foo() throws UnknownHostException {
public void test1() throws UnknownHostException {
HazelcastInstance h1 = create(false, 9001, 9002);
HazelcastInstance h1 = create(false, 9001);
IMap<Object, Object> h1map = h1.getMap("mymap");
h1map.put("key1", "bla1");
Assert.assertEquals("bla1", h1map.get("key1"));
HazelcastInstance h2 = create(false, 9002, 9001, 9003);
HazelcastInstance h2 = create(true, 9002, 9001);
IMap<Object, Object> h2map = h2.getMap("mymap");
Assert.assertEquals("bla1", h2map.get("key1"));
HazelcastInstance h3 = create(false, 9003, 9002);
HazelcastInstance h3 = create(true, 9003, 9002);
IMap<Object, Object> h3map = h3.getMap("mymap");
Assert.assertEquals("bla1", h3map.get("key1"));
HazelcastInstance h4 = create(true, 9004, 9003);
HazelcastInstance h5 = create(true, 9005);
IMap<Object, Object> h5map = h5.getMap("mymap");
Assert.assertEquals("bla1", h5map.get("key1"));
// HazelcastInstance h4 = create(true, 9004, 9003);
// HazelcastInstance h5 = create(true, 9005);
// IMap<Object, Object> h5map = h5.getMap("mymap");
// Assert.assertEquals("bla1", h5map.get("key1"));
// HazelcastInstance h6 = create(false, 9006, 9005);
// IMap<Object, Object> h6map = h6.getMap("mymap");
@ -66,22 +66,21 @@ public class RegistryTestCase {
}
private HazelcastInstance create(boolean multicast, int listenPort, int... connectPorts) throws UnknownHostException {
Config config1 = new XmlConfigBuilder().build();
config1.setPort(listenPort);
config1.setPortAutoIncrement(false);
Config config = new XmlConfigBuilder().build();
config.setPort(listenPort);
config.setPortAutoIncrement(false);
// declare the interface Hazelcast should bind to
config1.getNetworkConfig().getInterfaces().clear();
config1.getNetworkConfig().getInterfaces().addInterface(InetAddress.getLocalHost().getHostAddress());
config1.getNetworkConfig().getInterfaces().setEnabled(true);
config.getNetworkConfig().getInterfaces().clear();
config.getNetworkConfig().getInterfaces().addInterface(InetAddress.getLocalHost().getHostAddress());
config.getNetworkConfig().getInterfaces().setEnabled(true);
if (!multicast) {
config1.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
}
if (connectPorts.length > 0) {
TcpIpConfig tcpconfig = config1.getNetworkConfig().getJoin().getJoinMembers();
TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getJoinMembers();
tcpconfig.setEnabled(true);
List<Address> lsMembers = tcpconfig.getAddresses();
@ -91,8 +90,7 @@ public class RegistryTestCase {
}
}
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config1);
return h1;
return Hazelcast.newHazelcastInstance(config);
}
}