ASF Bugzilla – Full Text Bug Listing
|Summary:||Extend TCP Sampler to Support Length-Prefixed Binary Data|
|Product:||JMeter||Reporter:||Oghie Sheehy <osheehy>|
|Component:||Main||Assignee:||JMeter issues mailing list <issues>|
|Attachments:||Code to implement enhancement|
Description Oghie Sheehy 2008-10-16 23:59:25 UTC
Created attachment 22749 [details] Code to implement enhancement We have a requirement to test a TCP service where data is exchanged in length-prefixed binary format. To meet this need we have implemented the attached classes which we wish to submit for a future release of JMeter. A brief description of the classes follows: BinaryTCPClientImpl Concrete class which implements TCPClient Interface and converts hex-encoded strings to byte array in write(OutputStream, String) and from byte array to hex-encoded string in read(InputStream). write(OutputStream, InputStream) is unsupported. Contains utility method hexStringToByteArray(String s) which is a mirror of the JOrphanUtils.baToHexString(byte) method. TCPClientDecorator Abstract class implementing TCPClient Interface. This is to allow wrapping of TCPClientImpl/BinaryTCPClientImpl above with length prefixing methods. Contains two utility methods intToByteArray(int value, int len) and byteArrayToInt(byte b). Methods support 2 and 4 and byte lengths only and throw an IllegalArgumentException in other cases. LengthPrefixedBinaryTCPClientImpl Extends TCPClientDecorator and instantiates decorator with BinaryTCPClientImpl. The length to use in the prefix is taken from the properties file and defaults to 2. For write(OutputStream os, String s) the length is calculated and written to the output stream then the method delegates to the BinaryTCPClientImpl write() method. read(InputStream is) is overridden. write(OutputStream os, InputStream is) is not supported. Have created JUnit tests for the three utility methods but not for the read/write implementations themselves. These are in two test classes, BinaryTCPClientImplTest and TCPClientDecoratorTest. Have left the utility methods bundled with the client implementations to avoid modifying existing utility classes.
Comment 1 Sebb 2008-11-06 10:53:30 UTC
Code has been added to SVN. Thanks very much for the contribution.