jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1240507 - in /jmeter/trunk: bin/jmeter.properties src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java xdocs/changes.xml
Date Sat, 04 Feb 2012 14:32:43 GMT
Author: pmouawad
Date: Sat Feb  4 14:32:42 2012
New Revision: 1240507

URL: http://svn.apache.org/viewvc?rev=1240507&view=rev
Log:
Bug 51737 - TCPSampler : Packet gets converted/corrupted

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1240507&r1=1240506&r2=1240507&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sat Feb  4 14:32:42 2012
@@ -604,6 +604,10 @@ wmlParser.types=text/vnd.wap.wml 
 # set this to a value outside the range -128 to +127 to skip eol checking
 #tcp.eolByte=1000
 #
+# TCP Charset, used by org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl
+# default to Platform defaults charset as returned by Charset.defaultCharset().name()
+#tcp.charset=
+#
 # status.prefix and suffix = strings that enclose the status response code
 #tcp.status.prefix=Status=
 #tcp.status.suffix=.

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=1240507&r1=1240506&r2=1240507&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 14:32:42 2012
@@ -30,7 +30,9 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -46,6 +48,7 @@ public class TCPClientImpl extends Abstr
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     private int eolInt = JMeterUtils.getPropDefault("tcp.eolByte", 1000); // $NON-NLS-1$
+    private String charset = JMeterUtils.getPropDefault("tcp.charset", Charset.defaultCharset().name());
// $NON-NLS-1$
     // default is not in range of a byte
 
     public TCPClientImpl() {
@@ -54,13 +57,19 @@ public class TCPClientImpl extends Abstr
         if (useEolByte) {
             log.info("Using eolByte=" + eolByte);
         }
+        String charset = JMeterUtils.getProperty("tcp.charset");
+        if(StringUtils.isEmpty(charset)) {
+            log.info("Using platform default charset:"+charset);
+        } else {
+            log.info("Using charset:"+charset);
+        }
     }
 
     /**
      * {@inheritDoc}
      */
     public void write(OutputStream os, String s)  throws IOException{
-        os.write(s.getBytes()); // TODO - charset?
+        os.write(s.getBytes(charset)); 
         os.flush();
         if(log.isDebugEnabled()) {
             log.debug("Wrote: " + s);
@@ -99,7 +108,7 @@ public class TCPClientImpl extends Abstr
 			if(log.isDebugEnabled()) {
 			    log.debug("Read: " + w.size() + "\n" + w.toString());
 			}
-			return w.toString();
+			return w.toString(charset);
 		} catch (IOException e) {
 			throw new ReadException("", e, w.toString());
 		}

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1240507&r1=1240506&r2=1240507&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Feb  4 14:32:42 2012
@@ -71,6 +71,7 @@ or a Debug Sampler with all fields set t
 
 <h3>Other Samplers</h3>
 <ul>
+<li>Bug 51737 - TCPSampler : Packet gets converted/corrupted</li>
 </ul>
 
 <h3>Controllers</h3>



Mime
View raw message