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 2006/01/26 01:59:11 UTC
svn commit: r372384 - in /jakarta/jmeter/branches/rel-2-1:
src/core/org/apache/jmeter/junit/ src/core/org/apache/jmeter/junit/stubs/
src/protocol/http/org/apache/jmeter/protocol/http/control/gui/
src/protocol/http/org/apache/jmeter/protocol/http/modifi...
Author: sebb
Date: Wed Jan 25 16:58:52 2006
New Revision: 372384
URL: http://svn.apache.org/viewcvs?rev=372384&view=rev
Log:
Move last of unit test code to test tree
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java (contents, props changed)
- copied, changed from r371993, jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/JMeterTestCase.java
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/stubs/TestSampler.java (contents, props changed)
- copied, changed from r371993, jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/stubs/TestSampler.java
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java (with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java (with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java (with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java (with props)
Removed:
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/JMeterTestCase.java
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/stubs/TestSampler.java
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPArgument.java
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java?rev=372384&r1=372383&r2=372384&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java Wed Jan 25 16:58:52 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
@@ -25,8 +24,6 @@
import javax.swing.JCheckBox;
import javax.swing.JPanel;
-import junit.framework.TestCase;
-
import org.apache.jmeter.gui.util.HorizontalPanel;
import org.apache.jmeter.protocol.http.config.gui.MultipartUrlConfigGui;
import org.apache.jmeter.protocol.http.config.gui.UrlConfigGui;
@@ -36,7 +33,11 @@
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
+//For unit tests, @see TestHttpTestSampleGui
+
/**
+ * The GUI for HttpSampler
+ *
* @version $Revision$ on $Date$
*/
public class HttpTestSampleGui extends AbstractSamplerGui {
@@ -123,28 +124,6 @@
public Dimension getPreferredSize() {
return getMinimumSize();
- }
-
- public static class Test extends TestCase {
- HttpTestSampleGui gui;
-
- public Test(String name) {
- super(name);
- }
-
- public void setUp() {
- gui = new HttpTestSampleGui();
- }
-
- public void testCloneSampler() throws Exception {
- HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
- sampler.addArgument("param", "value");
- HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
- clonedSampler.setRunningVersion(true);
- sampler.getArguments().getArgument(0).setValue("new value");
- assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0)
- .getValue());
- }
}
/*
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java?rev=372384&r1=372383&r2=372384&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java Wed Jan 25 16:58:52 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
@@ -20,31 +19,28 @@
import java.io.Serializable;
-import junit.framework.TestCase;
-
-import org.apache.jmeter.config.Argument;
-import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.processor.PreProcessor;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
-import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.threads.JMeterContext;
-import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
+//For unit tests, @see TestURLRewritingModifier
+
/**
* @author mstover
* @author <a href="mailto:jsalvata@apache.org">Jordi Salvat i Alabart</a>
* @version $Revision$ updated on $Date$
*/
+
public class URLRewritingModifier extends AbstractTestElement implements Serializable, PreProcessor {
private Pattern pathExtensionEqualsQuestionmarkRegexp;
@@ -190,124 +186,5 @@
public boolean isPathExtensionNoQuestionmark() {
return getPropertyAsBoolean(PATH_EXTENSION_NO_QUESTIONMARK);
- }
-
- // TODO: add test cases for new jakarta commons http client
- public static class Test extends TestCase {
- private SampleResult response = null;
-
- private JMeterContext context = null;
-
- private URLRewritingModifier mod = null;
-
- public Test(String name) {
- super(name);
- }
-
- public void setUp() {
- context = JMeterContextService.getContext();
- mod = new URLRewritingModifier();
- mod.setThreadContext(context);
- }
-
- public void testGrabSessionId() throws Exception {
- String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
- response = new SampleResult();
- response.setResponseData(html.getBytes());
- mod.setArgumentName("session_id");
- HTTPSamplerBase sampler = createSampler();
- sampler.addArgument("session_id", "adfasdfdsafasdfasd");
- context.setCurrentSampler(sampler);
- context.setPreviousResult(response);
- mod.process();
- Arguments args = sampler.getArguments();
- assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
- .getValue());
- assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
- }
-
- public void testGrabSessionId2() throws Exception {
- String html = "<a href=\"http://server.com/index.html?" + "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
- response = new SampleResult();
- response.setResponseData(html.getBytes());
- mod.setArgumentName("session_id");
- HTTPSamplerBase sampler = createSampler();
- context.setCurrentSampler(sampler);
- context.setPreviousResult(response);
- mod.process();
- Arguments args = sampler.getArguments();
- assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
- }
-
- private HTTPSamplerBase createSampler() {
- HTTPSamplerBase sampler = new HTTPNullSampler();
- sampler.setDomain("server.com");
- sampler.setPath("index.html");
- sampler.setMethod(HTTPSamplerBase.GET);
- sampler.setProtocol("http");
- return sampler;
- }
-
- public void testGrabSessionId3() throws Exception {
- String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
- response = new SampleResult();
- response.setResponseData(html.getBytes());
- mod.setArgumentName("session_id");
- HTTPSamplerBase sampler = createSampler();
- context.setCurrentSampler(sampler);
- context.setPreviousResult(response);
- mod.process();
- Arguments args = sampler.getArguments();
- assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
- }
-
- public void testGrabSessionIdEndedInTab() throws Exception {
- String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\t";
- response = new SampleResult();
- response.setResponseData(html.getBytes());
- mod.setArgumentName("session_id");
- HTTPSamplerBase sampler = createSampler();
- context.setCurrentSampler(sampler);
- context.setPreviousResult(response);
- mod.process();
- Arguments args = sampler.getArguments();
- assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
- }
-
- public void testGrabSessionId4() throws Exception {
- String html = "href='index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT'";
- response = new SampleResult();
- response.setResponseData(html.getBytes());
- mod.setArgumentName("%24sid%24");
- mod.setPathExtension(true);
- mod.setPathExtensionNoEquals(true);
- HTTPSamplerBase sampler = createSampler();
- context.setCurrentSampler(sampler);
- context.setPreviousResult(response);
- mod.process();
- // Arguments args = sampler.getArguments();
- assertEquals("index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT", sampler.getPath());
- }
-
- public void testGrabSessionIdFromForm() throws Exception {
- String[] html = new String[] { "<input name=\"sid\" value=\"myId\">", "<input name='sid' value='myId'>",
- "<input value=\"myId\" NAME='sid'>", "<input VALUE='myId' name=\"sid\">",
- "<input blah blah value=\"myId\" yoda yoda NAME='sid'>", };
- for (int i = 0; i < html.length; i++) {
- response = new SampleResult();
- response.setResponseData(html[i].getBytes());
- URLRewritingModifier newMod = new URLRewritingModifier();
- newMod.setThreadContext(context);
- newMod.setArgumentName("sid");
- newMod.setPathExtension(false);
- HTTPSamplerBase sampler = createSampler();
- context.setCurrentSampler(sampler);
- context.setPreviousResult(response);
- newMod.process();
- Arguments args = sampler.getArguments();
- assertEquals("For case i=" + i, "myId", ((Argument) args.getArguments().get(0).getObjectValue())
- .getValue());
- }
- }
}
}
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java?rev=372384&r1=372383&r2=372384&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java Wed Jan 25 16:58:52 2006
@@ -27,8 +27,6 @@
import java.util.Map;
import java.util.StringTokenizer;
-import junit.framework.TestCase;
-
import org.apache.jmeter.protocol.http.config.MultipartUrlConfig;
import org.apache.jmeter.protocol.http.control.Header;
import org.apache.jmeter.protocol.http.control.HeaderManager;
@@ -41,6 +39,8 @@
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
+//For unit tests, @see TestHttpRequestHdr
+
/**
* The headers of the client HTTP request.
*
@@ -334,21 +334,4 @@
return str;
}
- public static class Test extends TestCase {
- public Test(String name) {
- super(name);
- }
-
- public void setUp() {
- }
-
- public void testRepeatedArguments() throws Exception {
- String TEST_REQ = "GET http://localhost/matrix.html?" + "update=yes&d=1&d=2&d=&d=&d=&d=&d=&d=1&d=2&d=1&d="
- + "&d= HTTP/1.0\n\n";
- HttpRequestHdr req = new HttpRequestHdr();
- req.parse(new java.io.ByteArrayInputStream(TEST_REQ.getBytes()));
- HTTPSamplerBase s = req.getSampler();
- assertEquals(s.getArguments().getArguments().size(), 13);
- }
- }
}
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java?rev=372384&r1=372383&r2=372384&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java Wed Jan 25 16:58:52 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
@@ -25,7 +24,6 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import junit.framework.TestCase;
import org.apache.jmeter.assertions.ResponseAssertion;
import org.apache.jmeter.config.Arguments;
@@ -41,7 +39,6 @@
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.protocol.http.control.RecordingController;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
-import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
import org.apache.jmeter.samplers.SampleEvent;
import org.apache.jmeter.samplers.SampleListener;
import org.apache.jmeter.samplers.SampleResult;
@@ -57,17 +54,16 @@
import org.apache.jmeter.threads.ThreadGroup;
import org.apache.jmeter.timers.Timer;
import org.apache.jmeter.util.JMeterUtils;
-
import org.apache.jorphan.logging.LoggingManager;
-
import org.apache.log.Logger;
-
import org.apache.oro.text.MalformedCachePatternException;
import org.apache.oro.text.PatternCacheLRU;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
+//For unit tests, @see TestProxyControl
+
/**
* @version $Revision$ updated on $Date$
*/
@@ -315,7 +311,8 @@
}
}
- private boolean filterUrl(HTTPSamplerBase sampler) {
+ // Package protected to allow test case access
+ boolean filterUrl(HTTPSamplerBase sampler) {
String domain = sampler.getDomain();
if (domain == null || domain.length() == 0) {
return false;
@@ -774,40 +771,5 @@
public boolean canRemove() {
return null == server;
- }
-
- public static class Test extends TestCase {
- HTTPSamplerBase sampler;
-
- ProxyControl control;
-
- public Test(String name) {
- super(name);
- }
-
- public void setUp() {
- control = new ProxyControl();
- control.addIncludedPattern(".*\\.jsp");
- control.addExcludedPattern(".*apache.org.*");
- sampler = new HTTPNullSampler();
- }
-
- public void testFilter1() throws Exception {
- sampler.setDomain("jakarta.org");
- sampler.setPath("index.jsp");
- assertTrue("Should find jakarta.org/index.jsp", control.filterUrl(sampler));
- }
-
- public void testFilter2() throws Exception {
- sampler.setPath("index.jsp");
- sampler.setDomain("www.apache.org");
- assertFalse("Should not match www.apache.org", control.filterUrl(sampler));
- }
-
- public void testFilter3() throws Exception {
- sampler.setPath("header.gif");
- sampler.setDomain("jakarta.org");
- assertFalse("Should not match header.gif", control.filterUrl(sampler));
- }
}
}
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPArgument.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPArgument.java?rev=372384&r1=372383&r2=372384&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPArgument.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPArgument.java Wed Jan 25 16:58:52 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -23,21 +22,18 @@
import java.util.LinkedList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.testelement.property.BooleanProperty;
-import org.apache.jmeter.testelement.property.CollectionProperty;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.util.JOrphanUtils;
import org.apache.log.Logger;
+//For unit tests, @see TestHTTPArgument
+
/*
*
- * @author unattributed
- *
* @version $Revision$ $Date$
*/
public class HTTPArgument extends Argument implements Serializable {
@@ -165,34 +161,5 @@
}
args.removeAllArguments();
args.setArguments(newArguments);
- }
-
- public static class Test extends TestCase {
- public Test(String name) {
- super(name);
- }
-
- public void testCloning() throws Exception {
- HTTPArgument arg = new HTTPArgument("name.?", "value_ here");
- assertEquals("name.%3F", arg.getEncodedName());
- assertEquals("value_+here", arg.getEncodedValue());
- HTTPArgument clone = (HTTPArgument) arg.clone();
- assertEquals("name.%3F", clone.getEncodedName());
- assertEquals("value_+here", clone.getEncodedValue());
- }
-
- public void testConversion() throws Exception {
- Arguments args = new Arguments();
- args.addArgument("name.?", "value_ here");
- args.addArgument("name$of property", "value_.+");
- HTTPArgument.convertArgumentsToHTTP(args);
- CollectionProperty argList = args.getArguments();
- HTTPArgument httpArg = (HTTPArgument) argList.get(0).getObjectValue();
- assertEquals("name.%3F", httpArg.getEncodedName());
- assertEquals("value_+here", httpArg.getEncodedValue());
- httpArg = (HTTPArgument) argList.get(1).getObjectValue();
- assertEquals("name%24of+property", httpArg.getEncodedName());
- assertEquals("value_.%2B", httpArg.getEncodedValue());
- }
}
}
Copied: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java (from r371993, jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/JMeterTestCase.java)
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java?p2=jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java&p1=jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/JMeterTestCase.java&r1=371993&r2=372384&rev=372384&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/JMeterTestCase.java (original)
+++ jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java Wed Jan 25 16:58:52 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
@@ -26,11 +25,8 @@
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
-/**
- * @author ano ano
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+/*
+ * Extend JUnit TestCase to provide common setup
*/
public abstract class JMeterTestCase extends TestCase {
// Used by findTestFile
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/JMeterTestCase.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/stubs/TestSampler.java (from r371993, jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/stubs/TestSampler.java)
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/stubs/TestSampler.java?p2=jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/stubs/TestSampler.java&p1=jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/junit/stubs/TestSampler.java&r1=371993&r2=372384&rev=372384&view=diff
==============================================================================
(empty)
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/stubs/TestSampler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/junit/stubs/TestSampler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java?rev=372384&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java (added)
+++ jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java Wed Jan 25 16:58:52 2006
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.modifier;
+
+import junit.framework.TestCase;
+
+import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+
+public class TestURLRewritingModifier extends TestCase {
+ private SampleResult response = null;
+
+ private JMeterContext context = null;
+
+ private URLRewritingModifier mod = null;
+
+ public TestURLRewritingModifier(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+ context = JMeterContextService.getContext();
+ mod = new URLRewritingModifier();
+ mod.setThreadContext(context);
+ }
+
+ public void testGrabSessionId() throws Exception {
+ String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
+ response = new SampleResult();
+ response.setResponseData(html.getBytes());
+ mod.setArgumentName("session_id");
+ HTTPSamplerBase sampler = createSampler();
+ sampler.addArgument("session_id", "adfasdfdsafasdfasd");
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ Arguments args = sampler.getArguments();
+ assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
+ .getValue());
+ assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
+ }
+
+ public void testGrabSessionId2() throws Exception {
+ String html = "<a href=\"http://server.com/index.html?" + "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
+ response = new SampleResult();
+ response.setResponseData(html.getBytes());
+ mod.setArgumentName("session_id");
+ HTTPSamplerBase sampler = createSampler();
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ Arguments args = sampler.getArguments();
+ assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+ }
+
+ private HTTPSamplerBase createSampler() {
+ HTTPSamplerBase sampler = new HTTPNullSampler();
+ sampler.setDomain("server.com");
+ sampler.setPath("index.html");
+ sampler.setMethod(HTTPSamplerBase.GET);
+ sampler.setProtocol("http");
+ return sampler;
+ }
+
+ public void testGrabSessionId3() throws Exception {
+ String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
+ response = new SampleResult();
+ response.setResponseData(html.getBytes());
+ mod.setArgumentName("session_id");
+ HTTPSamplerBase sampler = createSampler();
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ Arguments args = sampler.getArguments();
+ assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+ }
+
+ public void testGrabSessionIdEndedInTab() throws Exception {
+ String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\t";
+ response = new SampleResult();
+ response.setResponseData(html.getBytes());
+ mod.setArgumentName("session_id");
+ HTTPSamplerBase sampler = createSampler();
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ Arguments args = sampler.getArguments();
+ assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+ }
+
+ public void testGrabSessionId4() throws Exception {
+ String html = "href='index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT'";
+ response = new SampleResult();
+ response.setResponseData(html.getBytes());
+ mod.setArgumentName("%24sid%24");
+ mod.setPathExtension(true);
+ mod.setPathExtensionNoEquals(true);
+ HTTPSamplerBase sampler = createSampler();
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ mod.process();
+ // Arguments args = sampler.getArguments();
+ assertEquals("index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT", sampler.getPath());
+ }
+
+ public void testGrabSessionIdFromForm() throws Exception {
+ String[] html = new String[] { "<input name=\"sid\" value=\"myId\">", "<input name='sid' value='myId'>",
+ "<input value=\"myId\" NAME='sid'>", "<input VALUE='myId' name=\"sid\">",
+ "<input blah blah value=\"myId\" yoda yoda NAME='sid'>", };
+ for (int i = 0; i < html.length; i++) {
+ response = new SampleResult();
+ response.setResponseData(html[i].getBytes());
+ URLRewritingModifier newMod = new URLRewritingModifier();
+ newMod.setThreadContext(context);
+ newMod.setArgumentName("sid");
+ newMod.setPathExtension(false);
+ HTTPSamplerBase sampler = createSampler();
+ context.setCurrentSampler(sampler);
+ context.setPreviousResult(response);
+ newMod.process();
+ Arguments args = sampler.getArguments();
+ assertEquals("For case i=" + i, "myId", ((Argument) args.getArguments().get(0).getObjectValue())
+ .getValue());
+ }
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java?rev=372384&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java (added)
+++ jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java Wed Jan 25 16:58:52 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.proxy;
+
+import junit.framework.TestCase;
+
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+
+public class TestHttpRequestHdr extends TestCase {
+ public TestHttpRequestHdr(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+ }
+
+ public void testRepeatedArguments() throws Exception {
+ String TEST_REQ = "GET http://localhost/matrix.html?" + "update=yes&d=1&d=2&d=&d=&d=&d=&d=&d=1&d=2&d=1&d="
+ + "&d= HTTP/1.0\n\n";
+ HttpRequestHdr req = new HttpRequestHdr();
+ req.parse(new java.io.ByteArrayInputStream(TEST_REQ.getBytes()));
+ HTTPSamplerBase s = req.getSampler();
+ assertEquals(s.getArguments().getArguments().size(), 13);
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java?rev=372384&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java (added)
+++ jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java Wed Jan 25 16:58:52 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.proxy;
+
+import junit.framework.TestCase;
+
+import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+
+public class TestProxyControl extends TestCase {
+ HTTPSamplerBase sampler;
+
+ ProxyControl control;
+
+ public TestProxyControl(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+ control = new ProxyControl();
+ control.addIncludedPattern(".*\\.jsp");
+ control.addExcludedPattern(".*apache.org.*");
+ sampler = new HTTPNullSampler();
+ }
+
+ public void testFilter1() throws Exception {
+ sampler.setDomain("jakarta.org");
+ sampler.setPath("index.jsp");
+ assertTrue("Should find jakarta.org/index.jsp", control.filterUrl(sampler));
+ }
+
+ public void testFilter2() throws Exception {
+ sampler.setPath("index.jsp");
+ sampler.setDomain("www.apache.org");
+ assertFalse("Should not match www.apache.org", control.filterUrl(sampler));
+ }
+
+ public void testFilter3() throws Exception {
+ sampler.setPath("header.gif");
+ sampler.setDomain("jakarta.org");
+ assertFalse("Should not match header.gif", control.filterUrl(sampler));
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java?rev=372384&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java (added)
+++ jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java Wed Jan 25 16:58:52 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.util;
+
+import junit.framework.TestCase;
+
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+
+public class TestHTTPArgument extends TestCase {
+ public TestHTTPArgument(String name) {
+ super(name);
+ }
+
+ public void testCloning() throws Exception {
+ HTTPArgument arg = new HTTPArgument("name.?", "value_ here");
+ assertEquals("name.%3F", arg.getEncodedName());
+ assertEquals("value_+here", arg.getEncodedValue());
+ HTTPArgument clone = (HTTPArgument) arg.clone();
+ assertEquals("name.%3F", clone.getEncodedName());
+ assertEquals("value_+here", clone.getEncodedValue());
+ }
+
+ public void testConversion() throws Exception {
+ Arguments args = new Arguments();
+ args.addArgument("name.?", "value_ here");
+ args.addArgument("name$of property", "value_.+");
+ HTTPArgument.convertArgumentsToHTTP(args);
+ CollectionProperty argList = args.getArguments();
+ HTTPArgument httpArg = (HTTPArgument) argList.get(0).getObjectValue();
+ assertEquals("name.%3F", httpArg.getEncodedName());
+ assertEquals("value_+here", httpArg.getEncodedValue());
+ httpArg = (HTTPArgument) argList.get(1).getObjectValue();
+ assertEquals("name%24of+property", httpArg.getEncodedName());
+ assertEquals("value_.%2B", httpArg.getEncodedValue());
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org