Package org.apache.jmeter.threads

Examples of org.apache.jmeter.threads.JMeterContext


    /**
     * Create additional SampleEvent in NON Parent Mode
     */
    protected void notifyListeners() {
        // TODO could these be done earlier (or just once?)
        JMeterContext threadContext = getThreadContext();
        JMeterVariables threadVars = threadContext.getVariables();
        SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT);
        if (pack == null) {
            // If child of TransactionController is a ThroughputController and TPC does
            // not sample its children, then we will have this
            // TODO Should this be at warn level ?
            log.warn("Could not fetch SamplePackage");
        } else {
            SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars, true);
            // We must set res to null now, before sending the event for the transaction,
            // so that we can ignore that event in our sampleOccured method
            res = null;
            // bug 50032
            if (!getThreadContext().isReinitializingSubControllers()) {
View Full Code Here


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

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

        }
    }

    public String execute() {
        if (isDynamic) {
            JMeterContext context = JMeterContextService.getContext();
            SampleResult previousResult = context.getPreviousResult();
            Sampler currentSampler = context.getCurrentSampler();
            return execute(previousResult, currentSampler);
        }
        return permanentResults; // $NON-NLS-1$
    }
View Full Code Here

     * @see Function#execute(SampleResult, Sampler)
     */
    abstract public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException;

    public String execute() throws InvalidVariableException {
        JMeterContext context = JMeterContextService.getContext();
        SampleResult previousResult = context.getPreviousResult();
        Sampler currentSampler = context.getCurrentSampler();
        return execute(previousResult, currentSampler);
    }
View Full Code Here

                if(res.isSuccessful()) {
                    res.setResponseCodeOK();
                }

                // TODO could these be done earlier (or just once?)
                JMeterContext threadContext = getThreadContext();
                JMeterVariables threadVars = threadContext.getVariables();

                SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT);
                if (pack == null) {
                  // If child of TransactionController is a ThroughputController and TPC does
                  // not sample its children, then we will have this
                  // TODO Should this be at warn level ?
                    log.warn("Could not fetch SamplePackage");
                } else {
                    SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars, true);
                    // We must set res to null now, before sending the event for the transaction,
                    // so that we can ignore that event in our sampleOccured method
                    res = null;
                    // bug 50032
                    if (!getThreadContext().isReinitializingSubControllers()) {
View Full Code Here

            } 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

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isDone() {
        JMeterContext context = getThreadContext();
        String inputVariable = getInputVal() + getSeparator() + (loopCount + 1);
        final JMeterVariables variables = context.getVariables();
        final Object currentVariable = variables.getObject(inputVariable);
        if (currentVariable != null) {
            variables.putObject(getReturnVal(), currentVariable);
            if (log.isDebugEnabled()) {
                log.debug("ForEach resultstring isDone=" + variables.get(getReturnVal()));
View Full Code Here

        }
        return super.isDone();
    }

    private boolean endOfArguments() {
        JMeterContext context = getThreadContext();
        String inputVariable = getInputVal() + getSeparator() + (loopCount + 1);
        if (context.getVariables().getObject(inputVariable) != null) {
            log.debug("ForEach resultstring eofArgs= false");
            return false;
        }
        log.debug("ForEach resultstring eofArgs= true");
        return true;
View Full Code Here

     * Check if there are any matching entries
     *
     * @return whether any entries in the list
     */
    private boolean emptyList() {
        JMeterContext context = getThreadContext();
        String inputVariable = getInputVal() + getSeparator() + "1";// $NON-NLS-1$
        if (context.getVariables().getObject(inputVariable) != null) {
            return false;
        }
        if (log.isDebugEnabled()) {
            log.debug("No entries found - null first entry: " + inputVariable);
        }
View Full Code Here

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

        // Fetch some variables
        JMeterVariables vars = context.getVariables();
        String refName = getRefName();
        int matchNumber = getMatchNumber();

        final String defaultValue = getDefaultValue();
        if (defaultValue.length() > 0){// Only replace default if it is provided
View Full Code Here

TOP

Related Classes of org.apache.jmeter.threads.JMeterContext

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.