@Override
  public void perform(WsdlTestSuite testSuite, Object param) {

    if (IntegrationUtils.forceSaveProject(testSuite.getProject())) {

      if (!StartLoadUI.testCajoConnection()) {
        if (UISupport.confirm(
            StartLoadUI.LOADUI_LAUNCH_QUESTION, StartLoadUI.LOADUI_LAUNCH_TITLE)) {
          StartLoadUI.launchLoadUI();
        }
        return;
      }

      XFormDialog dialog = ADialogBuilder.buildDialog(TestSuiteForm.class);

      dialog.setOptions(TestSuiteForm.LOADUIPROJECT, IntegrationUtils.getAvailableProjects());
      if (!StringUtils.isNullOrEmpty(IntegrationUtils.getOpenedProjectName())) {
        dialog.setValue(TestSuiteForm.LOADUIPROJECT, IntegrationUtils.getOpenedProjectName());
      } else {
        dialog.setValue(TestSuiteForm.LOADUIPROJECT, IntegrationUtils.CREATE_NEW_OPTION);
      }
      List<String> testSuiteLoadTests = new ArrayList<String>();
      for (TestCase testCase : testSuite.getTestCaseList()) {
        for (LoadTest loadTest : testCase.getLoadTestList()) {
          testSuiteLoadTests.add(testCase.getName() + " - " + loadTest.getName());
        }
      }
      String[] names = new String[testSuiteLoadTests.size()];
      for (int c = 0; c < names.length; c++) {
        names[c] = testSuiteLoadTests.get(c);
      }
      dialog.setOptions(TestSuiteForm.LOADTESTS, names);
      if (dialog.show()) {
        if (dialog.getReturnValue() == XFormDialog.OK_OPTION) {
          String loadUIProject = dialog.getValue(TestSuiteForm.LOADUIPROJECT);
          String openedProjectName = IntegrationUtils.getOpenedProjectName();
          if (!StringUtils.isNullOrEmpty(openedProjectName)
              && !loadUIProject.equals(openedProjectName)
              && IntegrationUtils.checkOpenedLoadUIProjectForClose()) {
            return;
          }
          String[] soapuiLoadTests =
              StringUtils.toStringArray(
                  ((XFormMultiSelectList) dialog.getFormField(TestSuiteForm.LOADTESTS))
                      .getSelectedOptions());
          if (soapuiLoadTests.length == 0) {
            UISupport.showErrorMessage("No LoadTests selected.");
            return;
          }
          try {
            IntegrationUtils.exportMultipleLoadTestToLoadUI(
                testSuite, soapuiLoadTests, loadUIProject);
          } catch (IOException e) {
            UISupport.showInfoMessage("Error while opening selected loadUI project");
            return;
          }
        }
      }
    }
  }
 public void perform(ModelItem[] targets, Object param) {
   for (ModelItem target : targets) {
     if (target instanceof WsdlTestStep) ((WsdlTestStep) target).setDisabled(false);
     else if (target instanceof WsdlTestCase) ((WsdlTestCase) target).setDisabled(false);
     else if (target instanceof WsdlTestSuite) ((WsdlTestSuite) target).setDisabled(false);
   }
 }
Exemplo n.º 3
0
 /**
  * Run tests in the specified TestSuite
  *
  * @param suite the TestSuite to run
  */
 protected void runSuite(WsdlTestSuite suite) {
   try {
     log.info(("Running TestSuite [" + suite.getName() + "], runType = " + suite.getRunType()));
     WsdlTestSuiteRunner runner = suite.run(new StringToObjectMap(), false);
     log.info(
         "TestSuite ["
             + suite.getName()
             + "] finished with status ["
             + runner.getStatus()
             + "] in "
             + (runner.getTimeTaken())
             + "ms");
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     testSuiteCount++;
   }
 }
