예제 #1
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple search query, with multiple requests, with *win* or *lin* as the
  *       parameter, searching for VMs
  *   <li>Return success, the success status is succeeded, with a failure in the result set
  *   <li>Check to make sure the appropriate query start and query complete events are fired
  * </ol>
  */
 @Test
 public void testRunMultipleQueries_multiple_success_and_failure() {
   // Don't immediately call process until both queries are in the queue.
   fakeScheduler.setThreshold(2);
   ArrayList<VdcQueryType> queryTypeList = new ArrayList<VdcQueryType>();
   queryTypeList.add(VdcQueryType.Search);
   queryTypeList.add(VdcQueryType.Search);
   ArrayList<VdcQueryParametersBase> queryParamsList = new ArrayList<VdcQueryParametersBase>();
   queryParamsList.add(new SearchParameters("*win*", SearchType.VM)); // $NON-NLS-1$
   queryParamsList.add(new SearchParameters("*lin*", SearchType.VM)); // $NON-NLS-1$
   frontend.runMultipleQueries(
       queryTypeList, queryParamsList, mockMultipleQueryCallback, "test"); // $NON-NLS-1$
   verify(mockService)
       .RunMultipleQueries(
           eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
   // Call the failure handler.
   List<VdcQueryReturnValue> result = new ArrayList<VdcQueryReturnValue>();
   result.add(new VdcQueryReturnValue());
   result.get(0).setSucceeded(false);
   result.add(new VdcQueryReturnValue());
   result.get(1).setSucceeded(true);
   ArgumentCaptor<FrontendMultipleQueryAsyncResult> multipleResultCaptor =
       ArgumentCaptor.forClass(FrontendMultipleQueryAsyncResult.class);
   callbackMultipleQueries.getValue().onSuccess((ArrayList<VdcQueryReturnValue>) result);
   verify(mockMultipleQueryCallback).executed(multipleResultCaptor.capture());
   assertEquals(
       "callback result much match",
       result, //$NON-NLS-1$
       multipleResultCaptor.getValue().getReturnValues());
 }
예제 #2
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple search query, with multiple requests, with *win* or *lin* as the
  *       parameter, searching for VMs
  *   <li>Force a special failure with an HTTP status code = 0, this is an ignored failure (escape
  *       key pressed)
  *   <li>Check to make sure the appropriate query start and query complete events are fired
  * </ol>
  */
 @Test
 public void testRunMultipleQueries_ignored_failure_multiple() {
   // Don't immediately call process until both queries are in the queue.
   fakeScheduler.setThreshold(2);
   ArrayList<VdcQueryType> queryTypeList = new ArrayList<VdcQueryType>();
   queryTypeList.add(VdcQueryType.Search);
   queryTypeList.add(VdcQueryType.Search);
   ArrayList<VdcQueryParametersBase> queryParamsList = new ArrayList<VdcQueryParametersBase>();
   queryParamsList.add(new SearchParameters("*win*", SearchType.VM)); // $NON-NLS-1$
   queryParamsList.add(new SearchParameters("*lin*", SearchType.VM)); // $NON-NLS-1$
   frontend.runMultipleQueries(
       queryTypeList, queryParamsList, mockMultipleQueryCallback, "test"); // $NON-NLS-1$
   StatusCodeException exception = new StatusCodeException(0, "0 status code"); // $NON-NLS-1$
   // Repeat 4 times, because of retries.
   for (int i = 1; i < RETRY_COUNT; i++) {
     // Reset the count so we can re-add both entries again.
     fakeScheduler.resetCount();
     verify(mockService, times(i))
         .RunMultipleQueries(
             eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
     // Call the failure handler.
     callbackMultipleQueries.getValue().onFailure(exception);
   }
   verify(mockFrontendFailureEvent, never())
       .raise(eq(Frontend.class), any(FrontendFailureEventArgs.class));
 }
예제 #3
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple search query, with only multiple requests, with *win* / *lin* as the
  *       parameter, searching for VMs
  *   <li>Force a failure with an HTTP status code = 404
  *   <li>Check to make sure the appropriate query start and query complete events are fired
  * </ol>
  */
 @Test
 public void testRunMultipleQueries_404_failure() {
   // Don't immediately call process until both queries are in the queue.
   fakeScheduler.setThreshold(2);
   when(mockConstants.requestToServerFailedWithCode())
       .thenReturn("A Request to the Server failed with the following Status Code"); // $NON-NLS-1$
   ArrayList<VdcQueryType> queryTypeList = new ArrayList<VdcQueryType>();
   queryTypeList.add(VdcQueryType.Search);
   queryTypeList.add(VdcQueryType.Search);
   ArrayList<VdcQueryParametersBase> queryParamsList = new ArrayList<VdcQueryParametersBase>();
   queryParamsList.add(new SearchParameters("*win*", SearchType.VM)); // $NON-NLS-1$
   queryParamsList.add(new SearchParameters("*lin*", SearchType.VM)); // $NON-NLS-1$
   frontend.runMultipleQueries(
       queryTypeList, queryParamsList, mockMultipleQueryCallback, "test"); // $NON-NLS-1$
   StatusCodeException exception =
       new StatusCodeException(HttpServletResponse.SC_NOT_FOUND, "404 status code"); // $NON-NLS-1$
   // Repeat 4 times, because of retries.
   for (int i = 1; i < RETRY_COUNT; i++) {
     // Reset the count so we can re-add both entries again.
     fakeScheduler.resetCount();
     verify(mockService, times(i))
         .RunMultipleQueries(
             eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
     // Call the failure handler.
     callbackMultipleQueries.getValue().onFailure(exception);
   }
   ArgumentCaptor<FrontendFailureEventArgs> eventArgs =
       ArgumentCaptor.forClass(FrontendFailureEventArgs.class);
   verify(mockFrontendFailureEvent).raise(eq(Frontend.class), eventArgs.capture());
   assertEquals(
       "Message text didn't match", //$NON-NLS-1$
       "A Request to the Server failed with the following Status Code: 404", //$NON-NLS-1$
       eventArgs.getValue().getMessage().getText());
 }
예제 #4
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple search query, with only one request, with *win* as the parameter,
  *       searching for VMs
  *   <li>The callback is NOT marked to handle failures
  *   <li>Force a special failure with an HTTP status code = 0, this is an ignored failure (escape
  *       key pressed)
  *   <li>Check to make sure the appropriate query start and query complete events are fired
  * </ol>
  */
 @Test
 public void testRunMultipleQueries_ignored_failure() {
   ArrayList<VdcQueryType> queryTypeList = new ArrayList<VdcQueryType>();
   queryTypeList.add(VdcQueryType.Search);
   ArrayList<VdcQueryParametersBase> queryParamsList = new ArrayList<VdcQueryParametersBase>();
   queryParamsList.add(new SearchParameters("*win*", SearchType.VM)); // $NON-NLS-1$
   frontend.runMultipleQueries(
       queryTypeList, queryParamsList, mockMultipleQueryCallback, "test"); // $NON-NLS-1$
   StatusCodeException exception = new StatusCodeException(0, "0 status code"); // $NON-NLS-1$
   // Repeat 4 times, because of retries.
   for (int i = 1; i < RETRY_COUNT; i++) {
     verify(mockService, times(i))
         .RunMultipleQueries(
             eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
     // Call the failure handler.
     callbackMultipleQueries.getValue().onFailure(exception);
   }
   verify(mockFrontendFailureEvent, never())
       .raise(eq(Frontend.class), any(FrontendFailureEventArgs.class));
 }