Ejemplo n.º 1
0
 @Test
 public void testUDPconnection() throws Exception {
   Subject<byte[], byte[]> sub = PublishSubject.create();
   SimpleChan simpleadapter = new SimpleChan(sub);
   TestAwaitableObserver<byte[]> monitor = new TestAwaitableObserver<>();
   sub.subscribe(monitor);
   int port = rand.nextInt(100) + 8000;
   ServerFrontEnd udpSrv = ServerFrontEnd.udp(simpleadapter, port);
   udpSrv.startAsync().awaitRunning();
   sendMSG(MSG.getBytes(), port);
   monitor.awaitOnNext(1, TIMEOUT);
   assertThat("msg was received", monitor.getOnNextEvents().get(0), equalTo(MSG.getBytes()));
 }
Ejemplo n.º 2
0
 @Test
 public void testUDPLargePacket() throws Exception {
   Subject<byte[], byte[]> sub = PublishSubject.create();
   SimpleChan simpleadapter = new SimpleChan(sub);
   TestAwaitableObserver<byte[]> monitor = new TestAwaitableObserver<>();
   sub.subscribe(monitor);
   int port = rand.nextInt(100) + 8000;
   ServerFrontEnd udpSrv = ServerFrontEnd.udp(simpleadapter, port, 65536);
   byte[] msg = new byte[65535 - 28]; // max payload size
   rand.nextBytes(msg);
   udpSrv.startAsync().awaitRunning();
   sendMSG(msg, port);
   monitor.awaitOnNext(1, TIMEOUT);
   assertThat("msg was received", monitor.getOnNextEvents().get(0), equalTo(msg));
 }