use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class ClientQueryCacheContextTest method testInvokerWrapper_invokeOnTarget_whenRequestIsNull_thenThrowException.
@Test(expected = NullPointerException.class)
public void testInvokerWrapper_invokeOnTarget_whenRequestIsNull_thenThrowException() {
Address address = new Address();
context.getInvokerWrapper().invokeOnTarget(null, address);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_portableMapPartitionLostEvent_serialization.
@Test
public void test_portableMapPartitionLostEvent_serialization() throws IOException {
final Address source = new Address();
final PortablePartitionLostEvent event = new PortablePartitionLostEvent(1, 2, source);
final PortableWriter writer = mock(PortableWriter.class);
final ObjectDataOutput output = mock(ObjectDataOutput.class);
when(writer.getRawDataOutput()).thenReturn(output);
event.writePortable(writer);
verify(writer).writeInt("p", 1);
verify(writer).writeInt("l", 2);
verify(output).writeObject(source);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class ProxyManagerTest method testNextAddressToSendCreateRequestOnMultipleLiteMembers.
@Test
public void testNextAddressToSendCreateRequestOnMultipleLiteMembers() {
final List<HazelcastInstance> instances = createNodes(3, 0);
final HazelcastInstance client = factory.newHazelcastClient();
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
Set<Address> addresses = new HashSet<Address>();
final ProxyManager proxyManager = clientInstanceImpl.getProxyManager();
for (int i = 0; i < instances.size() * 100; i++) {
addresses.add(proxyManager.findNextAddressToSendCreateRequest());
}
assertEquals(1, addresses.size());
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class QuorumTestUtil method getClientConfig.
public static ClientConfig getClientConfig(HazelcastInstance instance) {
ClientConfig clientConfig = new ClientConfig();
Address address = getNode(instance).address;
clientConfig.getNetworkConfig().addAddress(address.getHost() + ":" + address.getPort());
clientConfig.getGroupConfig().setName(instance.getConfig().getGroupConfig().getName());
return clientConfig;
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class ClientDiscoverySpiTest method test_discovery_address_translator_with_public_ip.
@Test
public void test_discovery_address_translator_with_public_ip() throws Exception {
String xmlFileName = "hazelcast-client-discovery-spi-test.xml";
InputStream xmlResource = ClientDiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
ClientConfig clientConfig = new XmlClientConfigBuilder(xmlResource).build();
ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
DiscoveryConfig discoveryConfig = networkConfig.getDiscoveryConfig();
DiscoveryServiceProvider provider = new DefaultDiscoveryServiceProvider();
DiscoveryService discoveryService = provider.newDiscoveryService(buildDiscoveryServiceSettings(discoveryConfig));
AddressTranslator translator = new DiscoveryAddressTranslator(discoveryService, true);
Address publicAddress = new Address("127.0.0.1", 50001);
Address privateAddress = new Address("127.0.0.1", 1);
// Enforce refresh of the internal mapping
assertEquals(publicAddress, translator.translate(privateAddress));
}
Aggregations