コード例 #1
0
 @Override
 public void process(IIdRequest request) {
   checkConnection();
   init();
   if (request.getId() != null) {
     existsResponseMap.put(request.getId(), VOID_RESULT);
   }
   // TODO: block any request with No ID !!
   client.sendRequest(request);
 }
コード例 #2
0
  @Override
  public ITestResult processAndWaitForValue(IIdRequest request)
      throws IllegalAccessException, TimeoutException, ErrorResultReceivedException {

    final String idRequest = request.getId();
    if (idRequest == null) {
      throw new IllegalAccessException("Request requires an Id to wait for a value.");
    }
    init();
    valueResponseMap.put(idRequest, VOID_RESULT);
    client.sendRequest(request);
    ValueResponse valueResponse = waitForValue(request);
    ITestResult res = new SuccessResult(valueResponse.value);
    res.setScreenShot(valueResponse.getBase64ScreenShot());
    return res;
  }
コード例 #3
0
 private ValueResponse waitForValue(final IIdRequest request)
     throws TimeoutException, ErrorResultReceivedException {
   client.keepAlive();
   final String idRequest = request.getId();
   ValueResponse res = null;
   int countTimeOut = WAIT_TIMEOUT;
   int incOffset = 500;
   if (valueResponseMap.containsKey(idRequest)) {
     while (VOID_RESULT.equals(valueResponseMap.get(idRequest))) {
       try {
         client.keepAlive();
         Thread.sleep(incOffset);
         countTimeOut = countTimeOut - incOffset;
         if (countTimeOut <= 0) {
           valueResponseMap.remove(idRequest);
           throw new TimeoutException(
               "No Response received for request: "
                   + idRequest
                   + " after "
                   + (WAIT_TIMEOUT / 1000)
                   + "s !");
         }
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
     if (valueResponseMap.get(idRequest) instanceof ITestResult) {
       ITestResult result = (ITestResult) valueResponseMap.get(idRequest);
       ValueResponse valueResponse =
           new ValueResponse(idRequest, result.getMessage(), result.getScreenShot());
       valueResponseMap.remove(idRequest);
       return valueResponse;
     }
     res = (ValueResponse) valueResponseMap.get(idRequest);
     valueResponseMap.remove(idRequest);
   }
   return res;
 }