コード例 #1
0
 @Test
 public void IncorrectServer_Send() throws MalformedRecipientException {
   when(mockService.send("xxx", "Message")).thenThrow(new MalformedRecipientException());
   int result = msg.sendMessage("xxx", "Message");
   assertEquals(2, result);
   verify(mockService).send("xxx", "Message");
 }
コード例 #2
0
 @Test
 public void CorrectServerAndMessage_SendingError() throws MalformedRecipientException {
   when(mockService.send("inf.ug.edu.pl", "Message")).thenReturn(SendingStatus.SENDING_ERROR);
   int result = msg.sendMessage("inf.ug.edu.pl", "Message");
   assertEquals(1, result);
   verify(mockService).send("inf.ug.edu.pl", "Message");
 }
コード例 #3
0
 @Test
 public void NullServer_CheckConnection() {
   when(mockService.checkConnection(null)).thenReturn(ConnectionStatus.FAILURE);
   int result = msg.testConnection(null);
   assertEquals(1, result);
   verify(mockService).checkConnection(null);
 }
コード例 #4
0
 @Test
 public void IncorrectServer_CheckConnection() {
   when(mockService.checkConnection("inf.ug.edu.com")).thenReturn(ConnectionStatus.FAILURE);
   int result = msg.testConnection("inf.ug.edu.com");
   assertEquals(1, result);
   verify(mockService).checkConnection("inf.ug.edu.com");
 }
コード例 #5
0
 @Test
 public void CorrectServer_CheckConnection() {
   when(mockService.checkConnection("inf.ug.edu.pl")).thenReturn(ConnectionStatus.SUCCESS);
   int result = msg.testConnection("inf.ug.edu.pl");
   assertEquals(0, result);
   verify(mockService).checkConnection("inf.ug.edu.pl");
 }
コード例 #6
0
 @Test
 public void NullServerAndMessage_Send() throws MalformedRecipientException {
   when(mockService.send(null, null)).thenThrow(new MalformedRecipientException());
   int result = msg.sendMessage(null, null);
   assertEquals(2, result);
   verify(mockService).send(null, null);
 }