You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/07/20 20:36:15 UTC
svn commit: r1802530 - in /jmeter/trunk:
src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
xdocs/changes.xml
Author: pmouawad
Date: Thu Jul 20 20:36:15 2017
New Revision: 1802530
URL: http://svn.apache.org/viewvc?rev=1802530&view=rev
Log:
Bug 61314 - HTTP URL Re-writing Modifier doesn't replace existing jsessionid in http sampler, but adds to the end
Bugzilla Id: 61314
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java?rev=1802530&r1=1802529&r2=1802530&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java Thu Jul 20 20:36:15 2017
@@ -132,10 +132,21 @@ public class URLRewritingModifier extend
private void modify(HTTPSamplerBase sampler, String value) {
if (isPathExtension()) {
+ String oldPath = sampler.getPath();
+ int indexOfSessionId = oldPath.indexOf(SEMI_COLON + getArgumentName());
+ if(oldPath.indexOf(SEMI_COLON + getArgumentName())>=0) {
+ int indexOfQuestionMark = oldPath.indexOf('?');
+ if(indexOfQuestionMark < 0) {
+ oldPath = oldPath.substring(0, indexOfSessionId);
+ } else {
+ oldPath = oldPath.substring(0, indexOfSessionId)+
+ oldPath.substring(indexOfQuestionMark);
+ }
+ }
if (isPathExtensionNoEquals()) {
- sampler.setPath(sampler.getPath() + SEMI_COLON + getArgumentName() + value); // $NON-NLS-1$
+ sampler.setPath(oldPath + SEMI_COLON + getArgumentName() + value); // $NON-NLS-1$
} else {
- sampler.setPath(sampler.getPath() + SEMI_COLON + getArgumentName() + "=" + value); // $NON-NLS-1$ // $NON-NLS-2$
+ sampler.setPath(oldPath + SEMI_COLON + getArgumentName() + "=" + value); // $NON-NLS-1$ // $NON-NLS-2$
}
} else {
sampler.getArguments().removeArgument(getArgumentName());
Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java?rev=1802530&r1=1802529&r2=1802530&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java Thu Jul 20 20:36:15 2017
@@ -176,6 +176,38 @@ public class TestURLRewritingModifier ex
mod.process();
assertEquals("index.html;jsessionid=123456789",sampler.getPath());
}
+
+ @Test
+ public void testBug61314() throws Exception { // Bug 50286
+ String html = "<url>/some/path;jsessionid=123456789</url>";
+
+ response = new SampleResult();
+ response.setResponseData(html, null);
+ mod.setArgumentName("jsessionid");
+ mod.setPathExtension(true);
+ HTTPSamplerBase sampler = createSampler();
+ sampler.setPath("/urlRewrite/index;jsessionid=657CF77A86183868CF30AC36321394B7");
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ assertEquals("/urlRewrite/index;jsessionid=123456789",sampler.getPath());
+ }
+
+ @Test
+ public void testBug61314WithQuestionMark() throws Exception { // Bug 50286
+ String html = "<url>/some/path;jsessionid=123456789</url>";
+
+ response = new SampleResult();
+ response.setResponseData(html, null);
+ mod.setArgumentName("jsessionid");
+ mod.setPathExtension(true);
+ HTTPSamplerBase sampler = createSampler();
+ sampler.setPath("/urlRewrite/index;jsessionid=657CF77A86183868CF30AC36321394B7?toto=titi");
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ assertEquals("/urlRewrite/index;jsessionid=123456789",sampler.getPath());
+ }
@Test
public void testGrabSessionIdEndedInTab() throws Exception {
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1802530&r1=1802529&r2=1802530&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Thu Jul 20 20:36:15 2017
@@ -178,6 +178,7 @@ Summary
<h3>Timers, Assertions, Config, Pre- & Post-Processors</h3>
<ul>
<li><bug>58743</bug><pr>293</pr>TableEditor can't be saved, when using two or more instances. Bugfix provided by Emilian Bold (emi at apache.org)</li>
+ <li><bug>61314</bug>HTTP URL Re-writing Modifier doesn't replace existing jsessionid in http sampler, but adds to the end</li>
</ul>
<h3>Functions</h3>