Search in sources :

Example 16 with ApnsService

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);
}
Also used : ApnsService(com.notnoop.apns.ApnsService) Test(org.junit.Test)

Example 17 with ApnsService

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());
}
Also used : ApnsService(com.notnoop.apns.ApnsService) Test(org.junit.Test) Repeat(com.notnoop.apns.utils.junit.Repeat)

Example 18 with ApnsService

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"));
    }
}
Also used : ApnsService(com.notnoop.apns.ApnsService) NetworkIOException(com.notnoop.exceptions.NetworkIOException) Test(org.junit.Test)

Example 19 with ApnsService

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());
}
Also used : ApnsService(com.notnoop.apns.ApnsService) Test(org.junit.Test) Repeat(com.notnoop.apns.utils.junit.Repeat)

Example 20 with ApnsService

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());
}
Also used : ApnsService(com.notnoop.apns.ApnsService) Test(org.junit.Test)

Aggregations

ApnsService (com.notnoop.apns.ApnsService)32 Test (org.junit.Test)20 ApnsNotification (com.notnoop.apns.ApnsNotification)5 DeliveryError (com.notnoop.apns.DeliveryError)5 EnhancedApnsNotification (com.notnoop.apns.EnhancedApnsNotification)5 SimpleApnsNotification (com.notnoop.apns.SimpleApnsNotification)5 StartSendingApnsDelegate (com.notnoop.apns.StartSendingApnsDelegate)5 ApnsServerStub (com.notnoop.apns.utils.ApnsServerStub)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 CamelContext (org.apache.camel.CamelContext)4 ApnsServiceFactory (org.apache.camel.component.apns.factory.ApnsServiceFactory)4 ApnsDelegate (com.notnoop.apns.ApnsDelegate)2 Repeat (com.notnoop.apns.utils.junit.Repeat)2 ApnsServiceBuilder (com.notnoop.apns.ApnsServiceBuilder)1 ConnectionStub (com.notnoop.apns.internal.QueuedApnsServiceTest.ConnectionStub)1 NetworkIOException (com.notnoop.exceptions.NetworkIOException)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 GeneralSecurityException (java.security.GeneralSecurityException)1