package rx.broadcast;

import org.junit.Test;
import rx.observers.TestSubscriber;

import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Collections;

public class UdpBroadcastTest {
    @SuppressWarnings({"checkstyle:magicnumber"})
    @Test
    public final void valuesOfTypeDoesReceiveBroadcastValue() throws Exception {
        final TestSubscriber<Object> subscriber = new TestSubscriber<>();
        final DatagramSocket sa = new DatagramSocket();
        final DatagramSocket sb = new DatagramSocket();
        final Broadcast broadcast1 = new UdpBroadcast(sa, InetAddress.getLoopbackAddress(), sb.getLocalPort());
        final Broadcast broadcast2 = new UdpBroadcast(sb, InetAddress.getLoopbackAddress(), sa.getLocalPort());

        broadcast2.valuesOfType(TestValue.class).first().subscribe(subscriber);
        broadcast1.send(new TestValue(42)).toBlocking().subscribe();

        subscriber.awaitTerminalEvent();

        subscriber.assertNoErrors();
        subscriber.assertValueCount(1);
        subscriber.assertReceivedOnNext(Collections.singletonList(new TestValue(42)));

        sa.close();
        sb.close();
    }
}

@@ -137,16 +137,49 @@
 ddress;%0A
+import java.net.SocketException;%0A
 import j
@@ -362,16 +362,22 @@
  throws 
+Socket
 Exceptio

Fix exception in UdpBroadcastTest method signature