Author: sebb
Date: Wed Jan 25 17:26:49 2006
New Revision: 372390
URL: http://svn.apache.org/viewcvs?rev=372390&view=rev
Log:
Found some more tests
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
(with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
(with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
(with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
(with props)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
(with props)
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java?rev=372390&r1=372389&r2=372390&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
Wed Jan 25 17:26:49 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
@@ -33,8 +32,6 @@
import org.apache.jmeter.config.ConfigElement;
import org.apache.jmeter.config.ConfigTestElement;
-import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jmeter.protocol.http.util.Base64Encoder;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.CollectionProperty;
import org.apache.jmeter.testelement.property.PropertyIterator;
@@ -43,6 +40,8 @@
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
+// For Unit tests, @see TestAuthManager
+
/**
* This class provides a way to provide Authorization in jmeter requests. The
* format of the authorization file is: URL user pass where URL is an HTTP URL,
@@ -272,38 +271,8 @@
return getAuthObjects().size();
}
- private static boolean isSupportedProtocol(URL url) {
+ // Needs to be package protected for Unit test
+ static boolean isSupportedProtocol(URL url) {
return url.getProtocol().toUpperCase().equals("HTTP") ||
url.getProtocol().toUpperCase().equals("HTTPS");
- }
-
- // ////////////////////// UNIT TESTS ////////////////////////////
-
- public static class Test extends JMeterTestCase {
- public Test(String name) {
- super(name);
- }
-
- public void testHttp() throws Exception {
- assertTrue(isSupportedProtocol(new URL("http:")));
- }
-
- public void testHttps() throws Exception {
- assertTrue(isSupportedProtocol(new URL("https:")));
- }
-
- public void testFile() throws Exception {
- AuthManager am = new AuthManager();
- CollectionProperty ao = am.getAuthObjects();
- assertEquals(0, ao.size());
- am.addFile("testfiles/TestAuth.txt");
- assertEquals(5, ao.size());
- Authorization at;
- at = am.getAuthForURL(new URL("http://a.b.c/"));
- assertEquals("login", at.getUser());
- assertEquals("password", at.getPass());
- at = am.getAuthForURL(new URL("http://a.b.c/1"));
- assertEquals("login1", at.getUser());
- assertEquals("password1", at.getPass());
- }
}
}
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java?rev=372390&r1=372389&r2=372390&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
Wed Jan 25 17:26:49 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -18,7 +17,6 @@
package org.apache.jmeter.protocol.http.modifier;
-import java.io.FileInputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
@@ -32,19 +30,15 @@
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.config.ConfigElement;
-import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.processor.PreProcessor;
import org.apache.jmeter.protocol.http.parser.HtmlParsingUtils;
import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
-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;
import org.apache.log.Logger;
import org.w3c.dom.Document;
@@ -53,6 +47,8 @@
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+// For Unit tests, @see TestAnchorModifier
+
/**
* @author Michael Stover
* @version $Revision$
@@ -195,68 +191,5 @@
log.error("Bad pattern", e);
}
}
- }
-
- public static class Test extends JMeterTestCase {
- public Test(String name) {
- super(name);
- }
-
- private JMeterContext jmctx = null;
-
- public void setUp() {
- jmctx = JMeterContextService.getContext();
- }
-
- public void testProcessingHTMLFile(String HTMLFileName) throws
Exception {
- HTTPSamplerBase config = (HTTPSamplerBase)
SaveService.loadTree(
- new
FileInputStream(System.getProperty("user.dir") +
"/testfiles/load_bug_list.jmx")).getArray()[0];
- config.setRunningVersion(true);
- HTTPSampleResult result = new HTTPSampleResult();
- HTTPSamplerBase context = (HTTPSamplerBase)
SaveService.loadTree(
- new
FileInputStream(System.getProperty("user.dir") +
"/testfiles/Load_JMeter_Page.jmx")).getArray()[0];
- jmctx.setCurrentSampler(context);
- jmctx.setCurrentSampler(config);
- result.setResponseData(new
TextFile(System.getProperty("user.dir") + HTMLFileName).getText().getBytes());
- result.setSampleLabel(context.toString());
- result.setSamplerData(context.toString());
- result.setURL(new
URL("http://issues.apache.org/fakepage.html"));
- jmctx.setPreviousResult(result);
- AnchorModifier modifier = new AnchorModifier();
- modifier.setThreadContext(jmctx);
- modifier.process();
-
assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
- +
"bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED"
- +
"&email1=&emailtype1=substring&emailassigned_to1=1"
- +
"&email2=&emailtype2=substring&emailreporter2=1" +
"&bugidtype=include&bug_id=&changedin=&votes="
- +
"&chfieldfrom=&chfieldto=Now&chfieldvalue="
- +
"&product=JMeter&short_desc=&short_desc_type=substring"
- +
"&long_desc=&long_desc_type=substring&bug_file_loc=" +
"&bug_file_loc_type=substring&keywords="
- + "&keywords_type=anywords" +
"&field0-0-0=noop&type0-0-0=noop&value0-0-0="
- +
"&cmdtype=doit&order=Reuse+same+sort+as+last+time", config.toString());
- config.recoverRunningVersion();
-
assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
- +
"bug_status=.*&bug_status=.*&bug_status=.*&email1="
- +
"&emailtype1=substring&emailassigned_to1=1&email2=" +
"&emailtype2=substring&emailreporter2=1"
- +
"&bugidtype=include&bug_id=&changedin=&votes=" +
"&chfieldfrom=&chfieldto=Now&chfieldvalue="
- +
"&product=JMeter&short_desc=&short_desc_type=substring"
- +
"&long_desc=&long_desc_type=substring&bug_file_loc=" +
"&bug_file_loc_type=substring&keywords="
- +
"&keywords_type=anywords&field0-0-0=noop" +
"&type0-0-0=noop&value0-0-0=&cmdtype=doit"
- +
"&order=Reuse+same+sort+as+last+time", config.toString());
- }
-
- public void testModifySampler() throws Exception {
-
testProcessingHTMLFile("/testfiles/jmeter_home_page.html");
- }
-
- public void testModifySamplerWithRelativeLink() throws
Exception {
-
testProcessingHTMLFile("/testfiles/jmeter_home_page_with_relative_links.html");
- }
-
- // * Feature not yet implemented. TODO: implement it.
- public void testModifySamplerWithBaseHRef() throws Exception {
-
testProcessingHTMLFile("/testfiles/jmeter_home_page_with_base_href.html");
- }
- // */
}
}
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java?rev=372390&r1=372389&r2=372390&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
Wed Jan 25 17:26:49 2006
@@ -25,7 +25,6 @@
import java.util.List;
import org.apache.jmeter.config.Argument;
-import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.testelement.property.PropertyIterator;
@@ -43,6 +42,8 @@
import org.w3c.tidy.Tidy;
import org.xml.sax.SAXException;
+// For Junit tests @see TestHtmlParsingUtils
+
/**
* @author Michael Stover Created June 14, 2001
*/
@@ -312,42 +313,5 @@
String action = atts.getNamedItem("action").getNodeValue();
HTTPSamplerBase url = createUrlFromAnchor(action, context);
return url;
- }
-
- // /////////////////// Start of Test Code /////////////////
-
- // TODO: need more tests
-
- public static class Test extends JMeterTestCase {
-
- public Test(String name) {
- super(name);
- }
-
- protected void setUp() {
- }
-
- public void testGetParser() throws Exception {
- getParser();
- }
-
- public void testGetDom() throws Exception {
- getDOM("<HTML></HTML>");
- getDOM("");
- }
-
- public void testIsArgumentMatched() throws Exception {
- Argument arg = new Argument();
- Argument argp = new Argument();
- assertTrue(isArgumentMatched(arg, argp));
-
- arg = new Argument("test", "abcd");
- argp = new Argument("test", "a.*d");
- assertTrue(isArgumentMatched(arg, argp));
-
- arg = new Argument("test", "abcd");
- argp = new Argument("test", "a.*e");
- assertFalse(isArgumentMatched(arg, argp));
- }
}
}
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java?rev=372390&r1=372389&r2=372390&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
Wed Jan 25 17:26:49 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
@@ -21,12 +20,13 @@
import java.io.Serializable;
import java.util.ArrayList;
-import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
+// For JUnit tests, @see TestLogFilter
+
/**
* Description:<br>
* <br>
@@ -408,144 +408,6 @@
} catch (Exception exception) {
exception.printStackTrace();
return null;
- }
- }
-
- // ///////////////////// Start of Test Code //////////////////////
-
- public static class Test extends JMeterTestCase {
-
- private static final String TESTSTR = "/test/helloworld.html";
-
- private static final String TESTSTROUT = "/test/helloworld.jsp";
-
- private static class TestData {
- private final String file;
-
- private final boolean exclfile;
-
- private final boolean inclfile;
-
- private final boolean exclpatt;
-
- private final boolean inclpatt;
-
- TestData(String f, boolean exf, boolean inf, boolean
exp, boolean inp) {
- file = f;
- exclfile = exf;
- inclfile = inf;
- exclpatt = exp;
- inclpatt = inp;
- }
- }
-
- private static final String[] INCL = { "hello.html",
"index.html", "/index.jsp" };
-
- private static final String[] PATTERNS = { "index", ".jtml" };
-
- private static final TestData[] TESTDATA = {
- // file exclf inclf exclp inclp
- new TestData("/test/hello.jsp", true, false,
true, false),
- new TestData("/test/one/hello.html", false,
true, true, false),
- new TestData("hello.jsp", true, false, true,
false),
- new TestData("hello.htm", true, false, true,
false),
- new TestData("/test/open.jsp", true, false,
true, false),
- new TestData("/test/open.html", true, false,
true, false),
- new TestData("/index.jsp", false, true, false,
true),
- new TestData("/index.jhtml", true, false,
false, true),
- new TestData("newindex.jsp", true, false,
false, true),
- new TestData("oldindex.jsp", true, false,
false, true),
- new TestData("oldindex1.jsp", true, false,
false, true),
- new TestData("oldindex2.jsp", true, false,
false, true),
- new TestData("oldindex3.jsp", true, false,
false, true),
- new TestData("oldindex4.jsp", true, false,
false, true),
- new TestData("oldindex5.jsp", true, false,
false, true),
- new TestData("oldindex6.jsp", true, false,
false, true),
- new TestData("/test/index.htm", true, false,
false, true) };
-
- public void testConstruct() {
- new LogFilter();
- }
-
- private LogFilter testf;
-
- public void setUp() {
- testf = new LogFilter();
- }
-
- public void testReplaceExtension() {
- testf.setReplaceExtension("html", "jsp");
- testf.isFiltered(TESTSTR,null);// set the required
variables
- assertEquals(TESTSTROUT, testf.filter(TESTSTR));
- }
-
- public void testExcludeFiles() {
- testf.excludeFiles(INCL);
- for (int idx = 0; idx < TESTDATA.length; idx++) {
- TestData td = TESTDATA[idx];
- String theFile = td.file;
- boolean expect = td.exclfile;
-
- testf.isFiltered(theFile,null);
- String line = testf.filter(theFile);
- if (line != null) {
- assertTrue("Expect to accept " +
theFile, expect);
- } else {
- assertFalse("Expect to reject " +
theFile, expect);
- }
- }
- }
-
- public void testIncludeFiles() {
- testf.includeFiles(INCL);
- for (int idx = 0; idx < TESTDATA.length; idx++) {
- TestData td = TESTDATA[idx];
- String theFile = td.file;
- boolean expect = td.inclfile;
-
- testf.isFiltered(theFile,null);
- String line = testf.filter(theFile);
- if (line != null) {
- assertTrue("Expect to accept " +
theFile, expect);
- } else {
- assertFalse("Expect to reject " +
theFile, expect);
- }
- }
-
- }
-
- public void testExcludePattern() {
- testf.excludePattern(PATTERNS);
- for (int idx = 0; idx < TESTDATA.length; idx++) {
- TestData td = TESTDATA[idx];
- String theFile = td.file;
- boolean expect = td.exclpatt;
-
- assertEquals(!expect,
testf.isFiltered(theFile,null));
- String line = testf.filter(theFile);
- if (line != null) {
- assertTrue("Expect to accept " +
theFile, expect);
- } else {
- assertFalse("Expect to reject " +
theFile, expect);
- }
- }
- }
-
- public void testIncludePattern() {
- testf.includePattern(PATTERNS);
- for (int idx = 0; idx < TESTDATA.length; idx++) {
- TestData td = TESTDATA[idx];
- String theFile = td.file;
- boolean expect = td.inclpatt;
-
- assertEquals(!expect,
testf.isFiltered(theFile,null));
- String line = testf.filter(theFile);
- if (line != null) {
- assertTrue("Expect to accept " +
theFile, expect);
- } else {
- assertFalse("Expect to reject " +
theFile, expect);
- }
- }
}
}
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java?rev=372390&r1=372389&r2=372390&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
Wed Jan 25 17:26:49 2006
@@ -1,4 +1,3 @@
-// $Header$
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
@@ -27,13 +26,13 @@
import java.util.StringTokenizer;
import java.util.Vector;
-import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
+// For JUnit tests, @see TestTCLogParser
+
/**
* Description:<br>
* <br>
@@ -542,38 +541,4 @@
// do nothing
}
}
-
- // TODO write some more tests
-
- // /////////////////////////// Start of Test Code
//////////////////////////
-
- public static class Test extends JMeterTestCase {
- private static final TCLogParser tclp = new TCLogParser();
-
- private static final String URL1 = "127.0.0.1 - -
[08/Jan/2003:07:03:54 -0500] \"GET /addrbook/ HTTP/1.1\" 200 1981";
-
- private static final String URL2 = "127.0.0.1 - -
[08/Jan/2003:07:03:54 -0500] \"GET /addrbook?x=y HTTP/1.1\" 200 1981";
-
- public void testConstruct() throws Exception {
- TCLogParser tcp;
- tcp = new TCLogParser();
- assertNull("Should not have set the filename",
tcp.FILENAME);
-
- String file = "testfiles/access.log";
- tcp = new TCLogParser(file);
- assertEquals("Filename should have been saved", file,
tcp.FILENAME);
- }
-
- public void testcleanURL() throws Exception {
- String res = tclp.cleanURL(URL1);
- assertEquals("/addrbook/", res);
- assertNull(tclp.stripFile(res, new HTTPNullSampler()));
- }
-
- public void testcheckURL() throws Exception {
- assertFalse("URL is not have a query",
tclp.checkURL(URL1));
- assertTrue("URL is a query", tclp.checkURL(URL2));
- }
- }
-
}
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java?rev=372390&view=auto
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
(added)
+++
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
Wed Jan 25 17:26:49 2006
@@ -0,0 +1,60 @@
+/*
+ * 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.control;
+
+import java.net.URL;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+
+/**
+ * This class provides a way to provide Authorization in jmeter requests. The
+ * format of the authorization file is: URL user pass where URL is an HTTP URL,
+ * user a username to use and pass the appropriate password.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Raphael Luta</a>
+ * @version $Revision$
+ */
+public class TestAuthManager extends JMeterTestCase {
+ public TestAuthManager(String name) {
+ super(name);
+ }
+
+ public void testHttp() throws Exception {
+ assertTrue(AuthManager.isSupportedProtocol(new
URL("http:")));
+ }
+
+ public void testHttps() throws Exception {
+ assertTrue(AuthManager.isSupportedProtocol(new
URL("https:")));
+ }
+
+ public void testFile() throws Exception {
+ AuthManager am = new AuthManager();
+ CollectionProperty ao = am.getAuthObjects();
+ assertEquals(0, ao.size());
+ am.addFile("testfiles/TestAuth.txt");
+ assertEquals(5, ao.size());
+ Authorization at;
+ at = am.getAuthForURL(new URL("http://a.b.c/"));
+ assertEquals("login", at.getUser());
+ assertEquals("password", at.getPass());
+ at = am.getAuthForURL(new URL("http://a.b.c/1"));
+ assertEquals("login1", at.getUser());
+ assertEquals("password1", at.getPass());
+ }
+}
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java?rev=372390&view=auto
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
(added)
+++
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
Wed Jan 25 17:26:49 2006
@@ -0,0 +1,96 @@
+/*
+ * 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.modifier;
+
+import java.io.FileInputStream;
+import java.net.URL;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.save.SaveService;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jorphan.io.TextFile;
+
+/**
+ * @author Michael Stover
+ * @version $Revision$
+ */
+public class TestAnchorModifier extends JMeterTestCase {
+ public TestAnchorModifier(String name) {
+ super(name);
+ }
+
+ private JMeterContext jmctx = null;
+
+ public void setUp() {
+ jmctx = JMeterContextService.getContext();
+ }
+
+ public void testProcessingHTMLFile(String HTMLFileName) throws
Exception {
+ HTTPSamplerBase config = (HTTPSamplerBase)
SaveService.loadTree(
+ new
FileInputStream(System.getProperty("user.dir") +
"/testfiles/load_bug_list.jmx")).getArray()[0];
+ config.setRunningVersion(true);
+ HTTPSampleResult result = new HTTPSampleResult();
+ HTTPSamplerBase context = (HTTPSamplerBase)
SaveService.loadTree(
+ new
FileInputStream(System.getProperty("user.dir") +
"/testfiles/Load_JMeter_Page.jmx")).getArray()[0];
+ jmctx.setCurrentSampler(context);
+ jmctx.setCurrentSampler(config);
+ result.setResponseData(new
TextFile(System.getProperty("user.dir") + HTMLFileName).getText().getBytes());
+ result.setSampleLabel(context.toString());
+ result.setSamplerData(context.toString());
+ result.setURL(new
URL("http://issues.apache.org/fakepage.html"));
+ jmctx.setPreviousResult(result);
+ AnchorModifier modifier = new AnchorModifier();
+ modifier.setThreadContext(jmctx);
+ modifier.process();
+
assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
+ +
"bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED"
+ +
"&email1=&emailtype1=substring&emailassigned_to1=1"
+ +
"&email2=&emailtype2=substring&emailreporter2=1" +
"&bugidtype=include&bug_id=&changedin=&votes="
+ +
"&chfieldfrom=&chfieldto=Now&chfieldvalue="
+ +
"&product=JMeter&short_desc=&short_desc_type=substring"
+ +
"&long_desc=&long_desc_type=substring&bug_file_loc=" +
"&bug_file_loc_type=substring&keywords="
+ + "&keywords_type=anywords" +
"&field0-0-0=noop&type0-0-0=noop&value0-0-0="
+ +
"&cmdtype=doit&order=Reuse+same+sort+as+last+time", config.toString());
+ config.recoverRunningVersion();
+
assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
+ +
"bug_status=.*&bug_status=.*&bug_status=.*&email1="
+ +
"&emailtype1=substring&emailassigned_to1=1&email2=" +
"&emailtype2=substring&emailreporter2=1"
+ +
"&bugidtype=include&bug_id=&changedin=&votes=" +
"&chfieldfrom=&chfieldto=Now&chfieldvalue="
+ +
"&product=JMeter&short_desc=&short_desc_type=substring"
+ +
"&long_desc=&long_desc_type=substring&bug_file_loc=" +
"&bug_file_loc_type=substring&keywords="
+ +
"&keywords_type=anywords&field0-0-0=noop" +
"&type0-0-0=noop&value0-0-0=&cmdtype=doit"
+ +
"&order=Reuse+same+sort+as+last+time", config.toString());
+ }
+
+ public void testModifySampler() throws Exception {
+
testProcessingHTMLFile("/testfiles/jmeter_home_page.html");
+ }
+
+ public void testModifySamplerWithRelativeLink() throws
Exception {
+
testProcessingHTMLFile("/testfiles/jmeter_home_page_with_relative_links.html");
+ }
+
+ // * Feature not yet implemented. TODO: implement it.
+ public void testModifySamplerWithBaseHRef() throws Exception {
+
testProcessingHTMLFile("/testfiles/jmeter_home_page_with_base_href.html");
+ }
+ // */
+}
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java?rev=372390&view=auto
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
(added)
+++
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
Wed Jan 25 17:26:49 2006
@@ -0,0 +1,55 @@
+/*
+ * 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.parser;
+
+import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.junit.JMeterTestCase;
+
+// TODO: need more tests
+public final class TestHtmlParsingUtils extends JMeterTestCase {
+
+ public TestHtmlParsingUtils(String name) {
+ super(name);
+ }
+
+ protected void setUp() {
+ }
+
+ public void testGetParser() throws Exception {
+ HtmlParsingUtils.getParser();
+ }
+
+ public void testGetDom() throws Exception {
+ HtmlParsingUtils.getDOM("<HTML></HTML>");
+ HtmlParsingUtils.getDOM("");
+ }
+
+ public void testIsArgumentMatched() throws Exception {
+ Argument arg = new Argument();
+ Argument argp = new Argument();
+ assertTrue(HtmlParsingUtils.isArgumentMatched(arg,
argp));
+
+ arg = new Argument("test", "abcd");
+ argp = new Argument("test", "a.*d");
+ assertTrue(HtmlParsingUtils.isArgumentMatched(arg,
argp));
+
+ arg = new Argument("test", "abcd");
+ argp = new Argument("test", "a.*e");
+ assertFalse(HtmlParsingUtils.isArgumentMatched(arg,
argp));
+ }
+}
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java?rev=372390&view=auto
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
(added)
+++
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
Wed Jan 25 17:26:49 2006
@@ -0,0 +1,156 @@
+/*
+ * 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.util.accesslog;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+
+public class TestLogFilter extends JMeterTestCase {
+
+ private static final String TESTSTR = "/test/helloworld.html";
+
+ private static final String TESTSTROUT = "/test/helloworld.jsp";
+
+ private static class TestData {
+ private final String file;
+
+ private final boolean exclfile;
+
+ private final boolean inclfile;
+
+ private final boolean exclpatt;
+
+ private final boolean inclpatt;
+
+ TestData(String f, boolean exf, boolean inf, boolean
exp, boolean inp) {
+ file = f;
+ exclfile = exf;
+ inclfile = inf;
+ exclpatt = exp;
+ inclpatt = inp;
+ }
+ }
+
+ private static final String[] INCL = { "hello.html",
"index.html", "/index.jsp" };
+
+ private static final String[] PATTERNS = { "index", ".jtml" };
+
+ private static final TestData[] TESTDATA = {
+ // file exclf inclf exclp inclp
+ new TestData("/test/hello.jsp", true, false,
true, false),
+ new TestData("/test/one/hello.html", false,
true, true, false),
+ new TestData("hello.jsp", true, false, true,
false),
+ new TestData("hello.htm", true, false, true,
false),
+ new TestData("/test/open.jsp", true, false,
true, false),
+ new TestData("/test/open.html", true, false,
true, false),
+ new TestData("/index.jsp", false, true, false,
true),
+ new TestData("/index.jhtml", true, false,
false, true),
+ new TestData("newindex.jsp", true, false,
false, true),
+ new TestData("oldindex.jsp", true, false,
false, true),
+ new TestData("oldindex1.jsp", true, false,
false, true),
+ new TestData("oldindex2.jsp", true, false,
false, true),
+ new TestData("oldindex3.jsp", true, false,
false, true),
+ new TestData("oldindex4.jsp", true, false,
false, true),
+ new TestData("oldindex5.jsp", true, false,
false, true),
+ new TestData("oldindex6.jsp", true, false,
false, true),
+ new TestData("/test/index.htm", true, false,
false, true) };
+
+ public void testConstruct() {
+ new LogFilter();
+ }
+
+ private LogFilter testf;
+
+ public void setUp() {
+ testf = new LogFilter();
+ }
+
+ public void testReplaceExtension() {
+ testf.setReplaceExtension("html", "jsp");
+ testf.isFiltered(TESTSTR,null);// set the required
variables
+ assertEquals(TESTSTROUT, testf.filter(TESTSTR));
+ }
+
+ public void testExcludeFiles() {
+ testf.excludeFiles(INCL);
+ for (int idx = 0; idx < TESTDATA.length; idx++) {
+ TestData td = TESTDATA[idx];
+ String theFile = td.file;
+ boolean expect = td.exclfile;
+
+ testf.isFiltered(theFile,null);
+ String line = testf.filter(theFile);
+ if (line != null) {
+ assertTrue("Expect to accept " +
theFile, expect);
+ } else {
+ assertFalse("Expect to reject " +
theFile, expect);
+ }
+ }
+ }
+
+ public void testIncludeFiles() {
+ testf.includeFiles(INCL);
+ for (int idx = 0; idx < TESTDATA.length; idx++) {
+ TestData td = TESTDATA[idx];
+ String theFile = td.file;
+ boolean expect = td.inclfile;
+
+ testf.isFiltered(theFile,null);
+ String line = testf.filter(theFile);
+ if (line != null) {
+ assertTrue("Expect to accept " +
theFile, expect);
+ } else {
+ assertFalse("Expect to reject " +
theFile, expect);
+ }
+ }
+
+ }
+
+ public void testExcludePattern() {
+ testf.excludePattern(PATTERNS);
+ for (int idx = 0; idx < TESTDATA.length; idx++) {
+ TestData td = TESTDATA[idx];
+ String theFile = td.file;
+ boolean expect = td.exclpatt;
+
+ assertEquals(!expect,
testf.isFiltered(theFile,null));
+ String line = testf.filter(theFile);
+ if (line != null) {
+ assertTrue("Expect to accept " +
theFile, expect);
+ } else {
+ assertFalse("Expect to reject " +
theFile, expect);
+ }
+ }
+ }
+
+ public void testIncludePattern() {
+ testf.includePattern(PATTERNS);
+ for (int idx = 0; idx < TESTDATA.length; idx++) {
+ TestData td = TESTDATA[idx];
+ String theFile = td.file;
+ boolean expect = td.inclpatt;
+
+ assertEquals(!expect,
testf.isFiltered(theFile,null));
+ String line = testf.filter(theFile);
+ if (line != null) {
+ assertTrue("Expect to accept " +
theFile, expect);
+ } else {
+ assertFalse("Expect to reject " +
theFile, expect);
+ }
+ }
+ }
+}
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java?rev=372390&view=auto
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
(added)
+++
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
Wed Jan 25 17:26:49 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.util.accesslog;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
+
+// TODO - more tests needed
+
+public class TestTCLogParser extends JMeterTestCase {
+ private static final TCLogParser tclp = new TCLogParser();
+
+ private static final String URL1 = "127.0.0.1 - -
[08/Jan/2003:07:03:54 -0500] \"GET /addrbook/ HTTP/1.1\" 200 1981";
+
+ private static final String URL2 = "127.0.0.1 - -
[08/Jan/2003:07:03:54 -0500] \"GET /addrbook?x=y HTTP/1.1\" 200 1981";
+
+ public void testConstruct() throws Exception {
+ TCLogParser tcp;
+ tcp = new TCLogParser();
+ assertNull("Should not have set the filename",
tcp.FILENAME);
+
+ String file = "testfiles/access.log";
+ tcp = new TCLogParser(file);
+ assertEquals("Filename should have been saved", file,
tcp.FILENAME);
+ }
+
+ public void testcleanURL() throws Exception {
+ String res = tclp.cleanURL(URL1);
+ assertEquals("/addrbook/", res);
+ assertNull(tclp.stripFile(res, new HTTPNullSampler()));
+ }
+
+ public void testcheckURL() throws Exception {
+ assertFalse("URL is not have a query",
tclp.checkURL(URL1));
+ assertTrue("URL is a query", tclp.checkURL(URL2));
+ }
+}
\ No newline at end of file
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange:
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]