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);
}