jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1350999 - in /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler: HTTPSampleResult.java PostWriter.java PutWriter.java SoapSampler.java
Date Sat, 16 Jun 2012 21:30:19 GMT
On 16 June 2012 22:16, Philippe Mouawad <philippe.mouawad@gmail.com> wrote:
> Hello,
> It was to cleanup code.
> If we remove interface, won't we break plugins relying on it ?

Possibly, though they should really be using HTTPConstants.

JMeter code should also use HTTPConstants in all classes, except those
that currently implement the interface.

Later we need to consider if we can replace the interface with
HTTPConstants references (again, this may perhaps affect plugins).

> Regards
> Philippe.
>
> On Sat, Jun 16, 2012 at 11:08 PM, sebb <sebbaz@gmail.com> wrote:
>
>> On 16 June 2012 21:54,  <pmouawad@apache.org> wrote:
>> > Author: pmouawad
>> > Date: Sat Jun 16 20:54:51 2012
>> > New Revision: 1350999
>> >
>> > URL: http://svn.apache.org/viewvc?rev=1350999&view=rev
>> > Log:
>> > Use HTTPConstantsInterface instead of HTTPConstants
>>
>> Why change this?
>>
>> If anything, it would probably be better to remove the interface entirely.
>>
>> Constansts should rarely be defined in interfaces, as implementing the
>> interface will pollute the implementing class.
>>
>> > Modified:
>> >
>>  jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
>> >
>>  jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> >
>>  jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java
>> >
>>  jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
>> >
>> > Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
>> > URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java?rev=1350999&r1=1350998&r2=1350999&view=diff
>> >
>> ==============================================================================
>> > ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
>> (original)
>> > +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
>> Sat Jun 16 20:54:51 2012
>> > @@ -21,7 +21,7 @@ package org.apache.jmeter.protocol.http.
>> >  import java.net.HttpURLConnection;
>> >  import java.net.URL;
>> >
>> > -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>> > +import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
>> >  import org.apache.jmeter.samplers.SampleResult;
>> >
>> >  /**
>> > @@ -119,7 +119,7 @@ public class HTTPSampleResult extends Sa
>> >             sb.append(u.toString());
>> >             sb.append("\n");
>> >             // Include request body if it is a post or put
>> > -            if (HTTPConstants.POST.equals(method) ||
>> HTTPConstants.PUT.equals(method)) {
>> > +            if (HTTPConstantsInterface.POST.equals(method) ||
>> HTTPConstantsInterface.PUT.equals(method)) {
>> >                 sb.append("\n"+method+" data:\n");
>> >                 sb.append(queryString);
>> >                 sb.append("\n");
>> >
>> > Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> > URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java?rev=1350999&r1=1350998&r2=1350999&view=diff
>> >
>> ==============================================================================
>> > ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> (original)
>> > +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> Sat Jun 16 20:54:51 2012
>> > @@ -29,7 +29,7 @@ import java.io.UnsupportedEncodingExcept
>> >  import java.net.URLConnection;
>> >
>> >  import org.apache.jmeter.protocol.http.util.HTTPArgument;
>> > -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>> > +import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
>> >  import org.apache.jmeter.protocol.http.util.HTTPFileArg;
>> >  import org.apache.jmeter.samplers.SampleResult;
>> >  import org.apache.jmeter.testelement.property.PropertyIterator;
>> > @@ -177,8 +177,8 @@ public class PostWriter {
>> >         if(sampler.getUseMultipartForPost()) {
>> >             // Set the content type
>> >             connection.setRequestProperty(
>> > -                    HTTPConstants.HEADER_CONTENT_TYPE,
>> > -                    HTTPConstants.MULTIPART_FORM_DATA + "; boundary="
+
>> getBoundary()); // $NON-NLS-1$
>> > +                    HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> > +                    HTTPConstantsInterface.MULTIPART_FORM_DATA +
";
>> boundary=" + getBoundary()); // $NON-NLS-1$
>> >
>> >             // Write the form section
>> >             ByteArrayOutputStream bos = new ByteArrayOutputStream();
>> > @@ -238,7 +238,7 @@ public class PostWriter {
>> >             contentLength += getMultipartEndDivider().length;
>> >
>> >             // Set the content length
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_LENGTH,
>> Long.toString(contentLength));
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_LENGTH,
>> Long.toString(contentLength));
>> >
>> >             // Make the connection ready for sending post data
>> >             connection.setDoOutput(true);
>> > @@ -247,7 +247,7 @@ public class PostWriter {
>> >         else {
>> >             // Check if the header manager had a content type header
>> >             // This allows the user to specify his own content-type for
>> a POST request
>> > -            String contentTypeHeader =
>> connection.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE);
>> > +            String contentTypeHeader =
>> connection.getRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE);
>> >             boolean hasContentTypeHeader = contentTypeHeader != null &&
>> contentTypeHeader.length() > 0;
>> >
>> >             // If there are no arguments, we can send a file as the body
>> of the request
>> > @@ -258,10 +258,10 @@ public class PostWriter {
>> >                 if(!hasContentTypeHeader) {
>> >                     // Allow the mimetype of the file to control the
>> content type
>> >                     if(file.getMimeType() != null &&
>> file.getMimeType().length() > 0) {
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> file.getMimeType());
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> file.getMimeType());
>> >                     }
>> >                     else {
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> HTTPConstantsInterface.APPLICATION_X_WWW_FORM_URLENCODED);
>> >                     }
>> >                 }
>> >                 // Create the content length we are going to write
>> > @@ -278,7 +278,7 @@ public class PostWriter {
>> >                 if(!sampler.getSendParameterValuesAsPostBody()) {
>> >                     // Set the content type
>> >                     if(!hasContentTypeHeader) {
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> HTTPConstantsInterface.APPLICATION_X_WWW_FORM_URLENCODED);
>> >                     }
>> >
>> >                     // It is a normal post request, with parameter
names
>> and values
>> > @@ -292,11 +292,11 @@ public class PostWriter {
>> >                     if(!hasContentTypeHeader) {
>> >                         HTTPFileArg file = files.length > 0?
files[0] :
>> null;
>> >                         if(file != null && file.getMimeType()
!= null &&
>> file.getMimeType().length() > 0) {
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> file.getMimeType());
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> file.getMimeType());
>> >                         }
>> >                         else {
>> >                             // TODO: is this the correct default?
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> HTTPConstantsInterface.APPLICATION_X_WWW_FORM_URLENCODED);
>> >                         }
>> >                     }
>> >
>> > @@ -320,7 +320,7 @@ public class PostWriter {
>> >             }
>> >
>> >             // Set the content length
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_LENGTH,
>> Long.toString(contentLength));
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_LENGTH,
>> Long.toString(contentLength));
>> >
>> >             // Make the connection ready for sending post data
>> >             connection.setDoOutput(true);
>> >
>> > Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java
>> > URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java?rev=1350999&r1=1350998&r2=1350999&view=diff
>> >
>> ==============================================================================
>> > ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java
>> (original)
>> > +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java
>> Sat Jun 16 20:54:51 2012
>> > @@ -24,7 +24,7 @@ import java.io.IOException;
>> >  import java.net.URLConnection;
>> >
>> >  import org.apache.jmeter.protocol.http.util.HTTPArgument;
>> > -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>> > +import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
>> >  import org.apache.jmeter.protocol.http.util.HTTPFileArg;
>> >  import org.apache.jmeter.testelement.property.PropertyIterator;
>> >
>> > @@ -53,7 +53,7 @@ public class PutWriter extends PostWrite
>> >
>> >         // Check if the header manager had a content type header
>> >         // This allows the user to specify his own content-type for a
>> PUT request
>> > -        String contentTypeHeader =
>> connection.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE);
>> > +        String contentTypeHeader =
>> connection.getRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE);
>> >         boolean hasContentTypeHeader = contentTypeHeader != null &&
>> contentTypeHeader.length() > 0;
>> >
>> >         HTTPFileArg files[] = sampler.getHTTPFiles();
>> > @@ -66,7 +66,7 @@ public class PutWriter extends PostWrite
>> >             if(!hasContentTypeHeader) {
>> >                 // Allow the mimetype of the file to control the content
>> type
>> >                 if(file.getMimeType().length() > 0) {
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> file.getMimeType());
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> file.getMimeType());
>> >                 }
>> >             }
>> >
>> > @@ -80,7 +80,7 @@ public class PutWriter extends PostWrite
>> >             // This is not obvious in GUI if you are not uploading any
>> files,
>> >             // but just sending the content of nameless parameters
>> >             if(!hasContentTypeHeader && files.length == 1 &&
>> files[0].getMimeType().length() > 0) {
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,
>> files[0].getMimeType());
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_TYPE,
>> files[0].getMimeType());
>> >             }
>> >
>> >             // We create the post body content now, so we know the size
>> > @@ -104,7 +104,7 @@ public class PutWriter extends PostWrite
>> >         }
>> >         if(hasPutBody) {
>> >             // Set the content length
>> > -
>>  connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_LENGTH,
>> Long.toString(contentLength));
>> > +
>>  connection.setRequestProperty(HTTPConstantsInterface.HEADER_CONTENT_LENGTH,
>> Long.toString(contentLength));
>> >
>> >             // Make the connection ready for sending post data
>> >             connection.setDoOutput(true);
>> >
>> > Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
>> > URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java?rev=1350999&r1=1350998&r2=1350999&view=diff
>> >
>> ==============================================================================
>> > ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
>> (original)
>> > +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
>> Sat Jun 16 20:54:51 2012
>> > @@ -18,6 +18,17 @@
>> >
>> >  package org.apache.jmeter.protocol.http.sampler;
>> >
>> > +import java.io.ByteArrayOutputStream;
>> > +import java.io.File;
>> > +import java.io.FileInputStream;
>> > +import java.io.IOException;
>> > +import java.io.InputStream;
>> > +import java.io.OutputStream;
>> > +import java.io.UnsupportedEncodingException;
>> > +import java.net.MalformedURLException;
>> > +import java.net.URL;
>> > +import java.util.zip.GZIPInputStream;
>> > +
>> >  import org.apache.commons.httpclient.HttpClient;
>> >  import org.apache.commons.httpclient.methods.PostMethod;
>> >  import org.apache.commons.httpclient.methods.RequestEntity;
>> > @@ -25,24 +36,13 @@ import org.apache.commons.io.IOUtils;
>> >  import org.apache.jmeter.protocol.http.control.CacheManager;
>> >  import org.apache.jmeter.protocol.http.control.Header;
>> >  import org.apache.jmeter.protocol.http.control.HeaderManager;
>> > -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>> > +import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
>> >  import org.apache.jmeter.samplers.Interruptible;
>> >  import org.apache.jmeter.util.JMeterUtils;
>> >  import org.apache.jorphan.logging.LoggingManager;
>> >  import org.apache.jorphan.util.JOrphanUtils;
>> >  import org.apache.log.Logger;
>> >
>> > -import java.io.ByteArrayOutputStream;
>> > -import java.io.File;
>> > -import java.io.FileInputStream;
>> > -import java.io.IOException;
>> > -import java.io.InputStream;
>> > -import java.io.OutputStream;
>> > -import java.io.UnsupportedEncodingException;
>> > -import java.net.MalformedURLException;
>> > -import java.net.URL;
>> > -import java.util.zip.GZIPInputStream;
>> > -
>> >  /**
>> >  * Commons HTTPClient based soap sampler
>> >  */
>> > @@ -248,7 +248,7 @@ public class SoapSampler extends HTTPSam
>> >         res.setMonitor(false);
>> >
>> >         res.setSampleLabel(urlStr); // May be replaced later
>> > -        res.setHTTPMethod(HTTPConstants.POST);
>> > +        res.setHTTPMethod(HTTPConstantsInterface.POST);
>> >         res.setURL(url);
>> >         res.sampleStart(); // Count the retries as well in the time
>> >         HttpClient client = null;
>> >
>> >
>>
>
>
>
> --
> Cordialement.
> Philippe Mouawad.

Mime
View raw message