package com.notnoop.apns.internal;

import org.junit.Test;

import com.notnoop.apns.ApnsService;

public class QueuedApnsServiceTest extends ApnsServiceImplTest{

    @Test(expected=IllegalStateException.class)
    public void sendWithoutStarting() {
        QueuedApnsService service = new QueuedApnsService(null);
        service.push(notification);
    }

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

@@ -40,24 +40,137 @@
 ort 
-org.junit.Test;%0A
+static org.junit.Assert.*;%0Aimport org.junit.Test;%0Aimport static org.mockito.Mockito.*;%0A%0Aimport com.notnoop.apns.ApnsNotification;
 %0Aimp
@@ -465,16 +465,799 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void dontBlock() %7B%0A        final int delay = 10000;%0A        ApnsConnection connection = new ApnsConnection(null, null, 0) %7B%0A            protected synchronized void sendMessage(ApnsNotification m) %7B%0A                try %7B%0A                    Thread.sleep(delay);%0A                %7D catch (InterruptedException e) %7B%0A                %7D%0A            %7D%0A        %7D;%0A%0A        QueuedApnsService queued =%0A            new QueuedApnsService(new ApnsServiceImpl(connection, null));%0A        queued.start();%0A        long time1 = System.currentTimeMillis();%0A        queued.push(notification);%0A        queued.push(notification);%0A        long time2 = System.currentTimeMillis();%0A        assertTrue(%22Queued blocks unexpectedly%22, (time2- time1) %3C delay);%0A%0A        queued.stop();%0A    %7D%0A%0A
     prot

add tests for the queued service