final AtomicInteger numSent = new AtomicInteger();
int EXPECTED_RESEND_COUNT = 7;
int EXPECTED_SEND_COUNT = 12;
server.getWaitForError().acquire();
server.start();
ApnsService service =
APNS.newService().withSSLContext(clientContext())
.withGatewayDestination(LOCALHOST, server.getEffectiveGatewayPort())
.withDelegate(new ApnsDelegate() {
public void messageSent(ApnsNotification message, boolean resent) {
if (!resent) {
numSent.incrementAndGet();
}
sync.countDown();
}
public void messageSendFailed(ApnsNotification message, Throwable e) {
numSent.decrementAndGet();
}
public void connectionClosed(DeliveryError e, int messageIdentifier) {
}
public void cacheLengthExceeded(int newCacheLength) {
}
public void notificationsResent(int resendCount) {
numResent.set(resendCount);
}
})
.build();
server.stopAt(eMsg1.length() * 5 + eMsg2.length() + eMsg3.length() * 14);
for (int i = 0; i < 5; ++i) {
service.push(eMsg1);
}
service.push(eMsg2);
for (int i = 0; i < 7; ++i) {
service.push(eMsg3);
}
server.sendError(8, eMsg2.getIdentifier());
server.getWaitForError().release();