SOAtest provides flexible fixed-length message format support. Since many different fixed-length formats exist (and there is no single standard), Parasoft SOAtest is easily configured to recognize any fixed-length message format that the organization works with. This allows you to take advantage of SOAtest's rich interface for message configuration, sending, and validation when working with very specialized message types.
In order to configure and validate fixed-length messages in SOAtest, you need to perform the following one-time configuration:
- Define a data model that describes your fixed-length data format.
- Register the data model so that SOAtest can use it in the Fixed Length Client (and other applicable tools).
At this point, you can use the data model in the Fixed Length Client, Fixed Length Call Back Tool, and XML Converter. You can configure the message in the Fixed Length Client and validations in outputs of the Fixed Length Client.
Creating a Fixed-Length Data Model
First, we need to understand the message format for which we are going to create a data model. Consider a message where each record is on a different line and simply contains two fields: one for last name and one for first name. Each field is 10 characters long, is right-aligned, and is padded by spaces.
Smith John Doe Jane
To create a fixed-length data model for this format:
- Create a new empty .tst file:
- Go to File > New > Project.
- Choose SOAtest > Empty Project and click Next.
- Enter the project name
FixedLength
and click Finish.
- Create a new Data Model Definition file:
- Go to File > New > Data Model Definition File.
- Enter
Names
as the file name and choose /FixedLength as the location. - Click Finish. The Data Model editor will open.
- Enter
Names
in the Name field, andFirst and Last Nam
e in the Description field.
- Expand the General section and specify the following:
- Name -
people
- Record name -
person
- Record separator -
{platform newline}
- Name -
- Select the Components row, then click Add (at the bottom of the editor) twice to add two fields to the data model.
- Expand the first field and specify the following:
- Name -
LastName
- Alignment -
right
- Name -
- Expand the second field and specify the following:
- Name -
FirstName
- Alignment -
right
- Name -
- Save the Data Model editor.
- Click the Register data model directory link in the top right corner of the editor. This registers the data model that we just created with SOAtest. The model is now available to the appropriate tools.
Creating a New Fixed-Length Client
To create a new Fixed Length Client
- Find the FixedLength.tst file that you created in the previous exercise.
- Create a new Fixed Length Client:
- Right-click the test suite node and choose Add New > Test.
- Choose Fixed Length Client and click Finish.
- Select the data model that we just created by choosing Names: First and Last Name in the Message type dropdown.
- Click the Request tab and ensure that Input Mode is set to Form Input.
- Change the automatically generated person element to use
Smith
as the last name andJohn
as the first name. - Add a second person element by selecting the people element and clicking Insert.
Select the new person element, then enterDoe
as the last name andJane
as the first name. - Click the Transport tab and enter
http://localhost:8080/parabank/echo.jsp
in the Router Endpoint field. - Save the editor.
- Run the test.
- Open the Traffic Viewer and validate that the sent content looks like the sample message shown at the start of this tutorial.
Extending the Fixed-Length Data Model with a Variable Number of Repeating Segments
Now let's assume that for each person, we want to specify a variable number of pets owned by that person. We will start with the data format we used above, but for each record we will add the following:
- A number field that specifies the number of pets that is two characters long, padded with 0.
- A variable number of sections, where each section contains the type of pet and the name of the pet. The number of sections is equivalent to the number in the field that specifies the number of pets. The field for type of pet is five characters long, right-aligned, and the field for the name of pet is ten characters long, right-aligned.
Here is an example of such data:
Smith John00 Doe Jane02 Cat Fluffy Dog Spot
Let's start with our existing data model, and extend it to make a new data model:
- Create a new data model file:
- In the Navigator view, open the FixedLength project.
- Right-click the project and choose Refresh to ensure that the view is up to date.
- Right-click the Names.datamodel file and choose Copy.
- Paste it into the FixedLength project.
- When the new name dialog comes up, enter
NamesAndPets.datamode
l and click OK.
- Double-click the new NamesAndPets.datamodel file that is in the FixedLength project.
- Enter
Names and Pets
for the name and remove the description. - Choose Components and click Add. This adds a new field.
- Change Field to Section, then click Add again. This adds a new section.
- For the newly added (third) field in the top-level section, expand the node for the field and specify the following:
- Name -
NumberOfPets
- Type -
integer
- Length -
2
- Alignment -
right
- Padding -
0
- Name -
- For the new section, expand the General node and specify the following:
- Name -
pets
- Recordname -
pet
- Criteriafornextrecord -
xpath
- XPath -
count($section/*) < $section/../NumberOfPets
- Name -
- Click the Components node in the new section, ensure Field is selected, and click Add twice.
- Edit the components as follows:
- Click the Components node in the new section, then click Edit in Table.
- In row 1, specify
PetType
for Name,5
for Length, andright
for Alignment. - In row 2, specify
PetName
for Name andright
for Alignment. - Click Return to Full Data Model.
- Save the editor.
- Click the Components node in the new section, then click Edit in Table.
- Add a new Fixed Length Client to the Test Suite of the FixedLength.tst file and select Names and Pets: as the Message type.
- Enter the first person’s information as follows:
- In the Request tab, select the people element.
- Modify the default values as follows:
- LastName -
Smith
- FirstName -
John
- NumberOfPets -
0
- LastName -
- Delete the pets element.
- Enter the second person’s information as follows:
- Add a second person element by selecting the people element, then clicking Insert.
- Enter the following values:
- LastName -
Doe
- FirstName -
Jane
- NumberOfPets -
2
- LastName -
- Right-click the pets node for the second person, choose Insert Multiple, specify
2
for the Count, then click OK. - For the first pet, specify the following:
- PetType -
Cat
- PetName -
Fluffy
- PetType -
- For the second pet, specify the following:
- PetType -
Dog
- PetName -
Spot
- PetType -
- Click the Transport tab and set the RouterEndpoint to
http://localhost:8080/parabank/echo.jsp
. - Save the tool.
- Run the test.
- Open the Traffic Viewer and validate that the content that was sent appears like the example data we are modeling.
The .tst file corresponding to these exercises can be found at <SOAtest install dir>/examples/tests/FixedLength.tst
.