Package org.apache.jmeter.threads

Examples of org.apache.jmeter.threads.JMeterVariables


    }
   
    public void testVariableExtraction6() throws Exception
        {
          variable.setParameters(URLEncoder.encode("<value field=\"(pinposition\\d+)\">(\\d+)</value>")+",$2$,4,,default");
          variable.setJMeterVariables(new JMeterVariables());
          String match = variable.execute(result,null);
          assertEquals("default",match);     
        }
View Full Code Here


        }
   
    public void testComma() throws Exception
    {
      variable.setParameters(URLEncoder.encode("<value,? field=\"(pinposition\\d+)\">(\\d+)</value>")+",$1$,3");
      variable.setJMeterVariables(new JMeterVariables());
      String match = variable.execute(result,null);
      assertEquals("pinposition3",match);     
    }
View Full Code Here

   
    public void testVariableExtraction3() throws Exception
    {
      variable.setParameters(URLEncoder.encode("<value field=\"(pinposition\\d+)\">(\\d+)</value>")+
          ",_$1$,.5");
      variable.setJMeterVariables(new JMeterVariables());
      String match = variable.execute(result,null);
      assertEquals("_pinposition2",match);     
    }
View Full Code Here

    public void testVariableExtraction4() throws Exception
    {
      variable.setParameters(URLEncoder.encode(
          "<value field=\"(pinposition\\d+)\">(\\d+)</value>")+","+URLEncoder.encode("$2$, ")+
          ",.333");
      variable.setJMeterVariables(new JMeterVariables());
     
      String match = variable.execute(result,null);
      assertEquals("1, ",match);     
    }
View Full Code Here

    public void testDefaultValue() throws Exception
    {
      variable.setParameters(URLEncoder.encode(
          "<value,, field=\"(pinposition\\d+)\">(\\d+)</value>")+","+URLEncoder.encode("$2$, ")+
          ",.333,,No Value Found");
      variable.setJMeterVariables(new JMeterVariables());
     
      String match = variable.execute(result,null);
      assertEquals("No Value Found",match);     
    }
View Full Code Here

   * @see Function#execute(SampleResult, Sampler)
   */
  public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
      throws InvalidVariableException
  {
    JMeterVariables vars = getVariables();
    String totalString = Integer.toString(sum);
    vars.put(varName, totalString);
    return totalString;
  }
View Full Code Here

  /**
   * @see org.apache.jmeter.testelement.ThreadListener#iterationStarted(int)
   */
  public synchronized void iterationStarted(int iterationCount)
  {
    JMeterVariables variables = vars.getVariables();
    if(!perUser)
    {
      globalCounter++;
      int value = start + (increment * globalCounter);
      if(value > end)
      {
        globalCounter = 0;
        value = start;
      }
      variables.put(getVarName(),Integer.toString(value));
    }
    else
    {   
      String value = variables.get(getVarName());
      if(value == null)
      {
        variables.put(getVarName(),Integer.toString(start));
      }
      else
      {
        try
        {
          int current = Integer.parseInt(value);
          current += increment;
          if(current > end)
          {
            current = start;
          }
          variables.put(getVarName(),Integer.toString(current));
        }
        catch(NumberFormatException e)
        {
          log.info("Bad number in Counter config",e);
        }   
View Full Code Here

        }

        public void testParseExample1() throws Exception
        {
            function.setParameters("${__regexFunction(<html>(.*)</html>,$1$)}");
            function.setJMeterVariables(new JMeterVariables());
            assertEquals(1, function.compiledComponents.size());
            assertEquals(
                "org.apache.jmeter.functions.RegexFunction",
                function.compiledComponents.getFirst().getClass().getName());
            assertTrue(function.hasFunction());
View Full Code Here

        {
            function.setParameters(
                "It should say:${${__regexFunction("
                    + URLEncoder.encode("<html>(.*)</html>")
                    + ",$1$)}}");
            function.setJMeterVariables(new JMeterVariables());
            assertEquals(3, function.compiledComponents.size());
            assertEquals(
                "It should say:${",
                function.compiledComponents.getFirst().toString());
            assertTrue(function.hasFunction());
View Full Code Here

        public void testParseExample3() throws Exception
        {
            function.setParameters(
                "${__regexFunction(<html>(.*)</html>,$1$)}${__regexFunction(<html>(.*o)(.*o)(.*)</html>,$1$$3$)}");
            function.setJMeterVariables(new JMeterVariables());
            assertEquals(2, function.compiledComponents.size());
            assertTrue(function.hasFunction());
            assertTrue(!function.hasStatics());
            assertEquals(
                "hello world",
View Full Code Here

TOP

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

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.