Package org.apache.jmeter.threads

Examples of org.apache.jmeter.threads.JMeterContext


   * string representation of the function is provided.
   *
   * @see JMeterProperty#getStringValue()
   */
  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


        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);
    }
View Full Code Here

     *
     * @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

     * 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

    /**
     * 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

        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

     * @see org.apache.jmeter.processor.PostProcessor#process()
     */
    @Override
    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

     * string representation of the function is provided.
     *
     * @see JMeterProperty#getStringValue()
     */
    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

   * Do the job - extract value from (X)HTML response using XPath Query.
   * Return value as variable defined by REFNAME. Returns DEFAULT value
   * if not found.
   */
    public void process() {
        JMeterContext context = getThreadContext();       
    JMeterVariables vars = context.getVariables();
    String refName = getRefName();
    vars.put(refName, getDefaultValue());
        vars.put(concat(refName,MATCH_NR), "0"); // In case parse fails // $NON-NLS-1$
        vars.remove(concat(refName,"1")); // In case parse fails // $NON-NLS-1$

    try{     
      Document d = parseResponse(context.getPreviousResult());   
      getValuesForXPath(d,getXPathQuery(),vars, refName);
    }catch(IOException e){// Should not happen
      final String errorMessage = "error on "+XPATH_QUERY+"("+getXPathQuery()+")";
      log.error(errorMessage,e);
      throw new JMeterError(errorMessage,e);
View Full Code Here

   * Do the job - extract value from (X)HTML response using XPath Query.
   * Return value as variable defined by REFNAME. Returns DEFAULT value
   * if not found.
   */
    public void process() {
        JMeterContext context = getThreadContext();       
    JMeterVariables vars = context.getVariables();
    String refName = getRefName();
    vars.put(refName, getDefaultValue());
        vars.put(concat(refName,MATCH_NR), "0"); // In case parse fails // $NON-NLS-1$
        vars.remove(concat(refName,"1")); // In case parse fails // $NON-NLS-1$

    try{     
      Document d = parseResponse(context.getPreviousResult());   
      getValuesForXPath(d,getXPathQuery(),vars, refName);
    }catch(IOException e){// Should not happen
      final String errorMessage = "error on "+XPATH_QUERY+"("+getXPathQuery()+")";
      log.error(errorMessage,e);
      throw new JMeterError(errorMessage,e);
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.