Beispiel #1
0
  private SoapUIAMFConnection getConnection(AMFRequest amfRequest) throws Exception {
    SoapUIAMFConnection amfConnection = null;
    if (isAuthorisationEnabled(amfRequest) && (context.getModelItem() instanceof WsdlTestCase)) {
      if ((amfConnection = (SoapUIAMFConnection) context.getProperty(AMF_CONNECTION)) != null) {
        return amfConnection;
      } else {
        throw new Exception("amf session connection error! ");
      }
    } else if (isAuthorisationEnabled(amfRequest)
        && (context.getModelItem() instanceof AMFRequestTestStep)) {
      String endpoint = context.expand(getTestCaseConfig(amfRequest).getAmfEndpoint());
      String username = context.expand(getTestCaseConfig(amfRequest).getAmfLogin());
      String password = context.expand(getTestCaseConfig(amfRequest).getAmfPassword());

      if (StringUtils.hasContent(endpoint) && StringUtils.hasContent(username)) {
        credentials = new AMFCredentials(endpoint, username, password, context);
        amfConnection = credentials.login();
      } else {
        amfConnection = new SoapUIAMFConnection();
        amfConnection.connect(context.expand(amfRequest.getEndpoint()));
      }

      context.setProperty(AMF_CONNECTION, amfConnection);
      return amfConnection;
    } else {
      amfConnection = new SoapUIAMFConnection();
      amfConnection.connect(context.expand(amfRequest.getEndpoint()));
      return amfConnection;
    }
  }
Beispiel #2
0
  private Object executeAmfCall(AMFRequest amfRequest)
      throws ClientStatusException, ServerStatusException {
    SoapUIAMFConnection amfConnection = null;
    try {
      amfConnection = getConnection(amfRequest);
      addAmfHeaders(amfRequest, amfConnection);
      addHttpHeaders(amfRequest, amfConnection);
      Object result =
          amfConnection.call(context, amfRequest.getAmfCall(), amfRequest.argumentsToArray());

      return result;
    } catch (Exception e) {
      SoapUI.logError(e);
      error = e;
      status = Status.ERROR;
    } finally {
      amfRequest.clearArguments();
      if (context.getModelItem() instanceof AMFRequestTestStep) {
        if (credentials != null && credentials.isLoggedIn()) {
          credentials.logout();
          credentials = null;
        } else {
          amfConnection.close();
        }
      }
    }
    return null;
  }
Beispiel #3
0
  private void addAmfHeaders(AMFRequest amfRequest, SoapUIAMFConnection amfConnection) {
    if (amfRequest.getAmfHeaders() != null) {
      for (String key : amfRequest.getAmfHeaders().keySet()) {
        Object data = amfRequest.getAmfHeaders().get(key);
        if (data instanceof String) data = context.expand((String) data);

        amfConnection.addAmfHeader(key, data);
      }
    }
  }
Beispiel #4
0
  public AMFSubmit(AMFRequest request, SubmitContext submitContext, boolean async) {
    this.request = request;
    this.context = submitContext;

    List<SubmitListener> regListeners =
        SoapUI.getListenerRegistry().getListeners(SubmitListener.class);

    SubmitListener[] submitListeners = request.getSubmitListeners();
    this.listeners = new SubmitListener[submitListeners.length + regListeners.size()];
    for (int c = 0; c < submitListeners.length; c++) {
      this.listeners[c] = submitListeners[c];
    }

    for (int c = 0; c < regListeners.size(); c++) {
      this.listeners[submitListeners.length + c] = regListeners.get(c);
    }

    error = null;
    status = Status.INITIALIZED;
    timestamp = System.currentTimeMillis();

    if (async) {
      future = SoapUI.getThreadPool().submit(this);
    } else {
      run();
    }
  }
Beispiel #5
0
 private void addHttpHeaders(AMFRequest amfRequest, SoapUIAMFConnection amfConnection) {
   StringToStringsMap httpHeaders = amfRequest.getHttpHeaders();
   if (httpHeaders != null) {
     for (String key : httpHeaders.getKeys()) {
       for (String value : httpHeaders.get(key))
         amfConnection.addHttpRequestHeader(key, context.expand(value));
     }
   }
 }
Beispiel #6
0
 private TestCaseConfig getTestCaseConfig(AMFRequest amfRequest) {
   return amfRequest.getTestStep().getTestCase().getConfig();
 }