I dont think sampler HTTPSampler creates a CookieManager - the framework
sets it on the sampler so CookieManager manager =
sampler.getCookieManager(); should be returning it null

If you are trying to manipulate cookies in places other than a pre/post
processor of an HTTPSampler , then on your first HTTPSampler you can do
something like (in a pre processor scoped to this sampler)
CookieManager manager = sampler.getCookieManager();
vars.putObject("CookieMananger",manager)

Then (CookieManager)vars.getObject("CookieManager") will allow you to get
it anywhere


On Tue, Jun 10, 2014 at 1:56 AM, Adrian Speteanu <[email protected]>
wrote:

> Hi guys,
>
> Need a suggestion with a piece of code that is not compiling in beanshell,
> and I have no idea why it doesn't work. The code is simple and it's in a
> beanshell sampler at the moment:
> "
> import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
> import org.apache.jmeter.protocol.http.control.CookieManager;
> import org.apache.jmeter.protocol.http.control.Cookie;
>
> HTTPSampler sampler = new HTTPSampler();
> CookieManager manager = sampler.getCookieManager();
> Cookie cookie = new Cookie("SessionPersistence", "value", "localhost:8080",
> "/", true, 0);
> manager.add(cookie);
> "
> Fails with
> "Response message: org.apache.jorphan.util.JMeterException: Error invoking
> bsh method: eval"
> because of the very last line.
>
> Any ideas what to do and why it fails?
>
> Thanks,
> --Adrian S
>

Reply via email to