use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.
the class MulticastServiceTest method testSetInterfaceDefaultWhenLoopback.
@Test
public void testSetInterfaceDefaultWhenLoopback() throws Exception {
Config config = createConfig(null);
MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
multicastConfig.setLoopbackModeEnabled(true);
MulticastSocket multicastSocket = mock(MulticastSocket.class);
Address address = new Address("127.0.0.1", 5701);
HazelcastProperties hzProperties = new HazelcastProperties(config);
MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
verify(multicastSocket).setLoopbackMode(false);
// https://github.com/hazelcast/hazelcast/pull/19251#issuecomment-891375270
if (OsHelper.isMac()) {
verify(multicastSocket).setInterface(address.getInetAddress());
} else {
verify(multicastSocket, never()).setInterface(any());
}
}
use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.
the class MulticastServiceTest method testSetInterfaceDefaultWhenNonLoopbackAddrAndLoopbackMode.
@Test
public void testSetInterfaceDefaultWhenNonLoopbackAddrAndLoopbackMode() throws Exception {
Config config = createConfig(null);
MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
multicastConfig.setLoopbackModeEnabled(true);
MulticastSocket multicastSocket = mock(MulticastSocket.class);
Address address = new Address("10.0.0.2", 5701);
HazelcastProperties hzProperties = new HazelcastProperties(config);
MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
verify(multicastSocket).setInterface(address.getInetAddress());
verify(multicastSocket).setLoopbackMode(false);
}
use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.
the class MulticastServiceTest method testMulticastGroupProperty.
@Test
public void testMulticastGroupProperty() throws Exception {
Config config = createConfig(null);
String customMulticastGroup = "225.225.225.225";
config.setProperty(ClusterProperty.MULTICAST_GROUP.getName(), customMulticastGroup);
MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
MulticastSocket multicastSocket = mock(MulticastSocket.class);
Address address = new Address("10.0.0.2", 5701);
HazelcastProperties hzProperties = new HazelcastProperties(config);
MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
verify(multicastSocket).bind(new InetSocketAddress(multicastConfig.getMulticastPort()));
verify(multicastSocket).setTimeToLive(multicastConfig.getMulticastTimeToLive());
verify(multicastSocket, never()).setLoopbackMode(anyBoolean());
verify(multicastSocket).joinGroup(InetAddress.getByName(customMulticastGroup));
}
use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.
the class MulticastServiceTest method testSetInterfaceDefaultWhenNonLoopbackAddrAndNoLoopbackMode.
@Test
public void testSetInterfaceDefaultWhenNonLoopbackAddrAndNoLoopbackMode() throws Exception {
Config config = createConfig(null);
MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
multicastConfig.setLoopbackModeEnabled(false);
MulticastSocket multicastSocket = mock(MulticastSocket.class);
Address address = new Address("10.0.0.2", 5701);
HazelcastProperties hzProperties = new HazelcastProperties(config);
MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
verify(multicastSocket).setInterface(address.getInetAddress());
verify(multicastSocket).setLoopbackMode(true);
}
use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.
the class MulticastServiceTest method testSetInterfaceDisabled.
@Test
public void testSetInterfaceDisabled() throws Exception {
Config config = createConfig(Boolean.FALSE);
MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
MulticastSocket multicastSocket = mock(MulticastSocket.class);
Address address = new Address("127.0.0.1", 5701);
HazelcastProperties hzProperties = new HazelcastProperties(config);
MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
verify(multicastSocket, never()).setInterface(any());
}
Aggregations