use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method check_joinAnySource_multiple_joins.
private void check_joinAnySource_multiple_joins(InetAddress group, NetworkInterface networkInterface) throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey1 = dc.join(group, networkInterface);
MembershipKey membershipKey2 = dc.join(group, loopbackInterface);
assertFalse(membershipKey1.equals(membershipKey2));
MembershipKey membershipKey1_2 = dc.join(group, networkInterface);
assertEquals(membershipKey1, membershipKey1_2);
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method test_unblock_mixedAddressTypes_IPv4.
public void test_unblock_mixedAddressTypes_IPv4() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface);
try {
membershipKey.unblock(UNICAST_IPv6_1);
fail();
} catch (IllegalStateException expected) {
// Either of these exceptions are fine
} catch (IllegalArgumentException expected) {
// Either of these exceptions are fine
}
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method test_unblock_multipleUnblocksFail.
public void test_unblock_multipleUnblocksFail() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface);
try {
membershipKey.unblock(UNICAST_IPv4_1);
fail();
} catch (IllegalStateException expected) {
}
assertTrue(membershipKey.isValid());
membershipKey.block(UNICAST_IPv4_1);
membershipKey.unblock(UNICAST_IPv4_1);
try {
membershipKey.unblock(UNICAST_IPv4_1);
fail();
} catch (IllegalStateException expected) {
}
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method check_dropSourceSpecific_sourceKeysAreIndependent.
private void check_dropSourceSpecific_sourceKeysAreIndependent(InetAddress groupAddress, InetAddress sourceAddress1, InetAddress sourceAddress2, NetworkInterface networkInterface) throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey1 = dc.join(groupAddress, networkInterface, sourceAddress1);
MembershipKey membershipKey2 = dc.join(groupAddress, networkInterface, sourceAddress2);
assertFalse(membershipKey1.equals(membershipKey2));
assertTrue(membershipKey1.isValid());
assertTrue(membershipKey2.isValid());
membershipKey1.drop();
assertFalse(membershipKey1.isValid());
assertTrue(membershipKey2.isValid());
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method test_drop_keyBehaviorAfterDrop.
public void test_drop_keyBehaviorAfterDrop() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface, UNICAST_IPv4_1);
membershipKey.drop();
assertFalse(membershipKey.isValid());
try {
membershipKey.block(UNICAST_IPv4_1);
fail();
} catch (IllegalStateException expected) {
}
try {
membershipKey.unblock(UNICAST_IPv4_1);
fail();
} catch (IllegalStateException expected) {
}
assertSame(dc, membershipKey.channel());
assertSame(GOOD_MULTICAST_IPv4, membershipKey.group());
assertSame(UNICAST_IPv4_1, membershipKey.sourceAddress());
assertSame(ipv4NetworkInterface, membershipKey.networkInterface());
}
Aggregations