@Before public void setup() { errorPrototype = mock(ApnsConnection.class); when(errorPrototype.copy()).thenReturn(errorPrototype); doThrow(NetworkIOException.class).when(errorPrototype).sendMessage(any(ApnsNotification.class)); prototype = mock(ApnsConnection.class); when(prototype.copy()).thenReturn(prototype); }