Beispiel #1
0
        // Update classloader if necessary
        //private void updateClassLoader()
        //{
        //    updatePath("search_paths",";"); //$NON-NLS-1$//$NON-NLS-2$
        //    updatePath("user.classpath",File.pathSeparator);//$NON-NLS-1$
        //}

        //private void updatePath(String property, String sep)
        //{
        //    String userpath= NetMeterUtils.getPropDefault(property,"");// $NON-NLS-1$
        //    if (userpath.Length <= 0) { return; }
        //    log.Info(property+"="+userpath); //$NON-NLS-1$
        //    StringTokenizer tok = new StringTokenizer(userpath, sep);
        //    while(tok.hasMoreTokens())
        //    {
        //        String path=tok.nextToken();
        //        File f=new File(path);
        //        if (!f.canRead() && !f.isDirectory())
        //        {
        //            log.Warn("Can't read "+path);
        //        }
        //        else
        //        {
        //            log.Info("Adding to classpath: "+path);
        //            try
        //            {
        //                NewDriver.addPath(path);
        //            }
        //            catch (MalformedURLException e)
        //            {
        //                log.Warn("Error adding: "+path+" "+e.getLocalizedMessage());
        //            }
        //        }
        //    }
        //}

        //private void initializeProperties(CLArgsParser parser)
        //{
        //    if (parser.GetArgumentById(PROPFILE_OPT) != null)
        //    {
        //        NetMeterUtils.loadJMeterProperties(parser.GetArgumentById(PROPFILE_OPT).GetArgument());
        //    }
        //    else
        //    {
        //        NetMeterUtils.loadJMeterProperties(NewDriver.getJMeterDir() + File.separator
        //                + "bin" + File.separator // $NON-NLS-1$
        //                + "jmeter.properties");// $NON-NLS-1$
        //    }

        //    if (parser.GetArgumentById(JMLOGFILE_OPT) != null){
        //        String jmlogfile=parser.GetArgumentById(JMLOGFILE_OPT).GetArgument();
        //        jmlogfile = processLAST(jmlogfile, ".log");// $NON-NLS-1$
        //        NetMeterUtils.setProperty(LoggingManager.LOG_FILE,jmlogfile);
        //    }

        //    NetMeterUtils.initLogging();
        //    // Bug 33845 - allow direct override of Home dir
        //    if (parser.GetArgumentById(JMETER_HOME_OPT) == null) {
        //        NetMeterUtils.setJMeterHome(NewDriver.getJMeterDir());
        //    } else {
        //        NetMeterUtils.setJMeterHome(parser.GetArgumentById(JMETER_HOME_OPT).GetArgument());
        //    }

        //    Properties jmeterProps = NetMeterUtils.getJMeterProperties();
        //    remoteProps = new Properties();

        //    // Add local JMeter properties, if the file is found
        //    String userProp = NetMeterUtils.getPropDefault("user.properties",""); //$NON-NLS-1$
        //    if (userProp.length() > 0){ //$NON-NLS-1$
        //        FileInputStream fis=null;
        //        try {
        //            File file = NetMeterUtils.findFile(userProp);
        //            if (file.canRead()){
        //                log.Info("Loading user properties from: "+file.getCanonicalPath());
        //                fis = new FileInputStream(file);
        //                Properties tmp = new Properties();
        //                tmp.load(fis);
        //                jmeterProps.putAll(tmp);
        //                LoggingManager.setLoggingLevels(tmp);//Do what would be done earlier
        //            }
        //        }
        //        catch (IOException e)
        //        {
        //            log.Warn("Error loading user property file: " + userProp, e);
        //        }
        //        finally
        //        {
        //            JOrphanUtils.closeQuietly(fis);
        //        }
        //    }

        //    // Add local system properties, if the file is found
        //    String sysProp = NetMeterUtils.getPropDefault("system.properties",""); //$NON-NLS-1$
        //    if (sysProp.length() > 0)
        //    {
        //        FileInputStream fis=null;
        //        try
        //        {
        //            File file = NetMeterUtils.findFile(sysProp);
        //            if (file())
        //            {
        //                log.Info("Loading system properties from: "+file.getCanonicalPath());
        //                fis = new FileInputStream(file);
        //                System.getProperties().load(fis);
        //            }
        //        }
        //        catch (IOException e)
        //        {
        //            log.Warn("Error loading system property file: " + sysProp, e);
        //        } finally {
        //            JOrphanUtils.closeQuietly(fis);
        //        }
        //    }

        //    // Process command line property definitions
        //    // These can potentially occur multiple times

        //    List<CLOption> clOptions = parser.GetArguments();
        //    int size = clOptions.Count;

        //    for (int i = 0; i < size; i++)
        //    {
        //        CLOption option = clOptions[i];
        //        String name = option.GetArgument(0);
        //        String value = option.GetArgument(1);
        //        FileInputStream fis = null;

        //        switch (option.GetDescriptor().GetId())
        //        {

        //        // Should not have any text arguments
        //        case CLOption.TEXT_ARGUMENT:
        //            throw new IllegalArgumentException("Unknown arg: "+option.GetArgument());

        //        case PROPFILE2_OPT: // Bug 33920 - allow multiple props
        //            try
        //            {
        //                fis = new FileInputStream(new File(name));
        //                Properties tmp = new Properties();
        //                tmp.load(fis);
        //                jmeterProps.putAll(tmp);
        //                LoggingManager.setLoggingLevels(tmp);//Do what would be done earlier
        //            }
        //            catch (FileNotFoundException e)
        //            {
        //                log.Warn("Can't find additional property file: " + name, e);
        //            }
        //            catch (IOException e)
        //            {
        //                log.Warn("Error loading additional property file: " + name, e);
        //            }
        //            finally
        //            {
        //                JOrphanUtils.closeQuietly(fis);
        //            }
        //            break;
        //        case SYSTEM_PROPFILE:
        //            log.Info("Setting System properties from file: " + name);
        //            try
        //            {
        //                fis = new FileInputStream(new File(name));
        //                System.getProperties().load(fis);
        //            }
        //            catch (IOException e)
        //            {
        //                log.Warn("Cannot find system property file "+e.getLocalizedMessage());
        //            }
        //            finally
        //            {
        //                JOrphanUtils.closeQuietly(fis);
        //            }
        //            break;
        //        case SYSTEM_PROPERTY:
        //            if (value.length() > 0)
        //            { // Set it
        //                log.Info("Setting System property: " + name + "=" + value);
        //                System.getProperties().setProperty(name, value);
        //            }
        //            else
        //            { // Reset it
        //                log.Warn("Removing System property: " + name);
        //                System.getProperties().remove(name);
        //            }
        //            break;
        //        case JMETER_PROPERTY:
        //            if (value.length() > 0) { // Set it
        //                log.Info("Setting JMeter property: " + name + "=" + value);
        //                jmeterProps.setProperty(name, value);
        //            } else { // Reset it
        //                log.Warn("Removing JMeter property: " + name);
        //                jmeterProps.remove(name);
        //            }
        //            break;
        //        case JMETER_GLOBAL_PROP:
        //            if (value.length() > 0) { // Set it
        //                log.Info("Setting Global property: " + name + "=" + value);
        //                remoteProps.setProperty(name, value);
        //            } else {
        //                File propFile = new File(name);
        //                if (propFile.canRead()) {
        //                    log.Info("Setting Global properties from the file " + name);
        //                    try
        //                    {
        //                        fis = new FileInputStream(propFile);
        //                        remoteProps.load(fis);
        //                    }
        //                    catch (FileNotFoundException e)
        //                    {
        //                        log.Warn("Could not find properties file: "+e.Message);
        //                    }
        //                    catch (IOException e)
        //                    {
        //                        log.Warn("Could not load properties file: " + e.Message);
        //                    }
        //                    finally
        //                    {
        //                        JOrphanUtils.closeQuietly(fis);
        //                    }
        //                }
        //            }
        //            break;
        //        case LOGLEVEL:
        //            if (value.Length > 0)
        //            { // Set category
        //                log.Info("LogLevel: " + name + "=" + value);
        //                LoggingManager.setPriority(value, name);
        //            } else { // Set root level
        //                log.Warn("LogLevel: " + name);
        //                LoggingManager.setPriority(name);
        //            }
        //            break;
        //        case REMOTE_STOP:
        //            remoteStop = true;
        //            break;
        //        default:
        //            // ignored
        //            break;
        //        }
        //    }

        //    String sample_variables = (String) jmeterProps.get(SampleEvent.SAMPLE_VARIABLES);
        //    if (sample_variables != null){
        //        remoteProps.put(SampleEvent.SAMPLE_VARIABLES, sample_variables);
        //    }
        //    jmeterProps.put("jmeter.version", NetMeterUtils.getJMeterVersion());
        //}

        /*
         * Checks for LAST or LASTsuffix.
         * Returns the LAST name with .JMX replaced by suffix.
         */
        //private String processLAST(String jmlogfile, String suffix)
        //{
        //    if (USE_LAST_JMX.Equals(jmlogfile) || USE_LAST_JMX.concat(suffix).equals(jmlogfile)){
        //        String last = LoadRecentProject.getRecentFile(0);// most recent
        //        String JMX_SUFFIX = ".JMX"; // $NON-NLS-1$
        //        if (last.ToUpper().EndsWith(JMX_SUFFIX))
        //        {
        //            jmlogfile = last.Substring(0, last.Length - JMX_SUFFIX.Length).concat(suffix);
        //        }
        //    }
        //    return jmlogfile;
        //}

        private void StartTest(String testFile, String logFile, CLOption remoteStart)
        {
            // add a system property so samplers can check to see if JMeter
            // is running in NonGui mode
            //System.setProperty(JMETER_NON_GUI, "true");// $NON-NLS-1$
            NetMeterServer driver = new NetMeterServer();// TODO - why does it create a new instance?

            driver.remoteProps = this.remoteProps;
            driver.remoteStop  = this.remoteStop;
            driver.parent      = this;

            String remote_hosts_string = null;

            if (remoteStart != null)
            {
                remote_hosts_string = remoteStart.GetArgument();
                if (remote_hosts_string == null)
                {
                    remote_hosts_string = "127.0.0.1";
                }
            }
            if (testFile == null)
            {
                throw new Exception("Non-GUI runs require a test plan");
            }
            driver.RunTest(testFile, logFile, remoteStart != null, remote_hosts_string);
        }
