sebb        2004/06/10 16:01:19

  Modified:    src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        Tag: rel-2_0 HTTPSampler2.java HTTPSamplerBase.java
                        HTTPSampler.java
  Log:
  Move downloadPageResources to superclass; fix HttpSampler2 to show full URI in 
sample labels
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.8.2.6   +3 -102    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
  
  Index: HTTPSampler2.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java,v
  retrieving revision 1.8.2.5
  retrieving revision 1.8.2.6
  diff -u -r1.8.2.5 -r1.8.2.6
  --- HTTPSampler2.java 28 May 2004 00:36:22 -0000      1.8.2.5
  +++ HTTPSampler2.java 10 Jun 2004 23:01:19 -0000      1.8.2.6
  @@ -23,7 +23,6 @@
   import java.net.URL;
   
   import java.util.Date;
  -import java.util.Iterator;
   
   import org.apache.commons.httpclient.ConnectMethod;
   import org.apache.commons.httpclient.DefaultMethodRetryHandler;
  @@ -33,7 +32,6 @@
   import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.HttpMethodBase;
   import org.apache.commons.httpclient.HttpState;
  -import org.apache.commons.httpclient.NTCredentials;
   import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
   import org.apache.commons.httpclient.methods.GetMethod;
   import org.apache.commons.httpclient.methods.PostMethod;
  @@ -44,8 +42,6 @@
   import org.apache.jmeter.protocol.http.control.AuthManager;
   import org.apache.jmeter.protocol.http.control.CookieManager;
   import org.apache.jmeter.protocol.http.control.HeaderManager;
  -import org.apache.jmeter.protocol.http.parser.HTMLParseException;
  -import org.apache.jmeter.protocol.http.parser.HTMLParser;
   
   import org.apache.jmeter.testelement.property.CollectionProperty;
   import org.apache.jmeter.testelement.property.PropertyIterator;
  @@ -487,7 +483,7 @@
   
               // Now collect the results into the HTTPSampleResult:
   
  -            res.setSampleLabel(httpMethod.getPath());// Pick up Actual path (after 
redirects)
  +            res.setSampleLabel(httpMethod.getURI().toString());// Pick up Actual 
