jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1240514 - in /jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler: AbstractTCPClient.java TCPClient.java TCPClientImpl.java TCPSampler.java
Date Sat, 04 Feb 2012 15:01:12 GMT
Author: pmouawad
Date: Sat Feb  4 15:01:11 2012
New Revision: 1240514

URL: http://svn.apache.org/viewvc?rev=1240514&view=rev
Log:
Bug 51737 - TCPSampler : Packet gets converted/corrupted
Added encoding to SampleResult

Modified:
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/AbstractTCPClient.java
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClient.java
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/AbstractTCPClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/AbstractTCPClient.java?rev=1240514&r1=1240513&r2=1240514&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/AbstractTCPClient.java
(original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/AbstractTCPClient.java
Sat Feb  4 15:01:11 2012
@@ -22,7 +22,7 @@ package org.apache.jmeter.protocol.tcp.s
  * Basic implementation of TCPClient interface.
  */
 public abstract class AbstractTCPClient implements TCPClient {
-
+    protected String charset;
     protected byte eolByte;
     protected boolean useEolByte = false;
 
@@ -57,4 +57,18 @@ public abstract class AbstractTCPClient 
     public void teardownTest() {
     }
 
+    /**
+     * @return the charset
+     */
+    public String getCharset() {
+        return charset;
+    }
+
+    /**
+     * @param charset the charset to set
+     */
+    public void setCharset(String charset) {
+        this.charset = charset;
+    }
+
 }

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClient.java?rev=1240514&r1=1240513&r2=1240514&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClient.java (original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClient.java Sat
Feb  4 15:01:11 2012
@@ -75,6 +75,13 @@ public interface TCPClient {
      * @return Returns the eolByte.
      */
     public byte getEolByte();
+    
+
+    /**
+     * Get the charset.
+     * @return Returns the charset.
+     */
+    public String getCharset();
 
     /**
      * Set the end-of-line/end-of-message byte.

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java?rev=1240514&r1=1240513&r2=1240514&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
(original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
Sat Feb  4 15:01:11 2012
@@ -57,11 +57,12 @@ public class TCPClientImpl extends Abstr
         if (useEolByte) {
             log.info("Using eolByte=" + eolByte);
         }
-        String charset = JMeterUtils.getProperty("tcp.charset");
-        if(StringUtils.isEmpty(charset)) {
+        setCharset(charset);
+        String configuredCharset = JMeterUtils.getProperty("tcp.charset");
+        if(StringUtils.isEmpty(configuredCharset)) {
             log.info("Using platform default charset:"+charset);
         } else {
-            log.info("Using charset:"+charset);
+            log.info("Using charset:"+configuredCharset);
         }
     }
 

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java?rev=1240514&r1=1240513&r2=1240514&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java (original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java Sat
Feb  4 15:01:11 2012
@@ -348,15 +348,15 @@ public class TCPSampler extends Abstract
                 res.setSamplerData(req);
                 protocolHandler.write(os, req);
                 String in = protocolHandler.read(is);
-                isSuccessful = setupSampleResult(res, in, null);
+                isSuccessful = setupSampleResult(res, in, null, protocolHandler.getCharset());
             }
         } catch (ReadException ex) {
             log.error("", ex);
-            isSuccessful=setupSampleResult(res, ex.getPartialResponse(), ex);
+            isSuccessful=setupSampleResult(res, ex.getPartialResponse(), ex,protocolHandler.getCharset());
             closeSocket(socketKey);
         } catch (Exception ex) {
             log.error("", ex);
-            isSuccessful=setupSampleResult(res, "", ex);
+            isSuccessful=setupSampleResult(res, "", ex, protocolHandler.getCharset());
             closeSocket(socketKey);
         } finally {
             // Calculate response time
@@ -377,12 +377,14 @@ public class TCPSampler extends Abstract
 	 * @param sampleResult {@link SampleResult}
 	 * @param readResponse Response read until error occured
 	 * @param exception Source exception
+     * @param encoding sample encoding
 	 * @return boolean if sample is considered as successful
 	 */
 	private boolean setupSampleResult(SampleResult sampleResult,
 			String readResponse, 
-			Exception exception) {
-		sampleResult.setResponseData(readResponse, null);
+			Exception exception,
+			String encoding) {
+		sampleResult.setResponseData(readResponse, encoding);
 		sampleResult.setDataType(SampleResult.TEXT);
 		if(exception==null) {
 			sampleResult.setResponseCodeOK();



Mime
View raw message