Jmeter script failing with ASM monitor
search cancel

Jmeter script failing with ASM monitor

book

Article ID: 395967

calendar_today

Updated On: 05-16-2025

Products

CA App Synthetic Monitor

Issue/Introduction

Testing an application with Jmeter script monitor that runs multiple tests in parallel. The script requires a cookies to be shared from the first step to the other parallel steps. This requires CookieManager.save.cookies property to be set to true in the jmeter.properties file. How this can be accomplished for ASM monitor. 

Resolution

This can be accomplished without having the CookieManager.save.cookies property enabled.

In the 'setCookie' request postprocessor replace the current:


codeprops.put("SMCookie","${COOKIE_SMSESSION}");withimport org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.testelement.property.JMeterProperty;
CookieManager manager = ctx.getCurrentSampler().getCookieManager();
PropertyIterator iter = manager.getCookies().iterator();
while (iter.hasNext()) {
    JMeterProperty prop = iter.next();
     Cookie cookie = prop.getObjectValue();
     if (cookie.getName().equals("SMSESSION")) {
         props.put("SMCookie", cookie.getValue());
         break;
     }
}