예제 #1
0
 @Test
 public void shouldReturnConnectionToPoolWhenNonOkResponse() throws Exception {
   when(mMessagePusher.pushAndReadResponse(mConnection, mMessage))
       .thenReturn(new PushResponse(AppleResponseCode.InvalidPayloadSize, BigDecimal.ONE));
   mService.pushMessage(mMessage);
   verify(mPool).returnObject(mConnection);
 }
예제 #2
0
 @Test
 public void shouldCloseConnectionExplicitlyIfResponseFromAppleIsNotOk() throws Exception {
   when(mMessagePusher.pushAndReadResponse(mConnection, mMessage))
       .thenReturn(new PushResponse(AppleResponseCode.InvalidPayloadSize, BigDecimal.ONE));
   mService.pushMessage(mMessage);
   verify(mConnection).close();
 }
예제 #3
0
 @Test
 public void shouldReturnConnectionToPoolWhenExceptionThrownByMessagePusher() throws Exception {
   when(mMessagePusher.pushAndReadResponse(mConnection, mMessage))
       .thenThrow(new MessageTransformationException("FOO"));
   try {
     mService.pushMessage(mMessage);
   } catch (MessageTransformationException e) {
     // expected
   }
   verify(mPool).returnObject(mConnection);
 }
예제 #4
0
 @Test
 public void shouldReturnConnectionToPoolWhenOkResponse() throws Exception {
   when(mMessagePusher.pushAndReadResponse(mConnection, mMessage)).thenReturn(PushResponse.OK);
   mService.pushMessage(mMessage);
   verify(mPool).returnObject(mConnection);
 }