Examples of ApnsService


Examples of com.notnoop.apns.ApnsService

        final AtomicInteger sync = new AtomicInteger(138);
        final AtomicInteger numResent = new AtomicInteger();
        final AtomicInteger numSent = new AtomicInteger();
        server.getWaitForError().acquire();
        server.start();
        ApnsService service =
                APNS.newService().withSSLContext(clientContext())
                .withGatewayDestination(LOCALHOST, server.getEffectiveGatewayPort())
                .asQueued()
                .withDelegate(new ApnsDelegate() {
            public void messageSent(ApnsNotification message, boolean resent) {
                if (!resent) {
                    numSent.incrementAndGet();
                }
                sync.getAndDecrement();
            }

            public void messageSendFailed(ApnsNotification message, Throwable e) {
                numSent.decrementAndGet();
                sync.incrementAndGet();
            }

            public void connectionClosed(DeliveryError e, int messageIdentifier) {
            }

            public void cacheLengthExceeded(int newCacheLength) {
            }

            public void notificationsResent(int resendCount) {
                numResent.set(resendCount);
                sync.getAndAdd(resendCount);
            }
        })
                .build();
        server.stopAt(eMsg3.length() * 50 + msg1.length() * 3
                + eMsg2.length() * 2 + eMsg1.length() * 85);
        for (int i = 0; i < 50; ++i) {
            service.push(eMsg3);
        }
        service.push(msg1);
        service.push(eMsg2);
        service.push(eMsg1);
        service.push(msg2);
        for (int i = 0; i < 85; ++i) {
            service.push(eMsg1);
        }

        server.sendError(8, eMsg2.getIdentifier());
        server.getWaitForError().release();
        server.getMessages().acquire();
View Full Code Here

Examples of com.notnoop.apns.ApnsService

        final CountDownLatch sync = new CountDownLatch(1);
        int ORIGINAL_CACHE_LENGTH = 100;
        final AtomicInteger modifiedCacheLength = new AtomicInteger();
        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) {

            }

            public void messageSendFailed(ApnsNotification message, Throwable e) {
            }

            public void connectionClosed(DeliveryError e, int messageIdentifier) {
            }

            public void cacheLengthExceeded(int newCacheLength) {
                modifiedCacheLength.set(newCacheLength);
                sync.countDown();
            }

            public void notificationsResent(int 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 < 101; ++i) {
            service.push(eMsg3);
        }

        server.sendError(8, eMsg2.getIdentifier());

        server.getWaitForError().release();
View Full Code Here

Examples of com.notnoop.apns.ApnsService

            EnhancedApnsNotification.MAXIMUM_EXPIRY, "2342", "{}");

    @Test
    public void pushEventually() {
        ApnsConnection connection = mock(ApnsConnection.class);
        ApnsService service = newService(connection, null);

        service.push(notification);

        verify(connection, times(1)).sendMessage(notification);
    }
View Full Code Here

Examples of com.notnoop.apns.ApnsService

    }

    @Test
    public void pushEventuallySample() {
        ApnsConnection connection = mock(ApnsConnection.class);
        ApnsService service = newService(connection, null);

        service.push("2342", "{}");

        verify(connection, times(1)).sendMessage(notification);
    }
View Full Code Here

Examples of com.notnoop.apns.ApnsService

    SimpleApnsNotification notification = new SimpleApnsNotification("2342", "{}");

    @Test
    public void pushEventually() {
        ConnectionStub connection = spy(new ConnectionStub(0, 1));
        ApnsService service = newService(connection, null);

        service.push(notification);
        connection.semaphore.acquireUninterruptibly();

        verify(connection, times(1)).sendMessage(notification);
    }
View Full Code Here

Examples of com.notnoop.apns.ApnsService

        queued.stop();
    }

    protected ApnsService newService(ApnsConnection connection, ApnsFeedbackConnection feedback) {
        ApnsService service = new ApnsServiceImpl(connection, null);
        ApnsService queued = new QueuedApnsService(service);
        queued.start();
        return queued;
    }
View Full Code Here

Examples of com.notnoop.apns.ApnsService

            configureApnsCertificate(builder);
        } catch (IOException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

Examples of com.notnoop.apns.ApnsService

            configureApnsCertificate(builder);
        } catch (FileNotFoundException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

Examples of com.notnoop.apns.ApnsService

    protected CamelContext createCamelContext() throws Exception {
        CamelContext camelContext = super.createCamelContext();

        ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
        ApnsService apnsService = apnsServiceFactory.getApnsService();

        ApnsComponent apnsComponent = new ApnsComponent(apnsService);

        camelContext.addComponent("apns", apnsComponent);
View Full Code Here

Examples of com.notnoop.apns.ApnsService

    protected CamelContext createCamelContext() throws Exception {
        CamelContext camelContext = super.createCamelContext();

        ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
        ApnsService apnsService = apnsServiceFactory.getApnsService();

        ApnsComponent apnsComponent = new ApnsComponent(apnsService);
        camelContext.addComponent("apns", apnsComponent);

        return camelContext;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.