Overview
Protobuf is a language-agnostic, schema-based data serialization system created by Google. The Protobuf message format is binary and is considered more efficient than other formats like JSON & XML. The Protobuf extension enables SOAtest and Virtualize to support the Protobuf message format. It can read schemas from a Confluent Schema Registry or saved to a local drive.
Installing the extension adds the Protobuf Client for SOAtest and the Protobuf Message Responder for Virtualize.
Requirements
- SOAtest/Virtualize 2022.1 and later.
- Protocol Buffer Compiler (protoc). See https://protobuf.dev/installation/.
- Java 11 or later.
Build the protobuf-extension.jar
You will need to build a Protobuf extension jar to use the Protobuf extension. To do so:
- Download the Protocol Buffer Compiler (protoc) mentioned in Requirements.
- Run the following command with the appropriate arguments:
java -jar com.parasoft.soavirt.messages.protobuf.jar <ARGUMENTS>
The example below (for Windows) shows the command with all arguments. This will generate the jar (protobuf-extension.jar) which can then be added to SOAtest:
java -jar com.parasoft.soavirt.messages.protobuf-<VERSION>.jar -protoc C:\protoc-<VERSION>-win64\bin\protoc.exe -includes -protoDir C:\<PATH_TO_PROTO_FILES> -logLevel 4
For more information about the Protobuf jar, run:
java -jar com.parasoft.soavirt.messages.protobuf-<VERSION>.jar -help
Installation
This artifact can be installed from the UI or the command line.
UI Installation
- Go to Parasoft > Preferences and click System Properties.
- Click Add JARs and choose the protobuf-extension.jar.
- Click Apply.
- Restart SOAtest/Virtualize.
Command Line Installation
Add the Protobuf .jar file to the system.properties.classpath
property in your settings properties file. For example:
system.properties.classpath=<path to jar>/protobuf-extension.jar
Usage
Adding the Protobuf Clients
You can add standalone Protobuf clients to your suite using the Add Test wizard or chain Protobuf tools as a payload output of an existing tool using the Add Output wizard. See Adding Projects, .tst files, and Test Suites for details.
Configuration and Usage
Protobuf clients function in a manner similar to other messaging clients but are configured to use the Protobuf format by default. In addition, there are a few configuration options that are unique to Protobuf clients:
XML Conversion Options
- Send XML instead of Protobuf when in Form Input or Form XML mode: Enable this option to skip serializing the request as binary Protobuf, such as when using the Protobuf client as a consumer only to avoid conversion errors in a request that will not be used.
Schema for Modeling Request Payload Using Form Input
- Message type: Choose from the type definitions available in the schemas in the Protobuf schemas folder or Confluent schema registry specified previously (see Configuring Protobuf Schemas Location).
- When a local schema folder has been specified, you will see the names of available schema types in this list. When a Confluent Schema Registry has been specified, subject/version pairs will be shown.
Adding Protobuf Message Responders
You can add Protobuf message responders to your suite using the Add Responder wizard. See Creating Message Responders Manually for details.
Configuration and Usage
Protobuf message responders function in a manner similar to other responders. Refer to Message Responder Overview for information on configuring and using responders. There are a few configuration options that are unique to Protobuf message responders:
XML Conversion Options
- Respond with XML instead of Protobuf when in Form Input or Form XML mode: Enable this option when chaining other tools to process the Protobuf message in XML format.
Schema for Modeling Request Payload Using Form Input
- Message type: Choose from the type definitions available in the schemas in the Protobuf schemas folder or Confluent schema registry specified previously (see Configuring Protobuf Schemas Location).
- When a local schema folder has been specified, you will see the names of available schema types in this list. When a Confluent Schema Registry has been specified, subject/version pairs will be shown.
You can also configure the responder to use a different Protobuf message type for incoming requests. To do so:
- In the message responder, click the Options tab and choose Request Handling.
- Enable Convert incoming request to XML using different message format than response.
- Choose Protobuf from the Format menu.
- Choose the message type that is expected to come into the virtual asset from the Message type menu that appears. Type definitions available in the schemas in the Protobuf schemas folder or Confluent schema registry specified previously (see Configuring Protobuf Schemas Location).
- When a local schema folder has been specified, you will see the names of available schema types in this list. When a Confluent Schema Registry has been specified, subject/version pairs will be shown.
Using Protobuf with gRPC
One of the benefits of using the Protobuf extension is the ability to use it in conjunction with the gRPC Transport in order to send messages in one format and receive messages in another format.