Package org.apache.jmeter.threads

Examples of org.apache.jmeter.threads.JMeterContext


    if (bshInterpreter == null) // did we find BeanShell?
    {
      throw new InvalidVariableException("BeanShell not found");
    }

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

    String script = ((CompoundVariable) values[0]).execute();
    String varName = ""; //$NON-NLS-1$
    if (values.length > 1) {
      varName = ((CompoundVariable) values[1]).execute().trim();
View Full Code Here


        String varName = ""; //$NON-NLS-1$
        if (values.length > 1) {
            varName = ((CompoundVariable) values[1]).execute().trim();
        }

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

        try
        {
            Expression e = ExpressionFactory.createExpression(exp);
            JexlContext jc = JexlHelper.createContext();
View Full Code Here

   * @see org.apache.jmeter.functions.Function#execute(SampleResult, Sampler)
   */
  public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
      throws InvalidVariableException {

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

    String script = ((CompoundVariable) values[0]).execute();
    // Allow variable to be omitted
    String varName = values.length < 2 ? null : ((CompoundVariable) values[1]).execute().trim();
    String resultStr = "";
View Full Code Here

      // the script:
      bshInterpreter.set("FailureMessage", "");//$NON-NLS-1$ //$NON-NLS-2$
      bshInterpreter.set("Failure", false);//$NON-NLS-1$

      // Add variables for access to context and variables
      JMeterContext jmctx = JMeterContextService.getContext();
      JMeterVariables vars = jmctx.getVariables();
      bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
      bshInterpreter.set("vars", vars);//$NON-NLS-1$

      // Object bshOut;
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$
    final SampleResult previousResult = context.getPreviousResult();

    try{     
      Document d = parseResponse(previousResult);   
      getValuesForXPath(d,getXPathQuery(),vars, refName);
    }catch(IOException e){// Should not happen
View Full Code Here

   *
   * @see org.apache.jmeter.engine.event.LoopIterationListener#iterationStart(org.apache.jmeter.engine.event.LoopIterationEvent)
   */
  public void iterationStart(LoopIterationEvent iterEvent) {
    FileServer server = FileServer.getFileServer();
        final JMeterContext context = getThreadContext();
    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;
          }
      server.reserveFile(_fileName, getFileEncoding(), alias);
      vars = JOrphanUtils.split(getVariableNames(), ","); // $NON-NLS-1$
    }
    try {
      String delim = getDelimiter();
      if (delim.equals("\\t")) { // $NON-NLS-1$
        delim = "\t";// Make it easier to enter a Tab // $NON-NLS-1$
        }
      // TODO: fetch this once as per vars above?
            JMeterVariables threadVars = context.getVariables();
      String line = server.readLine(alias,getRecycle());
            if (line!=null) {// i.e. not EOF
                String[] lineValues = getQuotedData() ?
                        CSVSaveService.csvReadFile(new BufferedReader(new StringReader(line)), delim.charAt(0))
                        : JOrphanUtils.split(line, delim, false);
View Full Code Here

        final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
    if (bshInterpreter == null) {
          log.error("BeanShell not found");
          return 0;
        }
        JMeterContext jmctx = JMeterContextService.getContext();
        JMeterVariables vars = jmctx.getVariables();
        try {
            // Add variables for access to context and variables
            bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
            bshInterpreter.set("vars", vars);//$NON-NLS-1$
            Object o = processFileOrScript(bshInterpreter);
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

    }
  }

  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

                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) {
          log.warn("Could not fetch SamplePackage");
        } else {
                    SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars);
                    // 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;
          lnf.notifyListeners(event, pack.getSampleListeners());
        }
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.