コード例 #1
0
  void createJMeterSuitePerformed() {
    Project pProject = DataModel.getCurrentProject();
    TestList pTestList = null;
    Family pFamily = null;
    Test pTest = null;
    DefaultMutableTreeNode pNode = SalomeTMFPanels.getTestDynamicTree().getSelectedNode();
    if (pNode == null) {
      return;
    } else {
      SimpleData pData = (SimpleData) pNode.getUserObject();
      if (pData instanceof Family) {
        pFamily = (Family) pData;
      } else if (pData instanceof TestList) {
        pTestList = (TestList) pData;
      } else if (pData instanceof Test) {
        pTest = (Test) pData;
      }
    }

    if (pTestList != null) {
      Util.log("Test List selected = " + pTestList.getNameFromModel());
      JMeterTester pMeterTester = new JMeterTester(null, true, pProject, true, "", "", "", "");
      if (pMeterTester.execute()) {
        Util.log("[JMeterIntegrationPlugin:editTest] ok pressed");
        Attachment pNewattach = pMeterTester.getNewAttachment();
        Attachment pSelectedattach = pMeterTester.getSelectedAttachment();
        String toWrite = "attachment_id = ";
        if (pSelectedattach != null) {
          if (pSelectedattach.equals(pNewattach)) {
            if (!addAttachmentToProject(pNewattach, DataModel.getCurrentProject())) return;
          }
          toWrite += pSelectedattach.getIdBdd() + "\n";
          toWrite += "attachment_name = " + pSelectedattach.getNameFromModel() + "\n";
        } else {
          toWrite += "\nattachment_name = \n";
        }
        toWrite += "junit_class = " + pMeterTester.getJunitClass() + "\n";

        try {
          if (!pTestList.isInBase()) {
            pTestList.updateInModel(pMeterTester.getJunitClass(), "JMETER TEST SUITE");
            pFamily.addTestListInDB(pTestList);
          }
          // currentJunitAnalyser.createJunitTest(pSelectedattach,
          //		pJunitTester.getJunitClass(), pTestList, toWrite);
        } catch (Exception e1) {
          Tools.ihmExceptionView(e1);
        }
      }
    }
  }
コード例 #2
0
 /** ******************* interface common ******************* */
 String getTestName(String name, TestList pSuite, int index) {
   if (pSuite.getTestFromModel(name) != null) {
     index++;
     name = name + index;
     return getTestName(name, pSuite, index);
   } else {
     return name;
   }
 }
コード例 #3
0
  void addTest(String name, String description, String[] idReqs, TestList pSuite, String toWrite) {
    name = getTestName(name, pSuite, 0);
    AutomaticTest pTest = new AutomaticTest(name, description, id_plugin);
    pTest.setConceptorLoginInModel(DataModel.getCurrentUser().getLoginFromModel());
    if (Api.isConnected()) {
      try {
        pSuite.addTestInDBAndModel(pTest);
      } catch (Exception e1) {
        Tools.ihmExceptionView(e1);
        return;
      }
    }
    File file = null;
    try {
      Util.log("[JMeterIntegrationPlugin:AddTest] Create test Script file");
      file = writeJunitFile(null, pTest, toWrite);
    } catch (Exception e2) {
      Tools.ihmExceptionView(e2);
      e2.printStackTrace();
      return;
    }
    Script pScript = new Script(file.getName(), "Junit test script");
    pScript.setLocalisation(file.getAbsolutePath());
    pScript.setTypeInModel(ApiConstants.TEST_SCRIPT);
    pScript.setScriptExtensionInModel(pTest.getExtensionFromModel());
    // pScript.setPlugArg("");

    if (Api.isConnected()) {
      try {
        pTest.addScriptInDBAndModel(pScript, file);
        Util.log(
            "[JMeterIntegrationPlugin:AddTest] Add Script : "
                + pScript.getNameFromModel()
                + " to DB & Model");
      } catch (Exception e3) {
        Tools.ihmExceptionView(e3);
        return;
      }
    }

    // add associated requirements
    Vector<ReqManager> reqManagers = pIPlugObject.getReqManagers();
    for (ReqManager reqManager : reqManagers) {
      for (String idReqString : idReqs) {
        int idReq = new Integer(idReqString).intValue();
        reqManager.addReqLinkWithTest(pTest, idReq);
      }
    }
  }