Package org.apache.jmeter.exceptions

Examples of org.apache.jmeter.exceptions.IllegalUserActionException


  }

  public ReportTreeNode addComponent(TestElement component,
      ReportTreeNode node) throws IllegalUserActionException {
    if (node.getUserObject() instanceof AbstractConfigGui) {
      throw new IllegalUserActionException(
          "This node cannot hold sub-elements");
    }
    component.setProperty(TestElement.GUI_CLASS, NameUpdater
        .getCurrentName(component
            .getPropertyAsString(TestElement.GUI_CLASS)));
View Full Code Here


      System.setProperty("https.proxyHost", h);// $NON-NLS-1$
      System.setProperty("http.proxyPort",  p);// $NON-NLS-1$
      System.setProperty("https.proxyPort", p);// $NON-NLS-1$
      log.info("Set http[s].proxyHost: " + h + " Port: " + p);
    } else if (parser.getArgumentById(PROXY_HOST) != null || parser.getArgumentById(PROXY_PORT) != null) {
      throw new IllegalUserActionException(JMeterUtils.getResString("proxy_cl_error"));// $NON-NLS-1$
    }
       
        if (parser.getArgumentById(NONPROXY_HOSTS) != null) {
            String n = parser.getArgumentById(NONPROXY_HOSTS).getArgument();
            System.setProperty("http.nonProxyHosts",  n );// $NON-NLS-1$
View Full Code Here

                      "remote_hosts", //$NON-NLS-1$
                      "127.0.0.1");//$NON-NLS-1$       
      }
    }
    if (testFile == null) {
      throw new IllegalUserActionException("Non-GUI runs require a test plan");
    }
        if (logFile == null) {
      driver.run(testFile, null, remoteStart != null,remote_hosts_string);
    } else {
      driver.run(testFile, logFile, remoteStart != null,remote_hosts_string);
View Full Code Here

    return getCurrentSubTree(current);
  }

  public JMeterTreeNode addComponent(TestElement component, JMeterTreeNode node) throws IllegalUserActionException {
    if (node.getUserObject() instanceof AbstractConfigGui) {
      throw new IllegalUserActionException("This node cannot hold sub-elements");
    }
    component.setProperty(TestElement.GUI_CLASS, NameUpdater.getCurrentName(component
        .getPropertyAsString(TestElement.GUI_CLASS)));

    GuiPackage guiPackage = GuiPackage.getInstance();
View Full Code Here

  public void doAction(ActionEvent e) throws IllegalUserActionException {
    JMeterGUIComponent component = null;
    JComponent comp = null;
    if (!commands.contains(e.getActionCommand())) {
      throw new IllegalUserActionException("Invalid user command:" + e.getActionCommand());
    }
    if (e.getActionCommand().equals(ActionNames.SAVE_GRAPHICS)) {
      component = GuiPackage.getInstance().getCurrentGui();
      // get the JComponent from the visualizer
      if (component instanceof Printable) {
View Full Code Here

  }

  public void doAction(ActionEvent e) throws IllegalUserActionException {
    HashTree subTree = null;
    if (!commands.contains(e.getActionCommand())) {
      throw new IllegalUserActionException("Invalid user command:" + e.getActionCommand());
    }
    if (e.getActionCommand().equals(ActionNames.SAVE_AS)) {
      JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
      if (nodes.length > 1){
        JMeterUtils.reportErrorToUser(
            JMeterUtils.getResString("save_as_error"), // $NON-NLS-1$
            JMeterUtils.getResString("save_as")); // $NON-NLS-1$
        return;
      }
      subTree = GuiPackage.getInstance().getCurrentSubTree();
    } else {
      subTree = GuiPackage.getInstance().getTreeModel().getTestPlan();
    }

    String updateFile = GuiPackage.getInstance().getTestPlanFile();
    if (!ActionNames.SAVE.equals(e.getActionCommand()) || updateFile == null) {
      JFileChooser chooser = FileDialoger.promptToSaveFile(GuiPackage.getInstance().getTreeListener()
          .getCurrentNode().getName()
          + JMX_FILE_EXTENSION);
      if (chooser == null) {
        return;
      }
      updateFile = chooser.getSelectedFile().getAbsolutePath();
      // Make sure the file ends with proper extension
      if(FilenameUtils.getExtension(updateFile).equals("")) {
        updateFile = updateFile + JMX_FILE_EXTENSION;
      }
      // Check if the user is trying to save to an existing file
      if(!e.getActionCommand().equals(ActionNames.SAVE)) {//so it must be a SAVE_AS action
        File f = new File(updateFile);
        if(f.exists()) {
          int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
              JMeterUtils.getResString("save_overwrite_existing_file"), // $NON-NLS-1$
              JMeterUtils.getResString("save?")// $NON-NLS-1$
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE);
          if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.NO_OPTION) {
            return ; // Do not save, user does not want to overwrite
          }
        }
      }
     
      if (!e.getActionCommand().equals(ActionNames.SAVE_AS)) {
        GuiPackage.getInstance().setTestPlanFile(updateFile);
      }
    }
    // TODO: doesn't putting this here mark the tree as
    // saved even though a failure may occur later?

    ActionRouter.getInstance().doActionNow(new ActionEvent(subTree, e.getID(), ActionNames.SUB_TREE_SAVED));
    try {
      convertSubTree(subTree);
    } catch (Exception err) {
    }
    FileOutputStream ostream = null;
    try {
      ostream = new FileOutputStream(updateFile);
      if (SaveService.isSaveTestPlanFormat20()) {
        OldSaveService.saveSubTree(subTree, ostream);
      } else {
        SaveService.saveTree(subTree, ostream);
      }
    } catch (Throwable ex) {
      GuiPackage.getInstance().setTestPlanFile(null);
      log.error("", ex);
      throw new IllegalUserActionException("Couldn't save test plan to file: " + updateFile);
    } finally {
            JOrphanUtils.closeQuietly(ostream);
    }
        GuiPackage.getInstance().updateCurrentGui();
  }
View Full Code Here

        boolean ok = MenuFactory.canAddTo(guiInstance.getCurrentNode(), te);
        if (!ok){
          String name = te.getName();
          String className = te.getClass().getName();
          className = className.substring(className.lastIndexOf(".")+1);
          throw new IllegalUserActionException("Can't merge "+name+" ("+className+") here");
        }       
      }
    }
    HashTree newTree = guiInstance.addSubTree(tree);
    guiInstance.updateCurrentGui();