Beispiel #2
0
            private Int64 started = 0; // keep track of remote tests

            #endregion Fields

            #region Constructors

            /**
             * @param unused JMeter unused for now
             * @param engines List<JMeterEngine>
             */
            public ListenToTest(NetMeterServer unused, LinkedList<NetMeterEngine> engines)
            {
                //_parent = unused;
                this.engines = engines;
            }
Beispiel #3
0
        // Update classloader if necessary
        //private void updateClassLoader()
        //{
        //    updatePath("search_paths",";"); //$NON-NLS-1$//$NON-NLS-2$
        //    updatePath("user.classpath",File.pathSeparator);//$NON-NLS-1$
        //}
        //private void updatePath(String property, String sep)
        //{
        //    String userpath= NetMeterUtils.getPropDefault(property,"");// $NON-NLS-1$
        //    if (userpath.Length <= 0) { return; }
        //    log.Info(property+"="+userpath); //$NON-NLS-1$
        //    StringTokenizer tok = new StringTokenizer(userpath, sep);
        //    while(tok.hasMoreTokens())
        //    {
        //        String path=tok.nextToken();
        //        File f=new File(path);
        //        if (!f.canRead() && !f.isDirectory())
        //        {
        //            log.Warn("Can't read "+path);
        //        }
        //        else
        //        {
        //            log.Info("Adding to classpath: "+path);
        //            try
        //            {
        //                NewDriver.addPath(path);
        //            }
        //            catch (MalformedURLException e)
        //            {
        //                log.Warn("Error adding: "+path+" "+e.getLocalizedMessage());
        //            }
        //        }
        //    }
        //}
        //private void initializeProperties(CLArgsParser parser)
        //{
        //    if (parser.GetArgumentById(PROPFILE_OPT) != null)
        //    {
        //        NetMeterUtils.loadJMeterProperties(parser.GetArgumentById(PROPFILE_OPT).GetArgument());
        //    }
        //    else
        //    {
        //        NetMeterUtils.loadJMeterProperties(NewDriver.getJMeterDir() + File.separator
        //                + "bin" + File.separator // $NON-NLS-1$
        //                + "jmeter.properties");// $NON-NLS-1$
        //    }
        //    if (parser.GetArgumentById(JMLOGFILE_OPT) != null){
        //        String jmlogfile=parser.GetArgumentById(JMLOGFILE_OPT).GetArgument();
        //        jmlogfile = processLAST(jmlogfile, ".log");// $NON-NLS-1$
        //        NetMeterUtils.setProperty(LoggingManager.LOG_FILE,jmlogfile);
        //    }
        //    NetMeterUtils.initLogging();
        //    // Bug 33845 - allow direct override of Home dir
        //    if (parser.GetArgumentById(JMETER_HOME_OPT) == null) {
        //        NetMeterUtils.setJMeterHome(NewDriver.getJMeterDir());
        //    } else {
        //        NetMeterUtils.setJMeterHome(parser.GetArgumentById(JMETER_HOME_OPT).GetArgument());
        //    }
        //    Properties jmeterProps = NetMeterUtils.getJMeterProperties();
        //    remoteProps = new Properties();
        //    // Add local JMeter properties, if the file is found
        //    String userProp = NetMeterUtils.getPropDefault("user.properties",""); //$NON-NLS-1$
        //    if (userProp.length() > 0){ //$NON-NLS-1$
        //        FileInputStream fis=null;
        //        try {
        //            File file = NetMeterUtils.findFile(userProp);
        //            if (file.canRead()){
        //                log.Info("Loading user properties from: "+file.getCanonicalPath());
        //                fis = new FileInputStream(file);
        //                Properties tmp = new Properties();
        //                tmp.load(fis);
        //                jmeterProps.putAll(tmp);
        //                LoggingManager.setLoggingLevels(tmp);//Do what would be done earlier
        //            }
        //        }
        //        catch (IOException e)
        //        {
        //            log.Warn("Error loading user property file: " + userProp, e);
        //        }
        //        finally
        //        {
        //            JOrphanUtils.closeQuietly(fis);
        //        }
        //    }
        //    // Add local system properties, if the file is found
        //    String sysProp = NetMeterUtils.getPropDefault("system.properties",""); //$NON-NLS-1$
        //    if (sysProp.length() > 0)
        //    {
        //        FileInputStream fis=null;
        //        try
        //        {
        //            File file = NetMeterUtils.findFile(sysProp);
        //            if (file())
        //            {
        //                log.Info("Loading system properties from: "+file.getCanonicalPath());
        //                fis = new FileInputStream(file);
        //                System.getProperties().load(fis);
        //            }
        //        }
        //        catch (IOException e)
        //        {
        //            log.Warn("Error loading system property file: " + sysProp, e);
        //        } finally {
        //            JOrphanUtils.closeQuietly(fis);
        //        }
        //    }
        //    // Process command line property definitions
        //    // These can potentially occur multiple times
        //    List<CLOption> clOptions = parser.GetArguments();
        //    int size = clOptions.Count;
        //    for (int i = 0; i < size; i++)
        //    {
        //        CLOption option = clOptions[i];
        //        String name = option.GetArgument(0);
        //        String value = option.GetArgument(1);
        //        FileInputStream fis = null;
        //        switch (option.GetDescriptor().GetId())
        //        {
        //        // Should not have any text arguments
        //        case CLOption.TEXT_ARGUMENT:
        //            throw new IllegalArgumentException("Unknown arg: "+option.GetArgument());
        //        case PROPFILE2_OPT: // Bug 33920 - allow multiple props
        //            try
        //            {
        //                fis = new FileInputStream(new File(name));
        //                Properties tmp = new Properties();
        //                tmp.load(fis);
        //                jmeterProps.putAll(tmp);
        //                LoggingManager.setLoggingLevels(tmp);//Do what would be done earlier
        //            }
        //            catch (FileNotFoundException e)
        //            {
        //                log.Warn("Can't find additional property file: " + name, e);
        //            }
        //            catch (IOException e)
        //            {
        //                log.Warn("Error loading additional property file: " + name, e);
        //            }
        //            finally
        //            {
        //                JOrphanUtils.closeQuietly(fis);
        //            }
        //            break;
        //        case SYSTEM_PROPFILE:
        //            log.Info("Setting System properties from file: " + name);
        //            try
        //            {
        //                fis = new FileInputStream(new File(name));
        //                System.getProperties().load(fis);
        //            }
        //            catch (IOException e)
        //            {
        //                log.Warn("Cannot find system property file "+e.getLocalizedMessage());
        //            }
        //            finally
        //            {
        //                JOrphanUtils.closeQuietly(fis);
        //            }
        //            break;
        //        case SYSTEM_PROPERTY:
        //            if (value.length() > 0)
        //            { // Set it
        //                log.Info("Setting System property: " + name + "=" + value);
        //                System.getProperties().setProperty(name, value);
        //            }
        //            else
        //            { // Reset it
        //                log.Warn("Removing System property: " + name);
        //                System.getProperties().remove(name);
        //            }
        //            break;
        //        case JMETER_PROPERTY:
        //            if (value.length() > 0) { // Set it
        //                log.Info("Setting JMeter property: " + name + "=" + value);
        //                jmeterProps.setProperty(name, value);
        //            } else { // Reset it
        //                log.Warn("Removing JMeter property: " + name);
        //                jmeterProps.remove(name);
        //            }
        //            break;
        //        case JMETER_GLOBAL_PROP:
        //            if (value.length() > 0) { // Set it
        //                log.Info("Setting Global property: " + name + "=" + value);
        //                remoteProps.setProperty(name, value);
        //            } else {
        //                File propFile = new File(name);
        //                if (propFile.canRead()) {
        //                    log.Info("Setting Global properties from the file " + name);
        //                    try
        //                    {
        //                        fis = new FileInputStream(propFile);
        //                        remoteProps.load(fis);
        //                    }
        //                    catch (FileNotFoundException e)
        //                    {
        //                        log.Warn("Could not find properties file: "+e.Message);
        //                    }
        //                    catch (IOException e)
        //                    {
        //                        log.Warn("Could not load properties file: " + e.Message);
        //                    }
        //                    finally
        //                    {
        //                        JOrphanUtils.closeQuietly(fis);
        //                    }
        //                }
        //            }
        //            break;
        //        case LOGLEVEL:
        //            if (value.Length > 0)
        //            { // Set category
        //                log.Info("LogLevel: " + name + "=" + value);
        //                LoggingManager.setPriority(value, name);
        //            } else { // Set root level
        //                log.Warn("LogLevel: " + name);
        //                LoggingManager.setPriority(name);
        //            }
        //            break;
        //        case REMOTE_STOP:
        //            remoteStop = true;
        //            break;
        //        default:
        //            // ignored
        //            break;
        //        }
        //    }
        //    String sample_variables = (String) jmeterProps.get(SampleEvent.SAMPLE_VARIABLES);
        //    if (sample_variables != null){
        //        remoteProps.put(SampleEvent.SAMPLE_VARIABLES, sample_variables);
        //    }
        //    jmeterProps.put("jmeter.version", NetMeterUtils.getJMeterVersion());
        //}
        /*
         * Checks for LAST or LASTsuffix.
         * Returns the LAST name with .JMX replaced by suffix.
         */
        //private String processLAST(String jmlogfile, String suffix)
        //{
        //    if (USE_LAST_JMX.Equals(jmlogfile) || USE_LAST_JMX.concat(suffix).equals(jmlogfile)){
        //        String last = LoadRecentProject.getRecentFile(0);// most recent
        //        String JMX_SUFFIX = ".JMX"; // $NON-NLS-1$
        //        if (last.ToUpper().EndsWith(JMX_SUFFIX))
        //        {
        //            jmlogfile = last.Substring(0, last.Length - JMX_SUFFIX.Length).concat(suffix);
        //        }
        //    }
        //    return jmlogfile;
        //}
        private void StartTest(String testFile, String logFile, CLOption remoteStart)
        {
            // add a system property so samplers can check to see if JMeter
            // is running in NonGui mode
            //System.setProperty(JMETER_NON_GUI, "true");// $NON-NLS-1$
            NetMeterServer driver = new NetMeterServer();// TODO - why does it create a new instance?
            driver.remoteProps = this.remoteProps;
            driver.remoteStop = this.remoteStop;
            driver.parent = this;

            String remote_hosts_string = null;
            if (remoteStart != null)
            {
                remote_hosts_string = remoteStart.GetArgument();
                if (remote_hosts_string == null)
                {
                    remote_hosts_string = "127.0.0.1";
                }
            }
            if (testFile == null)
            {
                throw new Exception("Non-GUI runs require a test plan");
            }
            driver.RunTest(testFile, logFile, remoteStart != null, remote_hosts_string);
        }
Beispiel #4
0
 /**
  * @param unused JMeter unused for now
  * @param engines List<JMeterEngine>
  */
 public ListenToTest(NetMeterServer unused, LinkedList <NetMeterEngine> engines)
 {
     //_parent = unused;
     this.engines = engines;
 }