After creating a test case, you need to configure it before it can be run. You can configure the components, add test instances, define context variables, and specify the input and reference files as required.
You can create ProducerTemplate to send message exchanges to endpoints using Java code. To do so:
In the test case design workspace, right click the blank area and select Config ProducerTemplate in the context menu.
The Config ProducerTemplate wizard opens. In the Code area, type in the Java code to implement the message exchange.
You can click the Sample Code... button to see some examples. For more information about ProducerTemplate, you can click the ProducerTemplate link on the wizard to go to the Apache online documentation on ProducerTemplate.
Adding test instances
Upon creation, a test case has one test instance named Default. You can add as many instances as you need to run the same test case with different sets of data files. From the Test Cases view, you run an instance individually or run all the instances of the test case at the same time. To add a test instance, do the following:
From the Repository tree view, double click the test case to open it. The Test Cases view is shown.
On the left panel of the Test Cases, right-click the test case you want to set up, and select Add Instance from the contextual menu.
Type in a name for the instance or accept the proposed name.
The newly created test instance appears under the test case name node.
You can remove the instance, add test data to all existing instances, or run the instance by right-clicking on the instance and select the relevant item of the contextual menu. You can also remove a test data item by right-clicking it and select Remove TestData from the context menu.
Note that if you remove a test data item from an instance, this item is also removed from all the other instances.
Specify a new context for the newly created test instance. For more information, see the procedure below.
Defining context variables for the test data
Go to the Contexts view of the test case.
By default, the required variables have been created under the context named Default. You can define as many contexts as you need to perform your tests for different environments or using different text instances. For more information on how to define contexts and variables, see Using contexts and variables.
Click in the Value field of the variable for the file you want to specify, click the button, browse to your file in the [Open] dialog box, and double-click it to specify the file path for the variable.
In the Test Cases view, click each test instances on the left panel and select the related context from the context list box on the right panel.
Expand each test instance to show the test data, click each test data item on the left panel and check the context variable mapped to the data set. If needed, select the desired variable from the Context Value list box on the right panel.
Defining embedded data sets
Embedded data sets defined in the Test Cases view are used only for test case execution from Test Cases view and override the files specified in the Contexts view.
Go to the Test Cases view of the test case.
Select the data file to be defined from the left panel, click the File Browse button from the right panel, browse to your file in the [Open] dialog box, and double-click it to load the file to the repository.
Once a data file is loaded, the warning sign on the data set icon disappears, the text field at the lower part of the right panel displays the content of the loaded file, and the test case will use the data from the repository rather than from the local file system.