コード例 #1
0
  /** @see salome.plugins.core.TestDriver */
  public int runTest(
      String testScript,
      org.objectweb.salome_tmf.data.AutomaticTest pTest,
      Hashtable argTest,
      String plugArg)
      throws Exception {
    File pFile = new File(testScript);
    FileInputStream pFileInputStream = new FileInputStream(pFile);
    Properties test_prop = new Properties();
    test_prop.load(pFileInputStream);
    String strID = test_prop.getProperty("attachment_id");
    String strAttachment = test_prop.getProperty("attachment_name");
    String strClass = test_prop.getProperty("junit_class");
    String meth = test_prop.getProperty("test_meth");
    String version = test_prop.getProperty("junit_version");
    pFileInputStream.close();
    Util.log("[JMeterIntegrationPlugin:runTest] attachment_id = " + strID);
    Util.log("[JMeterIntegrationPlugin:runTest] attachment_name = " + strAttachment);
    Util.log("[JMeterIntegrationPlugin:runTest] junit_class = " + strClass);
    Util.log("[JMeterIntegrationPlugin:runTest] test_meth = " + meth);
    Util.log("[JMeterIntegrationPlugin:runTest] junit_version = " + version);

    return 0; // currentJunitAnalyser.runTest(strID, strAttachment,
    // strClass, meth, testScript, pTest, argTest, plugArg);
  }
コード例 #2
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);
        }
      }
    }
  }
コード例 #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);
      }
    }
  }
コード例 #4
0
 File writeJunitFile(
     File pFile, org.objectweb.salome_tmf.data.AutomaticTest pTest, String toWtrite)
     throws Exception {
   String fileName;
   if (pFile == null) {
     Properties sys = System.getProperties();
     String tmpDir = sys.getProperty("java.io.tmpdir");
     String fs = sys.getProperty("file.separator");
     fileName = tmpDir + fs + pTest.getNameFromModel() + ".junit";
     pFile = new File(fileName);
   } else {
     fileName = pFile.getAbsolutePath();
     pFile.delete();
     pFile.createNewFile();
   }
   Util.log("[JMeterIntegrationPlugin:writeJunitFile] write " + toWtrite + ", in " + fileName);
   FileOutputStream fos = new FileOutputStream(pFile);
   BufferedOutputStream bos = new BufferedOutputStream(fos);
   byte[] b = toWtrite.getBytes();
   bos.write(b, 0, b.length);
   bos.flush();
   bos.close();
   // return null;
   return pFile;
 }
コード例 #5
0
 java.io.File ChoiceOrEdit(
     AutomaticTest pTest,
     boolean choice,
     File pFile,
     String strID,
     String strAttachment,
     String strClass,
     String meth,
     String version) {
   JMeterTester pJMeterTester =
       new JMeterTester(null, true, pTest, choice, strID, strAttachment, strClass, meth, version);
   if (pJMeterTester.execute()) {
     Util.log("[JMeterIntegrationPlugin:editTest] ok pressed");
     Attachment pNewattach = pJMeterTester.getNewAttachment();
     Attachment pSelectedattach = pJMeterTester.getSelectedAttachment();
     String toWrite = "attachment_id = ";
     if (pSelectedattach != null) {
       if (pSelectedattach.equals(pNewattach)) {
         if (!addAttachmentToProject(pNewattach, DataModel.getCurrentProject())) return null;
       }
       toWrite += pSelectedattach.getIdBdd() + "\n";
       toWrite += "attachment_name = " + pSelectedattach.getNameFromModel() + "\n";
     } else {
       toWrite += "\nattachment_name = \n";
     }
     toWrite += "junit_class = " + pJMeterTester.getJunitClass() + "\n";
     toWrite += "test_meth = " + pJMeterTester.getJunitMeth() + "\n";
     if (version != null) {
       toWrite += "junit_version = " + version + "\n";
       version = version.trim();
     }
     try {
       File f = writeJunitFile(pFile, pTest, toWrite);
       return f;
     } catch (Exception e) {
       Tools.ihmExceptionView(e);
       e.printStackTrace();
       return null;
     }
   } else {
     Util.log("[JMeterIntegrationPlugin:editTest] cancel pressed");
     return null;
   }
 }
コード例 #6
0
  boolean addAttachmentToProject(Attachment pAttach, Project pProject) {
    if (Api.isConnected()) {
      try {
        pProject.addAttachementInDBAndModel(pAttach);
        Util.log(
            "[JMeterIntegrationPlugin:addAttachmentToSuite] add attach in DB & model : " + pAttach);

      } catch (Exception exception) {
        Tools.ihmExceptionView(exception);
        return false;
      }
    }

    return true;
  }
コード例 #7
0
 /** @see org.java.plugin.Plugin() */
 protected void doStart() throws Exception {
   Util.log("[JMeterIntegrationPlugin:doStart] chargement du plugin");
 }
コード例 #8
0
 /** @see salome.plugins.core.TestDriver */
 public void getHelp() {
   Util.log("JMeter TestDriver");
 }