Exemplo n.º 4
0
  public void perform(WsdlTestCase testCase, Object param) {
    if (dialog == null) {
      dialog = ADialogBuilder.buildDialog(Form.class);
      dialog
          .getFormField(Form.PROJECT)
          .addFormFieldListener(
              new XFormFieldListener() {

                public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                  if (newValue.equals(CREATE_NEW_OPTION))
                    dialog.setOptions(Form.TESTSUITE, new String[] {CREATE_NEW_OPTION});
                  else {
                    Project project = SoapUI.getWorkspace().getProjectByName(newValue);
                    dialog.setOptions(
                        Form.TESTSUITE,
                        ModelSupport.getNames(
                            project.getTestSuiteList(), new String[] {CREATE_NEW_OPTION}));
                  }
                }
              });
      dialog
          .getFormField(Form.CLONE_DESCRIPTION)
          .addFormFieldListener(
              new XFormFieldListener() {

                public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                  if (dialog.getBooleanValue(Form.CLONE_DESCRIPTION)) {
                    dialog.getFormField(Form.DESCRIPTION).setEnabled(false);
                  } else {
                    dialog.getFormField(Form.DESCRIPTION).setEnabled(true);
                  }
                }
              });
    }

    dialog.setBooleanValue(Form.MOVE, false);
    dialog.setBooleanValue(Form.CLONE_DESCRIPTION, true);
    dialog.getFormField(Form.DESCRIPTION).setEnabled(false);
    dialog.setValue(Form.DESCRIPTION, testCase.getDescription());
    dialog.setValue(Form.NAME, "Copy of " + testCase.getName());
    WorkspaceImpl workspace = testCase.getTestSuite().getProject().getWorkspace();
    dialog.setOptions(
        Form.PROJECT,
        ModelSupport.getNames(workspace.getOpenProjectList(), new String[] {CREATE_NEW_OPTION}));

    dialog.setValue(Form.PROJECT, testCase.getTestSuite().getProject().getName());

    dialog.setOptions(
        Form.TESTSUITE,
        ModelSupport.getNames(
            testCase.getTestSuite().getProject().getTestSuiteList(),
            new String[] {CREATE_NEW_OPTION}));

    dialog.setValue(Form.TESTSUITE, testCase.getTestSuite().getName());
    boolean hasLoadTests = testCase.getLoadTestCount() > 0;
    dialog.setBooleanValue(Form.CLONE_LOADTESTS, hasLoadTests);
    dialog.getFormField(Form.CLONE_LOADTESTS).setEnabled(hasLoadTests);

    if (dialog.show()) {
      String targetProjectName = dialog.getValue(Form.PROJECT);
      String targetTestSuiteName = dialog.getValue(Form.TESTSUITE);
      String name = dialog.getValue(Form.NAME);

      WsdlProject project = testCase.getTestSuite().getProject();
      WsdlTestSuite targetTestSuite = null;
      Set<Interface> requiredInterfaces = new HashSet<Interface>();

      // to another project project?
      if (!targetProjectName.equals(project.getName())) {
        // get required interfaces
        for (int y = 0; y < testCase.getTestStepCount(); y++) {
          WsdlTestStep testStep = testCase.getTestStepAt(y);
          requiredInterfaces.addAll(testStep.getRequiredInterfaces());
        }

        project = (WsdlProject) workspace.getProjectByName(targetProjectName);
        if (project == null) {
          targetProjectName = UISupport.prompt("Enter name for new Project", "Clone TestCase", "");
          if (targetProjectName == null) return;

          try {
            project = workspace.createProject(targetProjectName, null);
          } catch (SoapUIException e) {
            UISupport.showErrorMessage(e);
          }

          if (project == null) return;
        }

        if (requiredInterfaces.size() > 0 && project.getInterfaceCount() > 0) {
          Map<String, Interface> bindings = new HashMap<String, Interface>();
          for (Interface iface : requiredInterfaces) {
            bindings.put(iface.getTechnicalId(), iface);
          }

          for (Interface iface : project.getInterfaceList()) {
            bindings.remove(iface.getTechnicalId());
          }

          requiredInterfaces.retainAll(bindings.values());
        }

        if (requiredInterfaces.size() > 0) {
          String msg =
              "Target project [" + targetProjectName + "] is missing required Interfaces;\r\n\r\n";
          for (Interface iface : requiredInterfaces) {
            msg += iface.getName() + " [" + iface.getTechnicalId() + "]\r\n";
          }
          msg += "\r\nThese will be cloned to the targetProject as well";

          if (!UISupport.confirm(msg, "Clone TestCase")) return;

          for (Interface iface : requiredInterfaces) {
            project.importInterface((AbstractInterface<?>) iface, true, true);
          }
        }
      }

      targetTestSuite = project.getTestSuiteByName(targetTestSuiteName);
      if (targetTestSuite == null) {
        targetTestSuiteName =
            UISupport.prompt(
                "Specify name for new TestSuite",
                "Clone TestCase",
                "Copy of " + testCase.getTestSuite().getName());
        if (targetTestSuiteName == null) return;

        targetTestSuite = project.addNewTestSuite(targetTestSuiteName);
      }

      boolean move = dialog.getBooleanValue(Form.MOVE);
      WsdlTestCase newTestCase =
          targetTestSuite.importTestCase(
              testCase, name, -1, dialog.getBooleanValue(Form.CLONE_LOADTESTS), !move);
      UISupport.select(newTestCase);

      if (move) {
        testCase.getTestSuite().removeTestCase(testCase);
      }
      boolean cloneDescription = dialog.getBooleanValue(Form.CLONE_DESCRIPTION);
      if (!cloneDescription) {
        newTestCase.setDescription(dialog.getValue(Form.DESCRIPTION));
      }
    }
  }
    public void actionPerformed(ActionEvent e) {
      if (optionsDialog == null) {
        optionsDialog = ADialogBuilder.buildDialog(OptionsForm.class);
        optionsDialog
            .getFormField(OptionsForm.TESTSUITE)
            .addFormFieldListener(
                new XFormFieldListener() {

                  public void valueChanged(
                      XFormField sourceField, String newValue, String oldValue) {
                    List<TestCase> testCaseList =
                        project.getTestSuiteByName(newValue).getTestCaseList();
                    testCaseList.remove(getModelItem().getTestCase());
                    optionsDialog.setOptions(
                        OptionsForm.TESTCASE, ModelSupport.getNames(testCaseList));

                    if (testCaseList.size() > 0) {
                      WsdlTestCase testCase = project.getTestSuiteByName(newValue).getTestCaseAt(0);
                      optionsDialog.setOptions(
                          OptionsForm.RETURN_PROPERTIES, testCase.getPropertyNames());
                      ((XFormMultiSelectList)
                              optionsDialog.getFormField(OptionsForm.RETURN_PROPERTIES))
                          .setSelectedOptions(getModelItem().getReturnProperties().toStringArray());
                    }
                  }
                });
        optionsDialog
            .getFormField(OptionsForm.TESTCASE)
            .addFormFieldListener(
                new XFormFieldListener() {

                  public void valueChanged(
                      XFormField sourceField, String newValue, String oldValue) {
                    WsdlTestSuite testSuite =
                        project.getTestSuiteByName(optionsDialog.getValue(OptionsForm.TESTSUITE));
                    WsdlTestCase testCase = testSuite.getTestCaseByName(newValue);
                    optionsDialog.setOptions(
                        OptionsForm.RETURN_PROPERTIES, testCase.getPropertyNames());
                    ((XFormMultiSelectList)
                            optionsDialog.getFormField(OptionsForm.RETURN_PROPERTIES))
                        .setSelectedOptions(getModelItem().getReturnProperties().toStringArray());
                  }
                });
      }

      WsdlTestCase targetTestCase = getModelItem().getTargetTestCase();

      optionsDialog.setOptions(
          OptionsForm.TESTSUITE, ModelSupport.getNames(project.getTestSuiteList()));
      if (targetTestCase != null) {
        optionsDialog.setValue(OptionsForm.TESTSUITE, targetTestCase.getTestSuite().getName());

        List<TestCase> testCaseList = targetTestCase.getTestSuite().getTestCaseList();
        testCaseList.remove(getModelItem().getTestCase());

        optionsDialog.setOptions(OptionsForm.TESTCASE, ModelSupport.getNames(testCaseList));
        optionsDialog.setValue(OptionsForm.TESTCASE, targetTestCase.getName());

        optionsDialog.setOptions(OptionsForm.RETURN_PROPERTIES, targetTestCase.getPropertyNames());
        ((XFormMultiSelectList) optionsDialog.getFormField(OptionsForm.RETURN_PROPERTIES))
            .setSelectedOptions(getModelItem().getReturnProperties().toStringArray());
      } else {
        if (project.getTestSuiteCount() == 0) {
          optionsDialog.setOptions(OptionsForm.TESTCASE, new String[0]);
          optionsDialog.setOptions(OptionsForm.RETURN_PROPERTIES, new String[0]);
        } else {
          List<TestCase> testCaseList = project.getTestSuiteAt(0).getTestCaseList();
          testCaseList.remove(getModelItem().getTestCase());
          optionsDialog.setOptions(OptionsForm.TESTCASE, ModelSupport.getNames(testCaseList));

          if (testCaseList.isEmpty())
            optionsDialog.setOptions(OptionsForm.RETURN_PROPERTIES, new String[0]);
          else
            optionsDialog.setOptions(
                OptionsForm.RETURN_PROPERTIES, testCaseList.get(0).getPropertyNames());
        }
      }

      switch (getModelItem().getRunMode().intValue()) {
        case RunTestCaseRunModeTypeConfig.INT_PARALLELL:
          optionsDialog.setValue(
              OptionsForm.RUN_MODE, OptionsForm.CREATE_ISOLATED_COPY_FOR_EACH_RUN);
          break;
        case RunTestCaseRunModeTypeConfig.INT_SINGLETON_AND_FAIL:
          optionsDialog.setValue(OptionsForm.RUN_MODE, OptionsForm.RUN_PRIMARY_TEST_CASE);
          break;
        case RunTestCaseRunModeTypeConfig.INT_SINGLETON_AND_WAIT:
          optionsDialog.setValue(OptionsForm.RUN_MODE, OptionsForm.RUN_SYNCHRONIZED_TESTCASE);
          break;
      }

      optionsDialog.setBooleanValue(
          OptionsForm.COPY_HTTP_SESSION, getModelItem().isCopyHttpSession());
      optionsDialog.setBooleanValue(
          OptionsForm.COPY_LOADTEST_PROPERTIES, getModelItem().isCopyLoadTestProperties());
      optionsDialog.setBooleanValue(
          OptionsForm.IGNORE_EMPTY_PROPERTIES, getModelItem().isIgnoreEmptyProperties());

      if (optionsDialog.show()) {
        WsdlTestSuite testSuite =
            project.getTestSuiteByName(optionsDialog.getValue(OptionsForm.TESTSUITE));
        getModelItem()
            .setTargetTestCase(
                testSuite == null
                    ? null
                    : testSuite.getTestCaseByName(optionsDialog.getValue(OptionsForm.TESTCASE)));
        getModelItem()
            .setReturnProperties(
                new StringList(
                    ((XFormMultiSelectList)
                            optionsDialog.getFormField(OptionsForm.RETURN_PROPERTIES))
                        .getSelectedOptions()));

        switch (optionsDialog.getValueIndex(OptionsForm.RUN_MODE)) {
          case 0:
            getModelItem().setRunMode(RunTestCaseRunModeTypeConfig.PARALLELL);
            break;
          case 1:
            getModelItem().setRunMode(RunTestCaseRunModeTypeConfig.SINGLETON_AND_FAIL);
            break;
          case 2:
            getModelItem().setRunMode(RunTestCaseRunModeTypeConfig.SINGLETON_AND_WAIT);
            break;
        }

        getModelItem()
            .setCopyHttpSession(optionsDialog.getBooleanValue(OptionsForm.COPY_HTTP_SESSION));
        getModelItem()
            .setCopyLoadTestProperties(
                optionsDialog.getBooleanValue(OptionsForm.COPY_LOADTEST_PROPERTIES));
        getModelItem()
            .setIgnoreEmptyProperties(
                optionsDialog.getBooleanValue(OptionsForm.IGNORE_EMPTY_PROPERTIES));

        titledBorder.setTitle(createTitleForBorder());
      }
    }