// change window size to 3
configuration.setWindowSize(3);
// bind and get the simulator session
DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration);
SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
// make sure the processor is null
simulator0.setPduProcessor(null);
try {
// try {
// create the requests and response we plan on sending
EnquireLink el0 = new EnquireLink();
EnquireLink el1 = new EnquireLink();
EnquireLink el2 = new EnquireLink();
EnquireLink el3 = new EnquireLink();
el0.setSequenceNumber(0x7000);
el1.setSequenceNumber(0x4541);
el2.setSequenceNumber(0x5414);
el3.setSequenceNumber(0x2414);
EnquireLinkResp el0Resp = el0.createResponse();
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();