コード例 #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);
 }