Examples of JMeterContext


Examples of org.apache.jmeter.threads.JMeterContext

            } catch (ClassNotFoundException e) {
                log.error("Cannot reset BeanShell: "+e.toString());
            }
        }

        JMeterContext jmctx = JMeterContextService.getContext();
        JMeterVariables vars = jmctx.getVariables();

        try {
            bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
            bshInterpreter.set("Label", getName()); //$NON-NLS-1$
            bshInterpreter.set("prev", jmctx.getPreviousResult());//$NON-NLS-1$
            bshInterpreter.set("props", JMeterUtils.getJMeterProperties());
            bshInterpreter.set("vars", vars);//$NON-NLS-1$
        } catch (JMeterException e) {
            log.warn("Problem setting one or more BeanShell variables "+e);
        }
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

    /**
     * Modifies an Entry object based on HTML response text.
     */
    @Override
    public void process() {
        JMeterContext context = getThreadContext();
        Sampler sam = context.getCurrentSampler();
        SampleResult res = context.getPreviousResult();
        HTTPSamplerBase sampler = null;
        HTTPSampleResult result = null;
        if (res == null || !(sam instanceof HTTPSamplerBase) || !(res instanceof HTTPSampleResult)) {
            log.info("Can't apply HTML Link Parser when the previous" + " sampler run is not an HTTP Request.");
            return;
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

     *
     * @see org.apache.jmeter.processor.PostProcessor#process()
     */
    @Override
    public void process() {
        JMeterContext context = getThreadContext();
        SampleResult previousResult = context.getPreviousResult();
        if (previousResult == null) {
            return;
        }
        log.debug("HtmlExtractor processing result");

        // Fetch some variables
        JMeterVariables vars = context.getVariables();
       
        String refName = getRefName();
        String expression = getExpression();
        String attribute = getAttribute();
        int matchNumber = getMatchNumber();
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

        bindings.put("FileName", fileName);
        bindings.put("Parameters", scriptParameters);
        String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
        bindings.put("args", args);
        // Add variables for access to context and variables
        JMeterContext jmctx = JMeterContextService.getContext();
        bindings.put("ctx", jmctx);
        JMeterVariables vars = jmctx.getVariables();
        bindings.put("vars", vars);
        Properties props = JMeterUtils.getJMeterProperties();
        bindings.put("props", props);
        // For use in debugging:
        bindings.put("OUT", System.out);

        // Most subclasses will need these:
        Sampler sampler = jmctx.getCurrentSampler();
        bindings.put("sampler", sampler);
        SampleResult prev = jmctx.getPreviousResult();
        bindings.put("prev", prev);
    }
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

        mgr.declareBean("FileName",fileName, String.class); // $NON-NLS-1$
        mgr.declareBean("Parameters", scriptParameters, String.class); // $NON-NLS-1$
        String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
        mgr.declareBean("args",args,args.getClass());//$NON-NLS-1$
        // Add variables for access to context and variables
        JMeterContext jmctx = JMeterContextService.getContext();
        JMeterVariables vars = jmctx.getVariables();
        Properties props = JMeterUtils.getJMeterProperties();

        mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$
        mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$
        mgr.declareBean("props", props, props.getClass()); // $NON-NLS-1$
        // For use in debugging:
        mgr.declareBean("OUT", System.out, PrintStream.class); // $NON-NLS-1$

        // Most subclasses will need these:
        Sampler sampler = jmctx.getCurrentSampler();
        mgr.declareBean("sampler", sampler, Sampler.class);
        SampleResult prev = jmctx.getPreviousResult();
        mgr.declareBean("prev", prev, SampleResult.class);
    }
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

            if (log.isDebugEnabled()) {
                log.debug("Add cookie to store " + c.toString());
            }
            getCookies().addItem(c);
            if (SAVE_COOKIES)  {
                JMeterContext context = getThreadContext();
                if (context.isSamplingStarted()) {
                    context.getVariables().put(COOKIE_NAME_PREFIX+cn, cv);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

     * Return value as variable defined by REFNAME. Returns DEFAULT value
     * if not found.
     */
    @Override
    public void process() {
        JMeterContext context = getThreadContext();
        final SampleResult previousResult = context.getPreviousResult();
        if (previousResult == null){
            return;
        }
        JMeterVariables vars = context.getVariables();
        String refName = getRefName();
        vars.put(refName, getDefaultValue());
        final String matchNR = concat(refName,MATCH_NR);
        int prevCount=0; // number of previous matches
        try {
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

     *
     * @see JMeterProperty#getStringValue()
     */
    @Override
    public String getStringValue() {
        JMeterContext ctx = JMeterContextService.getContext();// Expensive, so
                                                                // do
        // once
        if (!isRunningVersion() /*|| !ctx.isSamplingStarted()*/) {
            log.debug("Not running version, return raw function string");
            return function.getRawParameters();
        }
        if(!ctx.isSamplingStarted()) {
            return function.execute();
        }
        log.debug("Running version, executing function");
        int iter = ctx.getVariables() != null ? ctx.getVariables().getIteration() : -1;
        if (iter < testIteration) {
            testIteration = -1;
        }
        if (iter > testIteration || cacheValue == null) {
            testIteration = iter;
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

    /**
     * {@inheritDoc}
     */
    @Override
    public SampleResult sample(Entry e) {
        JMeterContext context = JMeterContextService.getContext();

        int target = getTarget();
        int action = getAction();
        if (action == PAUSE) {
            pause(getDurationAsString());
        } else if (action == STOP || action == STOP_NOW || action == RESTART_NEXT_LOOP) {
            if (target == THREAD) {
                if(action == STOP || action == STOP_NOW) {
                    log.info("Stopping current thread");
                    context.getThread().stop();
                } else {
                    log.info("Restarting next loop");
                    context.setRestartNextLoop(true);
                }
//             //Not yet implemented
//            } else if (target==THREAD_GROUP) {
            } else if (target == TEST) {
                if (action == STOP_NOW) {
                    log.info("Stopping all threads now");
                    context.getEngine().stopTest();
                } else {
                    log.info("Stopping all threads");
                    context.getEngine().askThreadsToStop();
                }
            }
        }

        return null; // This means no sample is saved
View Full Code Here

Examples of org.apache.jmeter.threads.JMeterContext

    }

    @Override
    public void iterationStart(LoopIterationEvent iterEvent) {
        FileServer server = FileServer.getFileServer();
        final JMeterContext context = getThreadContext();
        String delim = getDelimiter();
        if (delim.equals("\\t")) { // $NON-NLS-1$
            delim = "\t";// Make it easier to enter a Tab // $NON-NLS-1$
        } else if (delim.length()==0){
            log.warn("Empty delimiter converted to ','");
            delim=",";
        }
        if (vars == null) {
            String _fileName = getFilename();
            String mode = getShareMode();
            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
            switch(modeInt){
                case CSVDataSetBeanInfo.SHARE_ALL:
                    alias = _fileName;
                    break;
                case CSVDataSetBeanInfo.SHARE_GROUP:
                    alias = _fileName+"@"+System.identityHashCode(context.getThreadGroup());
                    break;
                case CSVDataSetBeanInfo.SHARE_THREAD:
                    alias = _fileName+"@"+System.identityHashCode(context.getThread());
                    break;
                default:
                    alias = _fileName+"@"+mode; // user-specified key
                    break;
            }
            final String names = getVariableNames();
            if (names == null || names.length()==0) {
                String header = server.reserveFile(_fileName, getFileEncoding(), alias, true);
                try {
                    vars = CSVSaveService.csvSplitString(header, delim.charAt(0));
                    firstLineIsNames = true;
                } catch (IOException e) {
                    log.warn("Could not split CSV header line",e);
                }
            } else {
                server.reserveFile(_fileName, getFileEncoding(), alias);
                vars = JOrphanUtils.split(names, ","); // $NON-NLS-1$
            }
        }
          
        // TODO: fetch this once as per vars above?
        JMeterVariables threadVars = context.getVariables();
        String[] lineValues = {};
        try {
            if (getQuotedData()) {
                lineValues = server.getParsedLine(alias, recycle, firstLineIsNames, delim.charAt(0));
            } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.