如何将完整的cookie从一个线程组传递到另一个线程组

时间:2016-10-07 14:29:03

标签: cookies jmeter

我想将完整的Cookie从一个线程组传递到另一个线程组。我试过这个:

Thread Group A 
  --HTTP Cookie Manager
  --HTTP Sampler A
     --BeanShell PostProcessor
       import org.apache.jmeter.protocol.http.control.CookieManager; 
       CookieManager manager =ctx.getCurrentSampler().getProperty("HTTPSampler.cookie_manager").getObjectValue();
       props.put("cookiecount",String.valueOf(manager.getCookieCount()));
       for (int i=0;i<manager.getCookieCount();i++)
       {
             // code to convert Cookie information to JMeter Properties
       props.put("cookie_name_" + i, manager.get(i).getName());
       }

Thread Group B
  --HTTP Cookie Manager
  --HTTP Sampler B
     --BeanShell PreProcessor
       import org.apache.jmeter.protocol.http.control.CookieManager;
       import org.apache.jmeter.protocol.http.control.Cookie;
       import org.apache.jmeter.testelement.property.JMeterProperty;
       CookieManager manager = ctx.getCurrentSampler().getProperty("HTTPSampler.cookie_manager").getObjectValue();
       int count = Integer.parseInt(props.getProperty("cookiecount"));
       for (int i=0;i<count;i++) {
       Cookie cookie = new Cookie(props.getProperty("cookie_name"+i),props.getProperty("cookie_value"+i), props.getProperty("cookie_domain"+i),props.getProperty("cookie_path"+i), Boolean.parseBoolean(props.getProperty("cookie_secure"+i)), Long.parseLong(props.getProperty("cookie_expires"+i)));
       manager.add(cookie);
       }
      JMeterProperty cookieprop = ctx.getCurrentSampler().getProperty("HTTPSampler.cookie_manager");
      cookieprop.setObjectValue(manager); 
      ctx.getCurrentSampler().setProperty(myprop);
  

错误:jmeter.util.BeanShellInterpreter:调用bsh方法时出错:eval源文件:内联评估:``import org.apache.jmeter.protocol.http.control.CookieManager;

我能为此做些什么

0 个答案:

没有答案