Bug 54205 - Add Java Serialization sampler
Summary: Add Java Serialization sampler
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 2.8
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Keywords: PatchAvailable
Depends on: 54257
  Show dependency tree
Reported: 2012-11-25 20:05 UTC by Etienne Carrière
Modified: 2015-12-29 15:43 UTC (History)
1 user (show)

JavaSerializedSampler.java (9.60 KB, application/octet-stream)
2012-11-25 20:08 UTC, Etienne Carrière
JavaSerializedSamplerGui.java (6.32 KB, application/octet-stream)
2012-11-25 20:08 UTC, Etienne Carrière
Patch (833 bytes, patch)
2012-11-25 20:09 UTC, Etienne Carrière
Details | Diff
Patch for Java Serialization v1 (22.84 KB, patch)
2012-11-29 06:14 UTC, Etienne Carrière
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Etienne Carrière 2012-11-25 20:05:58 UTC
I am currently developing a JAVA Serialization sampler. I have 2 issues : 
1) My current implementation is a 'clone' of the SoapSampler. The current use is the following
  1) Add in lib/ext the JAR of the class you will have to Serialize/Unserialize 
  2) Do a recording of the scenario with the proxy . The Content-type for the binary types must be set to the Content-type used by the application to send the serialized POST
  3) Replace the HTTP Sampler by a Java Serialized sampler 
  3.1) Load the file POST*.binary ( for example POST9192898739932004659.binary) in the file. It generate the Xstream stream
  3.2) Put variable in the Xstream stream
When the test plan is run, the java object are dynamically generated

In order to automate this process, the proxy should recognize this stream : 
+ The current solution for SamplerCreatorFactory relies on Content-type 
+ The SamplerCreator interface splits between 
   - createSampler : creates the sampler with (currently) only parses the header 
   - populateSampler : fill more fields with a full parsing (header+Body)

I could like to create different Sampler not on the content-type basis but on a content basis. 
For example, for Java Serialized sampler, I would choose to create this sampler with the following pseudo-code

if ( content_type is in allowed_content_type_for_Java_ser && request_type == POST){
   }catch {

if (isserial == 1){
   create Java Serial Sampler

so only post with a valid body for Sampler is allowed 

The disadvantage of this method is that we have to (fully) parse the request to choose the type.

What is your preferred method to implement the integration in the proxy ? 

Comment 1 Etienne Carrière 2012-11-25 20:08:02 UTC
Created attachment 29632 [details]
Comment 2 Etienne Carrière 2012-11-25 20:08:22 UTC
Created attachment 29633 [details]
Comment 3 Etienne Carrière 2012-11-25 20:09:10 UTC
Created attachment 29634 [details]
Comment 4 Etienne Carrière 2012-11-29 06:06:08 UTC

I completed my first version of the Java Serialization implementation . You can find attached the full patch with : 
- Specific Sampler
- Specific SamplerGui
- Specific SamplerCreator which try to recognize the Java Serialized Object and if it fails it calls DefaultSamplerCreator. It is a simple method but it could be better to throw an exception in specific Creator and then use the DefaultSamplerCreator.
- Specific message.properties 

It currently does not contains the documentation. 

It we want to merge this sampler into HTTP Sampler, I would like to discuss how to define the Gui : 
+ a third panel "Java Serialized Object" with the two first "Parameters" and "Post Body" and integrate into the HTTP Sampler class
+ Retake the URLConfigGui and extend it with only 2 panels "Parameters" and "Post Body" and having a separate Sampler class 

Thanks for your comments,
Comment 5 Etienne Carrière 2012-11-29 06:14:28 UTC
Created attachment 29652 [details]
Patch for Java Serialization v1
Comment 6 Philippe Mouawad 2015-12-29 15:43:22 UTC
Niche technology nowadays.
Closing as WONTFIX