sebb        2004/07/03 07:04:52

  Modified:    src/protocol/http/org/apache/jmeter/protocol/http/proxy
                        Proxy.java HttpRequestHdr.java
               src/protocol/http/org/apache/jmeter/junit/protocol/http/config
                        UrlConfigTest.java
               src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog
                        TCLogParser.java
               src/protocol/http/org/apache/jmeter/junit/protocol/http/parser
                        HtmlParserTester.java
               src/protocol/http/org/apache/jmeter/protocol/http/parser
                        HtmlParsingUtils.java
  Log:
  Use HTTPSamplerBase and HTTPNullSampler where possible
  
  Revision  Changes    Path
  1.19      +4 -3      
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
  
  Index: Proxy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Proxy.java        16 Apr 2004 13:21:45 -0000      1.18
  +++ Proxy.java        3 Jul 2004 14:04:52 -0000       1.19
  @@ -28,6 +28,7 @@
   
   import org.apache.jmeter.protocol.http.control.HeaderManager;
   import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
  +import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
   import org.apache.jmeter.samplers.SampleResult;
   import org.apache.jmeter.testelement.TestElement;
   import org.apache.jorphan.logging.LoggingManager;
  @@ -101,7 +102,7 @@
           SampleResult result = null;
           HeaderManager headers = null;
   
  -        HTTPSampler sampler = new HTTPSampler();
  +        HTTPSamplerBase sampler = new HTTPSampler();
           try
           {
              request.parse(new BufferedInputStream(clientSocket.getInputStream()));
  
  
  
  1.27      +6 -5      
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
  
  Index: HttpRequestHdr.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- HttpRequestHdr.java       21 May 2004 16:58:26 -0000      1.26
  +++ HttpRequestHdr.java       3 Jul 2004 14:04:52 -0000       1.27
  @@ -35,6 +35,7 @@
   import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
   import org.apache.jmeter.protocol.http.gui.HeaderPanel;
   import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
  +import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
   import org.apache.jmeter.testelement.TestElement;
   import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jorphan.logging.LoggingManager;
  @@ -179,13 +180,13 @@
           return manager;
       }
       
  -    public HTTPSampler getSampler()
  +    public HTTPSamplerBase getSampler()
           throws MalformedURLException, IOException, ProtocolException
       {
        // Damn! A whole new GUI just to instantiate a test element?
        // Isn't there a beter way? 
           HttpTestSampleGui tempGui = new HttpTestSampleGui();
  -        HTTPSampler result = createSampler();
  +        HTTPSamplerBase result = createSampler();
           tempGui.configure(result);
           tempGui.modifyTestElement(result);
           result.setFollowRedirects(false);
  @@ -218,10 +219,10 @@
           }
       }
       
  -    private HTTPSampler createSampler()
  +    private HTTPSamplerBase createSampler()
       {
           MultipartUrlConfig urlConfig = null;
  -        HTTPSampler sampler = new HTTPSampler();
  +        HTTPSamplerBase sampler = new HTTPSampler();
           sampler.setDomain(serverName());
           log.debug("Proxy: setting server: " + sampler.getDomain());
           sampler.setMethod(method);
  @@ -405,7 +406,7 @@
                       + "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()));
  -            HTTPSampler s = req.getSampler();
  +            HTTPSamplerBase s = req.getSampler();
               assertEquals(s.getArguments().getArguments().size(), 13);
           }
       }
  
  
  
  1.8       +22 -21    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/junit/protocol/http/config/UrlConfigTest.java
  
  Index: UrlConfigTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/junit/protocol/http/config/UrlConfigTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UrlConfigTest.java        21 Feb 2004 21:28:36 -0000      1.7
  +++ UrlConfigTest.java        3 Jul 2004 14:04:52 -0000       1.8
  @@ -20,7 +20,8 @@
   
   import org.apache.jmeter.config.Arguments;
   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.protocol.http.sampler.HTTPNullSampler;
   import org.apache.jmeter.testelement.property.JMeterProperty;
   import org.apache.jmeter.testelement.property.NullProperty;
   import org.apache.jmeter.testelement.property.TestElementProperty;
  @@ -31,9 +32,9 @@
    */
   public class UrlConfigTest extends JMeterTestCase
   {
  -    HTTPSampler config;
  -    HTTPSampler defaultConfig;
  -    HTTPSampler partialConfig;
  +    HTTPSamplerBase config;
  +    HTTPSamplerBase defaultConfig;
  +    HTTPSamplerBase partialConfig;
   
       public UrlConfigTest(String name)
       {
  @@ -46,20 +47,20 @@
           args.addArgument("username", "mstover");
           args.addArgument("password", "pass");
           args.addArgument("action", "login");
  -        config = new HTTPSampler();
  +        config = new HTTPNullSampler();
           config.setName("Full Config");
  -        config.setProperty(HTTPSampler.DOMAIN, "www.lazer.com");
  -        config.setProperty(HTTPSampler.PATH, "login.jsp");
  -        config.setProperty(HTTPSampler.METHOD, HTTPSampler.POST);
  +        config.setProperty(HTTPSamplerBase.DOMAIN, "www.lazer.com");
  +        config.setProperty(HTTPSamplerBase.PATH, "login.jsp");
  +        config.setProperty(HTTPSamplerBase.METHOD, HTTPSamplerBase.POST);
           config.setProperty(
  -            new TestElementProperty(HTTPSampler.ARGUMENTS, args));
  -        defaultConfig = new HTTPSampler();
  +            new TestElementProperty(HTTPSamplerBase.ARGUMENTS, args));
  +        defaultConfig = new HTTPNullSampler();
           defaultConfig.setName("default");
  -        defaultConfig.setProperty(HTTPSampler.DOMAIN, "www.xerox.com");
  -        defaultConfig.setProperty(HTTPSampler.PATH, "default.html");
  -        partialConfig = new HTTPSampler();
  -        partialConfig.setProperty(HTTPSampler.PATH, "main.jsp");
  -        partialConfig.setProperty(HTTPSampler.METHOD, HTTPSampler.GET);
  +        defaultConfig.setProperty(HTTPSamplerBase.DOMAIN, "www.xerox.com");
  +        defaultConfig.setProperty(HTTPSamplerBase.PATH, "default.html");
  +        partialConfig = new HTTPNullSampler();
  +        partialConfig.setProperty(HTTPSamplerBase.PATH, "main.jsp");
  +        partialConfig.setProperty(HTTPSamplerBase.METHOD, HTTPSamplerBase.GET);
       }
   
       public void testSimpleConfig()
  @@ -70,15 +71,15 @@
   
       public void testOverRide()
       {
  -     JMeterProperty jmp =partialConfig.getProperty(HTTPSampler.DOMAIN);
  +     JMeterProperty jmp =partialConfig.getProperty(HTTPSamplerBase.DOMAIN);
           assertTrue(jmp instanceof NullProperty);
  -        assertTrue(new NullProperty(HTTPSampler.DOMAIN).equals(jmp));
  +        assertTrue(new NullProperty(HTTPSamplerBase.DOMAIN).equals(jmp));
           partialConfig.addTestElement(defaultConfig);
           assertEquals(
  -            partialConfig.getPropertyAsString(HTTPSampler.DOMAIN),
  +            partialConfig.getPropertyAsString(HTTPSamplerBase.DOMAIN),
               "www.xerox.com");
           assertEquals(
  -            partialConfig.getPropertyAsString(HTTPSampler.PATH),
  +            partialConfig.getPropertyAsString(HTTPSamplerBase.PATH),
               "main.jsp");
       }
   }
  
  
  
  1.15      +9 -8      
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
  
  Index: TCLogParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TCLogParser.java  8 Jun 2004 21:41:02 -0000       1.14
  +++ TCLogParser.java  3 Jul 2004 14:04:52 -0000       1.15
  @@ -26,7 +26,8 @@
   import java.util.Vector;
   
   import org.apache.jmeter.junit.JMeterTestCase;
  -import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
  +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;
  @@ -277,7 +278,7 @@
           String cleanedLine = this.cleanURL(line);
           log.debug("parsing line: "  + line);
           // now we set request method
  -        el.setProperty(HTTPSampler.METHOD,RMETHOD);
  +        el.setProperty(HTTPSamplerBase.METHOD,RMETHOD);
           if (FILTER != null)
           {
              log.debug("filter is not null");
  @@ -437,12 +438,12 @@
           {
               StringTokenizer tokens = this.tokenize(url, "?");
               this.URL_PATH = tokens.nextToken();
  -            el.setProperty(HTTPSampler.PATH,URL_PATH);
  +            el.setProperty(HTTPSamplerBase.PATH,URL_PATH);
               return tokens.nextToken();
           }
           else
           {
  -           el.setProperty(HTTPSampler.PATH,url);
  +           el.setProperty(HTTPSamplerBase.PATH,url);
               return null;
           }
       }
  @@ -489,7 +490,7 @@
        */
       public void convertStringToJMRequest(String text,TestElement el)
       {
  -        ((HTTPSampler)el).parseArguments(text);
  +        ((HTTPSamplerBase)el).parseArguments(text);
       }
   
       /**
  @@ -621,7 +622,7 @@
                {
                        String res = tclp.cleanURL(URL1);
                        assertEquals("/addrbook/",res);
  -                     assertNull(tclp.stripFile(res,new HTTPSampler()));
  +                     assertNull(tclp.stripFile(res,new HTTPNullSampler()));
                }
                public void testcheckURL() throws Exception
                {
  
  
  
  1.13      +31 -30    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/junit/protocol/http/parser/HtmlParserTester.java
  
  Index: HtmlParserTester.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/junit/protocol/http/parser/HtmlParserTester.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HtmlParserTester.java     22 Feb 2004 19:20:24 -0000      1.12
  +++ HtmlParserTester.java     3 Jul 2004 14:04:52 -0000       1.13
  @@ -24,7 +24,8 @@
   import org.apache.jmeter.junit.JMeterTestCase;
   import org.apache.jmeter.protocol.http.modifier.AnchorModifier;
   import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
  -import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
  +import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
  +import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
   import org.apache.jmeter.threads.JMeterContext;
   import org.apache.jmeter.threads.JMeterContextService;
   
  @@ -57,8 +58,8 @@
        */
       public void testSimpleParse() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig(".*/index\\.html");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig(".*/index\\.html");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -79,8 +80,8 @@
   
       public void testSimpleParse2() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig("/index\\.html");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig("/index\\.html");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -105,9 +106,9 @@
   
       public void testSimpleParse3() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig(".*index.*");
  +        HTTPSamplerBase config = makeUrlConfig(".*index.*");
           config.getArguments().addArgument("param1", "value1");
  -        HTTPSampler context =
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -129,8 +130,8 @@
   
       public void testSimpleParse4() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig("/subdir/index\\..*");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig("/subdir/index\\..*");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -149,8 +150,8 @@
   
       public void testSimpleParse5() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig("/subdir/index\\.h.*");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig("/subdir/index\\.h.*");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/one/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -169,8 +170,8 @@
   
       public void testFailSimpleParse1() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig(".*index.*?param2=.+1");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig(".*index.*?param2=.+1");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -190,8 +191,8 @@
   
       public void testFailSimpleParse3() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig("/home/index.html");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig("/home/index.html");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -211,8 +212,8 @@
   
       public void testFailSimpleParse2() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig(".*login\\.html");
  -        HTTPSampler context =
  +        HTTPSamplerBase config = makeUrlConfig(".*login\\.html");
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -237,10 +238,10 @@
        */
       public void testSimpleFormParse() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig(".*index.html");
  +        HTTPSamplerBase config = makeUrlConfig(".*index.html");
           config.addArgument("test", "g.*");
  -        config.setMethod(HTTPSampler.POST);
  -        HTTPSampler context =
  +        config.setMethod(HTTPSamplerBase.POST);
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -266,10 +267,10 @@
        */
       public void testBadCharParse() throws Exception
       {
  -        HTTPSampler config = makeUrlConfig(".*index.html");
  +        HTTPSamplerBase config = makeUrlConfig(".*index.html");
           config.addArgument("te$st", "g.*");
  -        config.setMethod(HTTPSampler.POST);
  -        HTTPSampler context =
  +        config.setMethod(HTTPSamplerBase.POST);
  +        HTTPSamplerBase context =
               makeContext("http://www.apache.org/subdir/previous.html";);
           String responseText =
               "<html><head><title>Test page</title></head><body>"
  @@ -290,10 +291,10 @@
           assertEquals("te%24st=goto", config.getQueryString());
       }
   
  -    private HTTPSampler makeContext(String url) throws MalformedURLException
  +    private HTTPSamplerBase makeContext(String url) throws MalformedURLException
       {
           URL u = new URL(url);
  -        HTTPSampler context = new HTTPSampler();
  +        HTTPSamplerBase context = new HTTPNullSampler();
           context.setDomain(u.getHost());
           context.setPath(u.getPath());
           context.setPort(u.getPort());
  @@ -302,11 +303,11 @@
           return context;
       }
   
  -    private HTTPSampler makeUrlConfig(String path)
  +    private HTTPSamplerBase makeUrlConfig(String path)
       {
  -        HTTPSampler config = new HTTPSampler();
  +        HTTPSamplerBase config = new HTTPNullSampler();
           config.setDomain("www.apache.org");
  -        config.setMethod(HTTPSampler.GET);
  +        config.setMethod(HTTPSamplerBase.GET);
           config.setPath(path);
           config.setPort(80);
           config.setProtocol("http");
  
  
  
  1.14      +6 -6      
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
  
  Index: HtmlParsingUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HtmlParsingUtils.java     3 Jul 2004 02:08:16 -0000       1.13
  +++ HtmlParsingUtils.java     3 Jul 2004 14:04:52 -0000       1.14
  @@ -245,11 +245,11 @@
       }
   
       /**
  -     * Create a new URL based on an HREF string plus a contextual URL object.
  +     * Create a new Sampler based on an HREF string plus a contextual URL object.
        * Given that an HREF string might be of three possible forms, some
        * processing is required.
        */
  -    public static HTTPSampler createUrlFromAnchor(
  +    public static HTTPSamplerBase createUrlFromAnchor(
           String parsedUrlString,
           URL context)
           throws MalformedURLException
  @@ -260,7 +260,7 @@
                   +", base: "+context);
           }
           URL url= new URL(context, parsedUrlString);
  -        HTTPSampler sampler = new HTTPSampler();
  +        HTTPSamplerBase sampler = new HTTPSampler();//TODO create appropriate 
sampler
           sampler.setDomain(url.getHost());
           sampler.setProtocol(url.getProtocol());
           sampler.setPort(url.getPort());
  @@ -303,7 +303,7 @@
           {
               if (inForm)
               {
  -                HTTPSampler url = (HTTPSampler) urlConfigs.getLast();
  +                HTTPSamplerBase url = (HTTPSamplerBase) urlConfigs.getLast();
                   if (tag.equalsIgnoreCase("form"))
                   {
                       try
  @@ -430,7 +430,7 @@
   
           return buf.toString();
       }
  -    private static HTTPSampler createFormUrlConfig(
  +    private static HTTPSamplerBase createFormUrlConfig(
           Node tempNode,
           URL context)
           throws MalformedURLException
  @@ -441,7 +441,7 @@
               throw new MalformedURLException();
           }
           String action = atts.getNamedItem("action").getNodeValue();
  -        HTTPSampler url = createUrlFromAnchor(action, context);
  +        HTTPSamplerBase url = createUrlFromAnchor(action, context);
           return url;
       }
       
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to