You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2004/02/22 20:23:16 UTC
cvs commit: jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier ParamModifier.java UserParameterModifier.java AnchorModifier.java URLRewritingModifier.java
sebb 2004/02/22 11:23:16
Modified: src/protocol/http/org/apache/jmeter/protocol/http/modifier
ParamModifier.java UserParameterModifier.java
AnchorModifier.java URLRewritingModifier.java
Log:
For speed, use getThreadContext() instead of JMeterContextService
Revision Changes Path
1.13 +3 -4 jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/ParamModifier.java
Index: ParamModifier.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/ParamModifier.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ParamModifier.java 12 Feb 2004 00:29:49 -0000 1.12
+++ ParamModifier.java 22 Feb 2004 19:23:15 -0000 1.13
@@ -29,7 +29,6 @@
import org.apache.jmeter.testelement.TestListener;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.testelement.property.TestElementProperty;
-import org.apache.jmeter.threads.JMeterContextService;
/**
* This modifier will replace any single http sampler's url parameter value
@@ -117,7 +116,7 @@
*/
public void process()
{
- Sampler sam = JMeterContextService.getContext().getCurrentSampler();
+ Sampler sam = getThreadContext().getCurrentSampler();
HTTPSampler sampler = null;
if (!(sam instanceof HTTPSampler))
{
1.13 +3 -4 jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/UserParameterModifier.java
Index: UserParameterModifier.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/UserParameterModifier.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- UserParameterModifier.java 12 Feb 2004 00:29:49 -0000 1.12
+++ UserParameterModifier.java 22 Feb 2004 19:23:15 -0000 1.13
@@ -31,7 +31,6 @@
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.TestListener;
import org.apache.jmeter.testelement.property.PropertyIterator;
-import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@@ -109,7 +108,7 @@
*/
public void process()
{
- Sampler entry = JMeterContextService.getContext().getCurrentSampler();
+ Sampler entry = getThreadContext().getCurrentSampler();
if (!(entry instanceof HTTPSampler))
{
return;
1.14 +16 -7 jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
Index: AnchorModifier.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AnchorModifier.java 12 Feb 2004 00:29:49 -0000 1.13
+++ AnchorModifier.java 22 Feb 2004 19:23:15 -0000 1.14
@@ -42,6 +42,7 @@
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.property.PropertyIterator;
+import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jorphan.io.TextFile;
import org.apache.jorphan.logging.LoggingManager;
@@ -71,8 +72,9 @@
*/
public void process()
{
- Sampler sam = JMeterContextService.getContext().getCurrentSampler();
- SampleResult res = JMeterContextService.getContext().getPreviousResult();
+ JMeterContext context = getThreadContext();
+ Sampler sam = context.getCurrentSampler();
+ SampleResult res = context.getPreviousResult();
HTTPSampler sampler = null;
HTTPSampleResult result = null;
if (res == null
@@ -259,6 +261,12 @@
{
super(name);
}
+ private JMeterContext jmctx = null;
+
+ public void setUp()
+ {
+ jmctx = JMeterContextService.getContext();
+ }
public void testProcessingHTMLFile(String HTMLFileName) throws Exception
{
@@ -278,8 +286,8 @@
System.getProperty("user.dir")
+ "/testfiles/Load_JMeter_Page.jmx"))
.getArray()[0];
- JMeterContextService.getContext().setCurrentSampler(context);
- JMeterContextService.getContext().setCurrentSampler(config);
+ jmctx.setCurrentSampler(context);
+ jmctx.setCurrentSampler(config);
result.setResponseData(
new TextFile(
System.getProperty("user.dir")
@@ -289,8 +297,9 @@
result.setSampleLabel(context.toString());
result.setSamplerData(context.toString());
result.setURL(new URL("http://nagoya.apache.org/fakepage.html"));
- JMeterContextService.getContext().setPreviousResult(result);
+ jmctx.setPreviousResult(result);
AnchorModifier modifier = new AnchorModifier();
+ modifier.setThreadContext(jmctx);
modifier.process();
assertEquals(
"http://nagoya.apache.org/bugzilla/buglist.cgi?"
1.29 +13 -12 jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
Index: URLRewritingModifier.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- URLRewritingModifier.java 12 Feb 2004 00:29:49 -0000 1.28
+++ URLRewritingModifier.java 22 Feb 2004 19:23:15 -0000 1.29
@@ -57,9 +57,9 @@
public void process()
{
- Sampler sampler = JMeterContextService.getContext().getCurrentSampler();
- SampleResult responseText =
- JMeterContextService.getContext().getPreviousResult();
+ JMeterContext ctx = getThreadContext();
+ Sampler sampler = ctx.getCurrentSampler();
+ SampleResult responseText = ctx.getPreviousResult();
if(responseText == null)
{
return;
@@ -183,8 +183,11 @@
}
public static class Test extends TestCase
{
- SampleResult response;
- JMeterContext context;
+ private SampleResult response = null;
+
+ private JMeterContext context = null;
+ private URLRewritingModifier mod = null;
+
public Test(String name)
{
super(name);
@@ -192,6 +195,8 @@
public void setUp()
{
context = JMeterContextService.getContext();
+ mod = new URLRewritingModifier();
+ mod.setThreadContext(context);
}
public void testGrabSessionId() throws Exception
{
@@ -200,7 +205,6 @@
+ "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
response = new SampleResult();
response.setResponseData(html.getBytes());
- URLRewritingModifier mod = new URLRewritingModifier();
mod.setArgumentName("session_id");
HTTPSampler sampler = createSampler();
sampler.addArgument("session_id", "adfasdfdsafasdfasd");
@@ -224,7 +228,6 @@
+ "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
response = new SampleResult();
response.setResponseData(html.getBytes());
- URLRewritingModifier mod = new URLRewritingModifier();
mod.setArgumentName("session_id");
HTTPSampler sampler = createSampler();
context.setCurrentSampler(sampler);
@@ -251,7 +254,6 @@
String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
response = new SampleResult();
response.setResponseData(html.getBytes());
- URLRewritingModifier mod = new URLRewritingModifier();
mod.setArgumentName("session_id");
HTTPSampler sampler = createSampler();
context.setCurrentSampler(sampler);
@@ -269,7 +271,6 @@
String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\t";
response = new SampleResult();
response.setResponseData(html.getBytes());
- URLRewritingModifier mod = new URLRewritingModifier();
mod.setArgumentName("session_id");
HTTPSampler sampler = createSampler();
context.setCurrentSampler(sampler);
@@ -288,7 +289,6 @@
"href='index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT'";
response = new SampleResult();
response.setResponseData(html.getBytes());
- URLRewritingModifier mod = new URLRewritingModifier();
mod.setArgumentName("%24sid%24");
mod.setPathExtension(true);
mod.setPathExtensionNoEquals(true);
@@ -316,6 +316,7 @@
response = new SampleResult();
response.setResponseData(html[i].getBytes());
URLRewritingModifier mod = new URLRewritingModifier();
+ mod.setThreadContext(context);
mod.setArgumentName("sid");
mod.setPathExtension(false);
HTTPSampler sampler = createSampler();
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org