### Question:
QueuedApnsService extends AbstractApnsService { @Override public void push(ApnsNotification msg) { if (!started.get()) { throw new IllegalStateException("service hasn't be started or was closed"); } queue.add(msg); } QueuedApnsService(ApnsService service); @Override void push(ApnsNotification msg); void start(); void stop(); @Override Map<String, Date> getInactiveDevices(); void testConnection();  }### Answer:
@Test public void pushEvantually() { ConnectionStub connection = spy(new ConnectionStub(0, 1)); ApnsService service = newService(connection, null); service.push(notification); connection.semaphor.acquireUninterruptibly(); verify(connection, times(1)).sendMessage(notification); }
@Test public void pushEvantuallySample() { ConnectionStub connection = spy(new ConnectionStub(0, 1)); ApnsService service = newService(connection, null); service.push("2342", "{}"); connection.semaphor.acquireUninterruptibly(); verify(connection, times(1)).sendMessage(notification); }
@Test(expected=IllegalStateException.class) public void sendWithoutStarting() { QueuedApnsService service = new QueuedApnsService(null); service.push(notification); }