Package com.cloudhopper.commons.util.windowing

Examples of com.cloudhopper.commons.util.windowing.WindowFuture


                EnquireLinkResp el1Resp = el1.createResponse();
                EnquireLinkResp el2Resp = el2.createResponse();
                EnquireLinkResp el3Resp = el3.createResponse();

                // this request should be permitted (with window size = 2)
                WindowFuture future0 = session.sendRequestPdu(el0, 3000, true);
                WindowFuture future1 = session.sendRequestPdu(el1, 3000, true);
                WindowFuture future2 = session.sendRequestPdu(el2, 3000, true);

                Assert.assertEquals(3, session.getSendWindow().getSize());

                try {
                    // window size of 3 is now filled up, this one should timeout
                    session.sendRequestPdu(el3, 100, true);
                    Assert.fail();
                } catch (SmppTimeoutException e) {
                    Assert.assertNotNull(e.getCause());
                    Assert.assertEquals(OfferTimeoutException.class, e.getCause().getClass());
                }

                Assert.assertEquals(3, session.getSendWindow().getSize());

                // now the smsc will send a response back to the second request
                simulator0.sendPdu(el1Resp);

                // wait for the response to make its way back in
                future1.await();

                // there should be 1 slot free now in the window
                Assert.assertEquals(2, session.getSendWindow().getSize());

                // this request should now succeed
                WindowFuture future3 = session.sendRequestPdu(el3, 3000, true);

                // send back responses for everything that's missing
                simulator0.sendPdu(el2Resp);
                simulator0.sendPdu(el0Resp);
                simulator0.sendPdu(el3Resp);

                // make sure they all finished
                future0.await();
                future1.await();
                future2.await();
                future3.await();

                Assert.assertEquals(0, session.getSendWindow().getSize());
        } finally {
            SmppSessionUtil.close(session);
        }
View Full Code Here


            EnquireLink el0 = new EnquireLink();
            el0.setSequenceNumber(0x1001);
            EnquireLinkResp el0Resp = el0.createResponse();

            // send a request and wait for a response that never shows up
            WindowFuture future = session.sendRequestPdu(el0, 50, true);
            Assert.assertFalse(future.await());
            // a call to cancel() is usually done in sendRequestPduAndGetResponse
            // but for this test we'll manually need to call it here
            future.cancel();

            Assert.assertEquals(WindowFuture.CALLER_WAITING_TIMEOUT, future.getCallerStateHint());
           
            // send a response now after the caller would have timed out
            simulator0.sendPdu(el0Resp);

            // we should have received an unexpected PDU response
View Full Code Here

TOP

Related Classes of com.cloudhopper.commons.util.windowing.WindowFuture

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.