View Full Code Here

            System.setProperty("https.proxyHost", h);// $NON-NLS-1$
            System.setProperty("http.proxyPort",  p);// $NON-NLS-1$
            System.setProperty("https.proxyPort", p);// $NON-NLS-1$
            log.info("Set http[s].proxyHost: " + h + " Port: " + p);
        } else if (parser.getArgumentById(PROXY_HOST) != null || parser.getArgumentById(PROXY_PORT) != null) {
            throw new IllegalUserActionException(JMeterUtils.getResString("proxy_cl_error"));// $NON-NLS-1$
        }

        if (parser.getArgumentById(NONPROXY_HOSTS) != null) {
            String n = parser.getArgumentById(NONPROXY_HOSTS).getArgument();
            System.setProperty("http.nonProxyHosts",  n );// $NON-NLS-1$
View Full Code Here

                        "remote_hosts", //$NON-NLS-1$
                        "127.0.0.1");//$NON-NLS-1$
            }
        }
        if (testFile == null) {
            throw new IllegalUserActionException("Non-GUI runs require a test plan");
        }
        driver.runNonGui(testFile, logFile, remoteStart != null, remote_hosts_string);
    }
View Full Code Here

    @Override
    public void doAction(ActionEvent e) throws IllegalUserActionException {
        HashTree subTree = null;
        boolean fullSave = false; // are we saving the whole tree?
        if (!commands.contains(e.getActionCommand())) {
            throw new IllegalUserActionException("Invalid user command:" + e.getActionCommand());
        }
        if (e.getActionCommand().equals(ActionNames.SAVE_AS)) {
            JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
            if (nodes.length > 1){
                JMeterUtils.reportErrorToUser(
                        JMeterUtils.getResString("save_as_error"), // $NON-NLS-1$
                        JMeterUtils.getResString("save_as")); // $NON-NLS-1$
                return;
            }
            subTree = GuiPackage.getInstance().getCurrentSubTree();
        } else {
            fullSave = true;
            HashTree testPlan = GuiPackage.getInstance().getTreeModel().getTestPlan();
            // If saveWorkBench
            JMeterTreeNode workbenchNode = (JMeterTreeNode) ((JMeterTreeNode) GuiPackage.getInstance().getTreeModel().getRoot()).getChildAt(1);
            if (((WorkBench)workbenchNode.getUserObject()).getSaveWorkBench()) {
                HashTree workbench = GuiPackage.getInstance().getTreeModel().getWorkBench();
                testPlan.add(workbench);
            }
            subTree = testPlan;
        }

        String updateFile = GuiPackage.getInstance().getTestPlanFile();
        if (!ActionNames.SAVE.equals(e.getActionCommand()) || updateFile == null) {
            JFileChooser chooser = FileDialoger.promptToSaveFile(updateFile == null ? GuiPackage.getInstance().getTreeListener()
                    .getCurrentNode().getName()
                    + JMX_FILE_EXTENSION : updateFile);
            if (chooser == null) {
                return;
            }
            updateFile = chooser.getSelectedFile().getAbsolutePath();
            // Make sure the file ends with proper extension
            if(FilenameUtils.getExtension(updateFile).equals("")) {
                updateFile = updateFile + JMX_FILE_EXTENSION;
            }
            // Check if the user is trying to save to an existing file
            File f = new File(updateFile);
            if(f.exists()) {
                int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
                        JMeterUtils.getResString("save_overwrite_existing_file"), // $NON-NLS-1$
                        JMeterUtils.getResString("save?")// $NON-NLS-1$
                        JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE);
                if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.NO_OPTION) {
                    return ; // Do not save, user does not want to overwrite
                }
            }

            if (!e.getActionCommand().equals(ActionNames.SAVE_AS)) {
                GuiPackage.getInstance().setTestPlanFile(updateFile);
            }
        }

        try {
            convertSubTree(subTree);
        } catch (Exception err) {
            log.warn("Error converting subtree "+err);
        }

        FileOutputStream ostream = null;
        try {
            ostream = new FileOutputStream(updateFile);
            SaveService.saveTree(subTree, ostream);
            if (fullSave) { // Only update the stored copy of the tree for a full save
                subTree = GuiPackage.getInstance().getTreeModel().getTestPlan(); // refetch, because convertSubTree affects it
                ActionRouter.getInstance().doActionNow(new ActionEvent(subTree, e.getID(), ActionNames.SUB_TREE_SAVED));
            }
        } catch (Throwable ex) {
            log.error("Error saving tree:", ex);
            if (ex instanceof Error){
                throw (Error) ex;
            }
            if (ex instanceof RuntimeException){
                throw (RuntimeException) ex;
            }
            throw new IllegalUserActionException("Couldn't save test plan to file: " + updateFile, ex);
        } finally {
            JOrphanUtils.closeQuietly(ostream);
        }
        GuiPackage.getInstance().updateCurrentGui();
    }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.exceptions.IllegalUserActionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.