use of java.net.InetAddress in project hazelcast by hazelcast.
the class MemberGroupFactoryTest method createMembersWithHostAwareMetadata.
private Collection<Member> createMembersWithHostAwareMetadata() throws UnknownHostException {
Collection<Member> members = new HashSet<Member>();
InetAddress fakeAddress = InetAddress.getLocalHost();
MemberImpl member1 = new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, true);
member1.setStringAttribute(PartitionGroupMetaData.PARTITION_GROUP_HOST, "host-1");
MemberImpl member2 = new MemberImpl(new Address("192.192.0.2", fakeAddress, 5701), VERSION, true);
member2.setStringAttribute(PartitionGroupMetaData.PARTITION_GROUP_HOST, "host-2");
MemberImpl member3 = new MemberImpl(new Address("192.192.0.3", fakeAddress, 5701), VERSION, true);
member3.setStringAttribute(PartitionGroupMetaData.PARTITION_GROUP_HOST, "host-3");
members.add(member1);
members.add(member2);
members.add(member3);
return members;
}
use of java.net.InetAddress in project hazelcast by hazelcast.
the class MemberGroupFactoryTest method createMembers.
private Collection<Member> createMembers() throws UnknownHostException {
Collection<Member> members = new HashSet<Member>();
InetAddress fakeAddress = InetAddress.getLocalHost();
members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5702), VERSION, false));
return members;
}
use of java.net.InetAddress in project guava by google.
the class InetAddressesTest method testIsMaximum.
public void testIsMaximum() throws UnknownHostException {
InetAddress address = InetAddress.getByName("255.255.255.254");
assertFalse(InetAddresses.isMaximum(address));
address = InetAddress.getByName("255.255.255.255");
assertTrue(InetAddresses.isMaximum(address));
address = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe");
assertFalse(InetAddresses.isMaximum(address));
address = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
assertTrue(InetAddresses.isMaximum(address));
}
use of java.net.InetAddress in project guava by google.
the class InetAddressesTest method testMappedIPv4Addresses.
public void testMappedIPv4Addresses() throws UnknownHostException {
/*
* Verify that it is not possible to instantiate an Inet6Address
* from an "IPv4 mapped" IPv6 address. Our String-based method can
* at least identify them, however.
*/
String mappedStr = "::ffff:192.168.0.1";
assertTrue(InetAddresses.isMappedIPv4Address(mappedStr));
InetAddress mapped = InetAddresses.forString(mappedStr);
assertThat(mapped).isNotInstanceOf(Inet6Address.class);
assertEquals(InetAddress.getByName("192.168.0.1"), mapped);
// check upper case
mappedStr = "::FFFF:192.168.0.1";
assertTrue(InetAddresses.isMappedIPv4Address(mappedStr));
mapped = InetAddresses.forString(mappedStr);
assertThat(mapped).isNotInstanceOf(Inet6Address.class);
assertEquals(InetAddress.getByName("192.168.0.1"), mapped);
mappedStr = "0:00:000:0000:0:ffff:1.2.3.4";
assertTrue(InetAddresses.isMappedIPv4Address(mappedStr));
mapped = InetAddresses.forString(mappedStr);
assertThat(mapped).isNotInstanceOf(Inet6Address.class);
assertEquals(InetAddress.getByName("1.2.3.4"), mapped);
mappedStr = "::ffff:0102:0304";
assertTrue(InetAddresses.isMappedIPv4Address(mappedStr));
mapped = InetAddresses.forString(mappedStr);
assertThat(mapped).isNotInstanceOf(Inet6Address.class);
assertEquals(InetAddress.getByName("1.2.3.4"), mapped);
assertFalse(InetAddresses.isMappedIPv4Address("::"));
assertFalse(InetAddresses.isMappedIPv4Address("::ffff"));
assertFalse(InetAddresses.isMappedIPv4Address("::ffff:0"));
assertFalse(InetAddresses.isMappedIPv4Address("::fffe:0:0"));
assertFalse(InetAddresses.isMappedIPv4Address("::1:ffff:0:0"));
assertFalse(InetAddresses.isMappedIPv4Address("foo"));
assertFalse(InetAddresses.isMappedIPv4Address("192.0.2.1"));
}
use of java.net.InetAddress in project guava by google.
the class InetAddressesTest method testIsatapAddresses.
public void testIsatapAddresses() {
InetAddress ipv4 = InetAddresses.forString("1.2.3.4");
String[] validIsatapAddresses = { "2001:db8::5efe:102:304", // Private Multicast? Not likely.
"2001:db8::100:5efe:102:304", "2001:db8::200:5efe:102:304", // Public Multicast? Also unlikely.
"2001:db8::300:5efe:102:304" };
String[] nonIsatapAddresses = { "::1.2.3.4", "3ffe::1", "::", "::1", "2001:db8::0040:5efe:102:304", "2001:db8::5ffe:102:304", "2001:db8::5eff:102:304", // Teredo address; not ISATAP
"2001:0:102:203:200:5efe:506:708" };
for (int i = 0; i < validIsatapAddresses.length; i++) {
InetAddress ip = InetAddresses.forString(validIsatapAddresses[i]);
assertTrue(InetAddresses.isIsatapAddress((Inet6Address) ip));
assertEquals("checking '" + validIsatapAddresses[i] + "'", ipv4, InetAddresses.getIsatapIPv4Address((Inet6Address) ip));
}
for (int i = 0; i < nonIsatapAddresses.length; i++) {
InetAddress ip = InetAddresses.forString(nonIsatapAddresses[i]);
assertFalse(InetAddresses.isIsatapAddress((Inet6Address) ip));
try {
InetAddresses.getIsatapIPv4Address((Inet6Address) ip);
fail("IllegalArgumentException expected for '" + nonIsatapAddresses[i] + "'");
} catch (IllegalArgumentException expected) {
// expected behavior
}
}
}
Aggregations