@Test public void testCopyCalls() throws Exception { ApnsPooledConnection conn = new ApnsPooledConnection(prototype, 1, getSingleThreadExecutor()); for (int i = 0; i < 10; i++) { conn.sendMessage(mock(ApnsNotification.class)); } verify(prototype, times(1)).copy(); }
@Test public void testCloseCalls() throws Exception { ApnsPooledConnection conn = new ApnsPooledConnection(prototype, 1, getSingleThreadExecutor()); conn.sendMessage(mock(ApnsNotification.class)); conn.close(); // should be closed twice because of the thread local copy verify(prototype, times(2)).close(); }
@Test(expected = NetworkIOException.class) public void testSendMessage() throws Exception { ApnsPooledConnection conn = new ApnsPooledConnection(errorPrototype, 1, getSingleThreadExecutor()); conn.sendMessage(mock(ApnsNotification.class)); }