예제 #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;
    }
  }
예제 #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;
  }