コード例 #1
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Attempt to log-off
  *   <li>Have the log-off succeed
  *   <li>Make sure the onSuccess handler is called
  *   <li>Make sure the onLogout handler is called
  * </ol>
  */
 @Test
 public void testLogoffAsync_success() {
   Object model = new Object();
   when(mockAsyncQuery.getModel()).thenReturn(model);
   DbUser testUser = new DbUser();
   testUser.setLoginName("testUser"); // $NON-NLS-1$
   frontend.logoffAsync(testUser, mockAsyncQuery);
   verify(mockService).logOff(eq(testUser), callbackAction.capture());
   VdcReturnValueBase returnValue = new VdcReturnValueBase();
   callbackAction.getValue().onSuccess(returnValue);
   verify(mockAsyncCallback).onSuccess(model, returnValue);
   verify(mockLoginHandler).onLogout();
 }
コード例 #2
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Attempt to log-off
  *   <li>Have the log-off fail with a status code of 0, which is an ignored failure
  *   <li>Check to make sure the callback is not called
  *   <li>Check to make sure the events handler is never called
  *   <li>Make sure the onSuccess handler is never called
  * </ol>
  */
 @Test
 public void testLogoffAsync_ignored_failure() {
   Object model = new Object();
   when(mockAsyncQuery.getModel()).thenReturn(model);
   DbUser testUser = new DbUser();
   testUser.setLoginName("testUser"); // $NON-NLS-1$
   frontend.logoffAsync(testUser, mockAsyncQuery);
   verify(mockService).logOff(eq(testUser), callbackAction.capture());
   StatusCodeException exception = new StatusCodeException(0, "0 status code"); // $NON-NLS-1$
   callbackAction.getValue().onFailure(exception);
   verify(mockFrontendFailureEvent, never()).raise(eq(Frontend.class), (EventArgs) any());
   verify(mockEventsHandler, never()).runQueryFailed(null);
   verify(mockAsyncCallback, never()).onSuccess(model, null);
 }