use of com.notnoop.apns.ApnsService in project java-apns by notnoop.
the class ApnsServiceImplTest method pushEventuallySample.
@Test
public void pushEventuallySample() {
ApnsConnection connection = mock(ApnsConnection.class);
ApnsService service = newService(connection, null);
service.push("2342", "{}");
verify(connection, times(1)).sendMessage(notification);
}
use of com.notnoop.apns.ApnsService in project java-apns by notnoop.
the class ApnsConnectionTest method sendOneSimple.
@Repeat(count = 50)
@Test(timeout = 2000)
public void sendOneSimple() throws InterruptedException {
ApnsService service = APNS.newService().withSSLContext(clientContext()).withGatewayDestination(LOCALHOST, gatewayPort).build();
server.stopAt(msg1.length());
service.push(msg1);
server.getMessages().acquire();
assertArrayEquals(msg1.marshall(), server.getReceived().toByteArray());
}
use of com.notnoop.apns.ApnsService in project java-apns by notnoop.
the class ApnsConnectionTest method sendOneSimpleClientCertFail.
@Test(timeout = 2000)
public void sendOneSimpleClientCertFail() throws InterruptedException {
ApnsService service = APNS.newService().withSSLContext(clientMultiKeyContext("notused")).withGatewayDestination(LOCALHOST, gatewayPort).build();
server.stopAt(msg1.length());
try {
service.push(msg1);
fail();
} catch (NetworkIOException e) {
assertTrue("Expected bad_certifcate exception", e.getMessage().contains("bad_certificate"));
}
}
use of com.notnoop.apns.ApnsService in project java-apns by notnoop.
the class ApnsConnectionTest method sendOneQueued.
@Repeat(count = 50)
@Test(timeout = 2000)
public void sendOneQueued() throws InterruptedException {
ApnsService service = APNS.newService().withSSLContext(clientContext()).withGatewayDestination(LOCALHOST, gatewayPort).asQueued().build();
server.stopAt(msg1.length());
service.push(msg1);
server.getMessages().acquire();
assertArrayEquals(msg1.marshall(), server.getReceived().toByteArray());
}
use of com.notnoop.apns.ApnsService in project java-apns by notnoop.
the class FeedbackTest method simpleFeedback.
@Test
public void simpleFeedback() throws IOException {
server.getToSend().write(simple);
ApnsService service = APNS.newService().withSSLContext(clientContext).withGatewayDestination(LOCALHOST, server.getEffectiveGatewayPort()).withFeedbackDestination(LOCALHOST, server.getEffectiveFeedbackPort()).build();
checkParsedSimple(service.getInactiveDevices());
}
Aggregations