Created attachment 32884 [details] three pictures in one in BeanShell PreProcessor : sampler.toString(); vars.put("sign","123"); ${sign} can not be replaced by 123 in HttpSampler please see Attachements
the sampler.toStirng() will use the Class HTTPSamplerBase: getUrl()-->getQueryString()-->item.getEncodedName();
I canot work out what the problem is here. Please provide the simplest possible Test Plan showing the issue. State what you expected to happen and what actually happened. Did the same test sequence work OK in a previous version of JMeter, if so which?
(In reply to Sebb from comment #2) > I canot work out what the problem is here. > > Please provide the simplest possible Test Plan showing the issue. > > State what you expected to happen and what actually happened. > > Did the same test sequence work OK in a previous version of JMeter, if so > which? Hi Sebb , Thanks for reply. I add an attachement provide the simplest Test Plan. you will see my problem in it . the Test Plan can not work because of the problem ,please use "//" before sampler.toString() in BeanShell PreProcessor .
Created attachment 32886 [details] Test Plan Demo
Thanks, that is a great help. I can confirm the problem, but I've no idea what is causing it yet.
(In reply to Sebb from comment #5) > Thanks, that is a great help. > > I can confirm the problem, but I've no idea what is causing it yet. from the source code ,I find something ,it may help: sampler.toString() will do( from HttpSamplerBase.java) : @Override public String toString() { try { StringBuilder stringBuffer = new StringBuilder(); stringBuffer.append(this.getUrl().toString());//problem is here this.getUrl().toStirng() make the bug; and from the functin getUrl(): if(HTTPConstants.GET.equals(getMethod()) || HTTPConstants.DELETE.equals(getMethod())) { // Get the query string encoded in specified encoding // If no encoding is specified by user, we will get it // encoded in UTF-8, which is what the HTTP spec says String queryString = getQueryString(getContentEncoding());//problem is here getQueryString() make the bug; and from the function getQueryStirng(): try { item.getEncodedValue(contentEncoding);// problem is here } finnally , i find the bug may be in the class AbstractTestElement when i do sampler.toString(),it will do getPropertyAsString(),and the parameters can not be replaced any more after it.
The following test plan also fails: Test Plan - BeanShell PP (at same level as the sampler) - HTTP Sampler This fails: Test Plan - BeanShell PP - HTTP Sampler - Java Request using the variable (this sees the variable OK) However, this works: Test Plan - BeanShell PP - Java Request using the variable (this sees the variable OK) - HTTP Sampler The processing of variables is quite complicated as they sometimes need to be resolved (e.g. when being used at run-time) and sometimes that must be returned in their original state (e.g. for display in the GUI). I expect what is happening is that the "running" state is not being set at the correct time.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3622