use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class AUTHTest method testFixedMembershipTokenIPv4.
public void testFixedMembershipTokenIPv4() throws Exception {
FixedMembershipToken tok = new FixedMembershipToken();
tok.setMemberList("192.168.1.6,10.1.1.1/7500,localhost/7800");
assert !tok.isInMembersList(new IpAddress("192.168.1.3", 7500));
assert !tok.isInMembersList(new IpAddress("10.1.1.1", 7000));
assert tok.isInMembersList(new IpAddress("10.1.1.1", 7500));
// port is not matched
assert tok.isInMembersList(new IpAddress("192.168.1.6", 7500));
// port is not matched
assert tok.isInMembersList(new IpAddress("192.168.1.6", 0));
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class TCPPING_Test method testSettingInitialHostsProgrammatically.
/**
* Tests https://issues.jboss.org/browse/JGRP-2168
*/
public void testSettingInitialHostsProgrammatically() throws Exception {
TCP transport = new TCP();
transport.setBindAddress(InetAddress.getLoopbackAddress());
transport.setBindPort(9600);
TCPPING ping = new TCPPING();
TCPGOSSIP gossip = new TCPGOSSIP();
List<InetSocketAddress> gossip_router = Collections.singletonList(new InetSocketAddress(InetAddress.getLoopbackAddress(), 12000));
gossip.setInitialHosts(gossip_router);
ping.setInitialHosts(Collections.singletonList(new IpAddress(transport.getBindAddress(), transport.getBindPort())));
ch = new JChannel(transport, ping, gossip);
assert !ping.getInitialHosts().isEmpty() : "No initial hosts!";
assert !gossip.getInitialHosts().isEmpty() : "no initial hosts!";
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class DefaultDNSResolverTest method test_parsing_srv_entries.
@Test
public void test_parsing_srv_entries() throws Exception {
// given
MockDirContext mockDirContext = MockDirContext.newDefault().addEntry("test", "10 100 8888 9089f34a.jgroups-dns-ping.local.", DNSResolver.DNSRecordType.SRV).addEntry("9089f34a.jgroups-dns-ping.local", "192.168.0.1", DNSResolver.DNSRecordType.A).addEntry("9089f34a.jgroups-dns-ping.local", "192.168.0.2", DNSResolver.DNSRecordType.A);
DefaultDNSResolver resolver = new DefaultDNSResolver(mockDirContext);
// when
List<Address> addresses = resolver.resolveIps("test", DNSResolver.DNSRecordType.SRV);
// then
List<Address> expectedResults = Arrays.asList(new IpAddress("192.168.0.1"), new IpAddress("192.168.0.2"));
Assert.assertEquals(addresses, expectedResults);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method setUp.
@BeforeClass
void setUp() throws Exception {
StackType type = Util.getIpStackType();
if (type == StackType.IPv6) {
a = new IpAddress("::1", 5555);
b = new IpAddress("::1", 5555);
d = new IpAddress("::1", 5556);
e = new IpAddress("::1", 5555);
f = new IpAddress("2001:0db8:0000:0000:0000:002e:0370:2334", 80);
g = new IpAddress("2001:0db8:0000:0000:0000:002e:0370:2334", 8080);
h = new IpAddress("ff0e::3:4:5", 5555);
j = new IpAddressUUID("::1", 5555);
k = new IpAddressUUID("::1", 5555);
} else {
a = new IpAddress("localhost", 5555);
b = new IpAddress("localhost", 5555);
d = new IpAddress("localhost", 5556);
e = new IpAddress("127.0.0.1", 5555);
f = new IpAddress("www.ibm.com", 80);
g = new IpAddress("www.ibm.com", 8080);
h = new IpAddress("224.0.0.1", 5555);
j = new IpAddressUUID("localhost", 5555);
k = new IpAddressUUID("localhost", 5555);
}
c = b;
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method testStreamable.
public void testStreamable() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream oos = new DataOutputStream(bos);
byte[] buf = null;
ByteArrayInputStream bis = null;
DataInputStream ois;
IpAddress a2, b2, x, x2, y, y2;
x = createStackConformantAddress(5555);
y = createStackConformantAddress(1111);
a.writeTo(oos);
b.writeTo(oos);
x.writeTo(oos);
y.writeTo(oos);
buf = bos.toByteArray();
bis = new ByteArrayInputStream(buf);
ois = new DataInputStream(bis);
a2 = new IpAddress();
a2.readFrom(ois);
b2 = new IpAddress();
b2.readFrom(ois);
x2 = new IpAddress();
x2.readFrom(ois);
y2 = new IpAddress();
y2.readFrom(ois);
Assert.assertEquals(a, a2);
Assert.assertEquals(b, b2);
assert y2.getIpAddress() != null;
Assert.assertEquals(1111, y2.getPort());
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream();
j.writeTo(out);
k.writeTo(out);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer(), 0, out.position());
IpAddressUUID tmp = new IpAddressUUID();
tmp.readFrom(in);
assert tmp.equals(j);
tmp = new IpAddressUUID();
tmp.readFrom(in);
assert tmp.equals(k);
}
Aggregations