path (after redirects)
               res.setResponseData(responseData);
   
               res.setResponseCode(Integer.toString(statusCode));
  @@ -673,86 +669,6 @@
       }
   
       /**
  -     * Download the resources of an HTML page.
  -     * <p>
  -     * If createContainerResult is true, the returned result will contain one 
  -     * subsample for each request issued, including the original one that was 
  -     * passed in. It will otherwise look exactly like that original one.
  -     * <p>
  -     * If createContainerResult is false, one subsample will be added to the
  -     * provided result for each requests issued.
  -     * 
  -     * @param res           result of the initial request - must contain an HTML
  -     *                      response
  -     * @param createContainerResult whether to create a "container" or just
  -     *                      use the provided <code>res</code> for that purpose
  -     * @param frameDepth    Depth of this target in the frame structure.
  -     *                      Used only to prevent infinite recursion.
  -     * @return              "Container" result with one subsample per request
  -     *                      issued
  -     */
  -    private HTTPSampleResult downloadPageResources(
  -        HTTPSampleResult res,
  -        boolean createContainerResult,
  -        int frameDepth)
  -    {
  -        Iterator urls= null;
  -        try
  -        {
  -             if (res.getContentType().toLowerCase().indexOf("text/html") != -1)
  -             {
  -            urls=
  -                HTMLParser.getParser().getEmbeddedResourceURLs(
  -                    res.getResponseData(),
  -                    res.getURL());
  -             }
  -        }
  -        catch (HTMLParseException e)
  -        {
  -            // Don't break the world just because this failed:
  -            res.addSubResult(errorResult(e, null, 0));
  -            res.setSuccessful(false);
  -        }
  -
  -        // Iterate through the URLs and download each image:
  -        if (urls != null && urls.hasNext())
  -        {
  -            if (createContainerResult)
  -            {
  -                res= new HTTPSampleResult(res);
  -            }
  -
  -            while (urls.hasNext())
  -            {
  -                Object binURL= urls.next();
  -                try
  -                {
  -                    HTTPSampleResult binRes=
  -                        sample(
  -                            (URL)binURL,
  -                            GET,
  -                            false,
  -                            frameDepth + 1);
  -                    res.addSubResult(binRes);
  -                    res.setSuccessful(
  -                        res.isSuccessful() && binRes.isSuccessful());
  -                }
  -                catch (ClassCastException e)
  -                {
  -                    res.addSubResult(
  -                        errorResult(
  -                            new Exception(binURL + " is not a correct URI"),
  -                            null,
  -                            0));
  -                    res.setSuccessful(false);
  -                    continue;
  -                }
  -            }
  -        }
  -        return res;
  -    }
  -
  -    /**
        * From the <code>HttpState</code>, store all the "set-cookie"
        * key-pair values in the cookieManager of the <code>UrlConfig</code>.
        *
  @@ -783,21 +699,6 @@
                                                          )
                                                );
               }
  -        }
  -    }
  -
  -    public String toString()
  -    {
  -        try
  -        {
  -            return this.getUrl().toString()
  -                + ((POST.equals(getMethod()))
  -                    ? "\nQuery Data: " + getQueryString()
  -                    : "");
  -        }
  -        catch (MalformedURLException e)
  -        {
  -            return "";
           }
       }
   
  
  
  
  1.1.2.3   +84 -2     
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
  
  Index: HTTPSamplerBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- HTTPSamplerBase.java      24 May 2004 23:07:54 -0000      1.1.2.2
  +++ HTTPSamplerBase.java      10 Jun 2004 23:01:19 -0000      1.1.2.3
  @@ -20,6 +20,7 @@
   import java.io.PrintStream;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.Iterator;
   
   import org.apache.jmeter.config.Argument;
   import org.apache.jmeter.config.Arguments;
  @@ -27,6 +28,8 @@
   import org.apache.jmeter.protocol.http.control.AuthManager;
   import org.apache.jmeter.protocol.http.control.CookieManager;
   import org.apache.jmeter.protocol.http.control.HeaderManager;
  +import org.apache.jmeter.protocol.http.parser.HTMLParseException;
  +import org.apache.jmeter.protocol.http.parser.HTMLParser;
   import org.apache.jmeter.protocol.http.util.HTTPArgument;
   import org.apache.jmeter.samplers.AbstractSampler;
   import org.apache.jmeter.samplers.Entry;
  @@ -603,6 +606,85 @@
            };
        private static Substitution spaceSub = new StringSubstitution("%20");
   
  +    /**
  +     * Download the resources of an HTML page.
  +     * <p>
  +     * If createContainerResult is true, the returned result will contain one 
  +     * subsample for each request issued, including the original one that was 
  +     * passed in. It will otherwise look exactly like that original one.
  +     * <p>
  +     * If createContainerResult is false, one subsample will be added to the
  +     * provided result for each requests issued.
  +     * 
  +     * @param res           result of the initial request - must contain an HTML
  +     *                      response
  +     * @param createContainerResult whether to create a "container" or just
  +     *                      use the provided <code>res</code> for that purpose
  +     * @param frameDepth    Depth of this target in the frame structure.
  +     *                      Used only to prevent infinite recursion.
  +     * @return              "Container" result with one subsample per request
  +     *                      issued
  +     */
  +    protected HTTPSampleResult downloadPageResources(
  +        HTTPSampleResult res,
  +        boolean createContainerResult,
  +        int frameDepth)
  +    {
  +        Iterator urls= null;
  +        try
  +        {
  +             if (res.getContentType().toLowerCase().indexOf("text/html") != -1)
  +             {
  +            urls=
  +                HTMLParser.getParser().getEmbeddedResourceURLs(
  +                    res.getResponseData(),
  +                    res.getURL());
  +             }
  +        }
  +        catch (HTMLParseException e)
  +        {
  +            // Don't break the world just because this failed:
  +            res.addSubResult(errorResult(e, null, 0));
  +            res.setSuccessful(false);
  +        }
  +
  +        // Iterate through the URLs and download each image:
  +        if (urls != null && urls.hasNext())
  +        {
  +            if (createContainerResult)
  +            {
  +                res= new HTTPSampleResult(res);
  +            }
  +
  +            while (urls.hasNext())
  +            {
  +                Object binURL= urls.next();
  +                try
  +                {
  +                    HTTPSampleResult binRes=
  +                        sample(
  +                            (URL)binURL,
  +                            GET,
  +                            false,
  +                            frameDepth + 1);
  +                    res.addSubResult(binRes);
  +                    res.setSuccessful(
  +                        res.isSuccessful() && binRes.isSuccessful());
  +                }
  +                catch (ClassCastException e)
  +                {
  +                    res.addSubResult(
  +                        errorResult(
  +                            new Exception(binURL + " is not a correct URI"),
  +                            null,
  +                            0));
  +                    res.setSuccessful(false);
  +                    continue;
  +                }
  +            }
  +        }
  +        return res;
  +    }
   
        protected String encodeSpaces(String path) {
                // TODO JDK1.4 
  
  
  
  1.91.2.4  +2 -100    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
  
  Index: HTTPSampler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
  retrieving revision 1.91.2.3
  retrieving revision 1.91.2.4
  diff -u -r1.91.2.3 -r1.91.2.4
  --- HTTPSampler.java  28 May 2004 00:36:22 -0000      1.91.2.3
  +++ HTTPSampler.java  10 Jun 2004 23:01:19 -0000      1.91.2.4
  @@ -26,7 +26,6 @@
   import java.net.URL;
   import java.net.URLConnection;
   
  -import java.util.Iterator;
   import java.util.zip.GZIPInputStream;
   
   import org.apache.jmeter.config.Arguments;
  @@ -35,8 +34,6 @@
   import org.apache.jmeter.protocol.http.control.CookieManager;
   import org.apache.jmeter.protocol.http.control.Header;
   import org.apache.jmeter.protocol.http.control.HeaderManager;
  -import org.apache.jmeter.protocol.http.parser.HTMLParseException;
  -import org.apache.jmeter.protocol.http.parser.HTMLParser;
   
   import org.apache.jmeter.testelement.property.CollectionProperty;
   import org.apache.jmeter.testelement.property.PropertyIterator;
  @@ -681,86 +678,6 @@
           return totalRes;
       }
   
  -    /**
  -     * Download the resources of an HTML page.
  -     * <p>
  -     * If createContainerResult is true, the returned result will contain one 
  -     * subsample for each request issued, including the original one that was 
  -     * passed in. It will otherwise look exactly like that original one.
  -     * <p>
  -     * If createContainerResult is false, one subsample will be added to the
  -     * provided result for each requests issued.
  -     * 
  -     * @param res           result of the initial request - must contain an HTML
  -     *                      response
  -     * @param createContainerResult whether to create a "container" or just
  -     *                      use the provided <code>res</code> for that purpose
  -     * @param frameDepth    Depth of this target in the frame structure.
  -     *                      Used only to prevent infinite recursion.
  -     * @return              "Container" result with one subsample per request
  -     *                      issued
  -     */
  -    private HTTPSampleResult downloadPageResources(
  -        HTTPSampleResult res,
  -        boolean createContainerResult,
  -        int frameDepth)
  -    {
  -        Iterator urls= null;
  -        try
  -        {
  -             if (res.getContentType().toLowerCase().indexOf("text/html") != -1)
  -             {
  -            urls=
  -                HTMLParser.getParser().getEmbeddedResourceURLs(
  -                    res.getResponseData(),
  -                    res.getURL());
  -             }
  -        }
  -        catch (HTMLParseException e)
  -        {
  -            // Don't break the world just because this failed:
  -            res.addSubResult(errorResult(e, null, 0));
  -            res.setSuccessful(false);
  -        }
  -
  -        // Iterate through the URLs and download each image:
  -        if (urls != null && urls.hasNext())
  -        {
  -            if (createContainerResult)
  -            {
  -                res= new HTTPSampleResult(res);
  -            }
  -
  -            while (urls.hasNext())
  -            {
  -                Object binURL= urls.next();
  -                try
  -                {
  -                    HTTPSampleResult binRes=
  -                        sample(
  -                            (URL)binURL,
  -                            GET,
  -                            false,
  -                            frameDepth + 1);
  -                    res.addSubResult(binRes);
  -                    res.setSuccessful(
  -                        res.isSuccessful() && binRes.isSuccessful());
  -                }
  -                catch (ClassCastException e)
  -                {
  -                    res.addSubResult(
  -                        errorResult(
  -                            new Exception(binURL + " is not a correct URI"),
  -                            null,
  -                            0));
  -                    res.setSuccessful(false);
  -                    continue;
  -                }
  -            }
  -        }
  -        return res;
  -    }
  -
       protected void disconnect(HttpURLConnection conn)
       {
           if (conn != null)
  @@ -801,21 +718,6 @@
                           u);
                   }
               }
  -        }
  -    }
  -
  -    public String toString()
  -    {
  -        try
  -        {
  -            return this.getUrl().toString()
  -                + ((POST.equals(getMethod()))
  -                    ? "\nQuery Data: " + getQueryString()
  -                    : "");
  -        }
  -        catch (MalformedURLException e)
  -        {
  -            return "";
           }
       }
   
  
  
  

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

Reply via email to