Binary Response can't be validated, or can't send proper binary request

Document created by Dave Murphy Employee on Dec 15, 2017
Version 1Show Document
  • View in full screen mode

Symptoms

When playing back a message, there is a binary response that shows up as garbled symbols, and I can not validate it properly.

-or-

When playing back a message, I need the sent binary data to be very precise, it can't be base64 encoded or represented with a string.

Diagnosis

You need to install a custom module specific to the target that allows you to manually handle the Binary->Text and Text->Binary conversion in Java code.

Solution

Create a custom module, using the attached CloudTest Transport Plugin API as a referenced library (but don't include it in the jar you upload to cloudtest). This jar provides a very specific API in the format

import com.soasta.plugins.transport.v1.MessageConverter;

public final class Base64MessageConverter implements MessageConverter
{
@Override
public byte[] serializeRequest(String request) throws Exception
{
return Base64.encodeBase64(request.getBytes("UTF-8"));
}
@Override

public String deserializeResponse(byte[] response) throws Exception
{
return new String(Base64.decodeBase64(response), "UTF-8");
}
}

This would be the most basic implementation possible, and essentially does what CloudTest does today. Attached is another example of something that can be done. With the attached code in place in the target, your binary responses get deserialized to hexademical representations, so you can validate them as standard text. Because you are in full control over the bytes and strings, you can do pretty much whatever you want to the requests and responses. You then just need to use the CloudTest UI to specify how it should use your custom module by providing the module to use, and the fully qualified Class name to load. That's it!

 

Attachments

    Outcomes