コード例 #1
0
  @Test
  public void testUpdateConnection() throws Exception {
    doNothing().when(connectionServiceImpl).ensureDataAccessPermission();
    doReturn("").when(connectionServiceImpl).getConnectionPassword(anyString(), anyString());

    assertTrue(connectionServiceImpl.updateConnection(mockDBConnection));

    verify(connectionServiceImpl).updateConnection(mockDBConnection);
    verify(datasourceService).clearDataSource(CONN_NAME);
  }
コード例 #2
0
 private void testUpdateConnectionError(Exception ex) throws Exception {
   doNothing().when(connectionServiceImpl).ensureDataAccessPermission();
   doReturn("").when(connectionServiceImpl).getConnectionPassword(anyString(), anyString());
   doThrow(ex)
       .when(connectionServiceImpl.datasourceMgmtSvc)
       .updateDatasourceByName(CONN_NAME, mockDBConnection);
   try {
     connectionServiceImpl.updateConnection(mockDBConnection);
     fail(); // This line should never be reached
   } catch (ConnectionServiceException e) {
     // Expected exception
   }
   verify(connectionServiceImpl).updateConnection(mockDBConnection);
 }