use of com.notnoop.apns.ApnsNotification in project java-apns by notnoop.
the class BatchApnsServiceTest method simpleBatchWait_maxDelay.
@Test
public void simpleBatchWait_maxDelay() throws IOException, InterruptedException {
// send message
ApnsNotification message1 = service.push("1234", "{}");
Thread.sleep(delayTimeInSec1_4_millis * 3);
ApnsNotification message2 = service.push("4321", "{}");
Thread.sleep(delayTimeInSec1_4_millis * 3);
ApnsNotification message3 = service.push("4321", "{}");
Thread.sleep(delayTimeInSec1_4_millis * 3);
ApnsNotification message4 = service.push("4321", "{}");
// make sure no message was send yet
verify(prototype, times(0)).copy();
verify(prototype, times(0)).sendMessage(message1);
verify(prototype, times(0)).sendMessage(message2);
verify(prototype, times(0)).sendMessage(message3);
verify(prototype, times(0)).sendMessage(message4);
verify(prototype, times(0)).close();
Thread.sleep(delayTimeInSec1_4_millis + /* for sure */
250);
// verify batch sends and close the connection
verify(prototype, times(1)).copy();
verify(prototype, times(1)).sendMessage(message1);
verify(prototype, times(1)).sendMessage(message2);
verify(prototype, times(1)).sendMessage(message3);
verify(prototype, times(1)).sendMessage(message4);
verify(prototype, times(1)).close();
}
use of com.notnoop.apns.ApnsNotification in project java-apns by notnoop.
the class BatchApnsServiceTest method simpleBatchWait_multiple.
@Test
public void simpleBatchWait_multiple() throws IOException, InterruptedException {
// send message
ApnsNotification message1 = service.push("1234", "{}");
Thread.sleep(delayTimeInSec1_2_millis);
ApnsNotification message2 = service.push("4321", "{}");
// make sure no message was send yet
verify(prototype, times(0)).copy();
verify(prototype, times(0)).sendMessage(message1);
verify(prototype, times(0)).sendMessage(message2);
verify(prototype, times(0)).close();
Thread.sleep(delayTimeInSec1_4_millis * 3);
// still no send
verify(prototype, times(0)).copy();
verify(prototype, times(0)).sendMessage(message1);
verify(prototype, times(0)).sendMessage(message2);
verify(prototype, times(0)).close();
Thread.sleep(delayTimeInSec1_4_millis + /* for sure */
250);
// verify batch sends and close the connection
verify(prototype, times(1)).copy();
verify(prototype, times(1)).sendMessage(message1);
verify(prototype, times(1)).sendMessage(message2);
verify(prototype, times(1)).close();
}
Aggregations