The JBI Test Manager in Netbeans lets you create synchronous request-reply tests. These tests require the binding used to be SOAP over HTTP. that is, they require the HTTP BC to be used. These tests are very useful for testing BPEL-SE as well as testing many other SEs and BCs that can provision services using synchronous request-reply operations. The JBI Test Manager has full support for creating and running such tests using GUI. Once created these tests can be run from the command line. So it is very easy to create and automate these tests.
Some SEs and BCs do not support request-reply operations. For example, IEP SE can only provision and consume services with one-way operations. So we need a mechanism to write tests for such Components. The N2M tests provide this functionality. The N2M tests are driven by sending requests to a SOAP over HTTP endpoint. These requests can be sent to one or more operations (N). The output is sent to one or more files (M). Finally a compariosn is made between the actual output and the expected output, which had previously been configured as part of the test definition. Presently, no GUI support exists to create them, so they need to be created manually. However, they can be run from Netbeans as well as from command line. So it is very easy to automate these tests, just like the synchronous request-reply tests.
. Following describes the files and their purpose.
File N2M.properties - This is the main file that defines the test. Here's a sample
description=test basic framework
destination=http://localhost:${HttpDefaultPort}/service/iepAttributeBasedWindow_iep
httpwarning=WARNING: SAAJ0014
######### Inputs #########
input.count=1
input.0.action="StreamInput0"
input.0.dataFile=data.txt
input.0.templateFile=template.xml
input.0.batchSize=1
######### Output #########
output.count=1
output.0.actualResultFile=actual.txt
output.0.expectedResultFile=expected.txt
######## Script ###########
scriptFile=script.txt
#featurestatus=progress
destination: The endpoint to which the requests will be sent. This corresponds to the value of "location" attribute in the soap:address element in the WSDL.
input.count: The number of different operations to which requests will be sent. In IEP this corresponds to the number of input streams, in this case 1.
Note: input.0.xxxx refers to properties used for the first operation. If there is a second operation then the properties will be input.1.xxxx.
input.0.action: The SOAP action for first the operation
input.0.templateFile: The file containing a template of the the SOAP message that will be used to send requests for the first operation. Here's a sample (template.xml)
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns="iepAttributeBasedWindow_iep">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<StreamInput0_MsgObj>
<name>${name.0}</name>
<value>${value.0}</value>
</StreamInput0_MsgObj>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
${name.0} and ${value.0} are tokens that will be replaced using actual values from a file specified using the dataFile property. Note that the tokens are "name" annd "value". The ".0" at the end is required, but has no meaning (?). See below for tips to generate a sample SOAP message.
input.0.dataFile: The dataFile for the first operation. Contains the values that will be used to replace the $ tokens in the templateFile. The first line is a header. Following this, each set of values is specified on a separate line. Comma is used as a separator. Following is a sample (data.txt)
name,value ADBE,60.1 ADBE,61.1 ADBE,62.1 ADBE,63.1 ADBE,64.1 ADBE,65.1 ADBE,66.1 ADBE,67.1 ADBE,68.1 ADBE,69.1 ADBE,70.1 ADBE,71.1
output.count: The number of files generated
output.0.actualResultFile: The actual result file that gets generated.
Since we want the output files to be generated in the test folder, we need to specify the file directory appropriately in the WSDL. For example, this test is checked in the open-jbi-components java.net repository at the location CVS/open-jbi-components/driver-tests/iepse/tests/jbi/test/IepAttributeBasedWindow. If you checkout the source under C:/MyEnc/open-jbi-components, the you would specify the file path as C:/MyEnc/open-jbi-components/driver-tests/iepse/tests/jbi/test/IepAttributeBasedWindow.
If you are going to automate the test or even otherwise, you can specify the path as ${ojc-root}/driver-tests/iepse/tests/jbi/test/IepAttributeBasedWindow. Then in File BC you can defined an application variable with name "ojc-root" and specify the value as "C:/MyEnc/open-jbi-components" or whatever is the root for open-jbi-components.
featurestatus: Use this property, if you don't want the test to be run, when the right-click "Test" menu of the Comp App project is selected. The value to set will be "progress". If you want the test to be run then set the value as "done". The default is "done". So if you don't specify the property, it is assumed as "done".
Note: If you change the IEP process definition, then the WSDL file is re-generated. You will lose the changes that you made to the WSDL file. One way to get around this is to ignore the bindings generated by IEP and specify the bindings in CASA. Even in this case, some changes to the IEP file may invalidate the WSDL that you created in CASA and you may have to redo the bindings in CASA.
output.0.expectedResultFile: The expected output in the file represented by output.0.actualResultFile. Initially, you can keep this file blank. After running the test once, the actual output files will be generated. You can review them and if the output is correct, copy the contents into the expected result files.
scriptFile: This is the file which defines how the input will be sent. Here's an example (script.txt)
wait 60 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 send input.0 1 wait 60
"wait 60" tells the framework to wait 60s before executing the next line. "send input.0 1" tells the framework to send one request to the first operation. So the above script will send 12 requests one after another. The 12 individual commands can be replaced by a single command - "send input.0 12". Note that you can put waits between the individual send commands, if you want to inroduce time lag between sending events. For example, "wait 1".
You can guide driver tests to load different configuration files by specifying system property "org.netbeans.modules.compapp.catd.context". The value of property "org.netbeans.modules.compapp.catd.context" must be in the format of a-zA-Z0-9+(_a-zA-Z0-9+)*. That is, the context is defined by a word optionally followed by any pairs of "_" and another word. For example,
For example, assume org.netbeans.modules.compapp.catd.context has value "oracle_solaris", then the driver test will load N2M.properties(always exists), N2M_oracle.properties(if exists), and N2M_oracle_solaris.properties(if exists) in order.
Assume that N2M.properties has content:
description=test basic framework
destination=http://localhost:${HttpDefaultPort}/service/iepAttributeBasedWindow_iep
httpwarning=WARNING: SAAJ0014
######### Inputs #########
input.count=1
input.0.action="StreamInput0"
input.0.dataFile=data.txt
input.0.templateFile=template.xml
input.0.batchSize=1
######### Output #########
output.count=1
output.0.actualResultFile=actual.txt
output.0.expectedResultFile=expected.txt
######## Script ###########
scriptFile=script.txt
N2M_oracle.properties has content:
output.0.expectedResultFile=expectedOracle.txt
and N2M_oracle_solaris does not exist
Then the following properties will be used
description=test basic framework
destination=http://localhost:${HttpDefaultPort}/service/iepAttributeBasedWindow_iep
httpwarning=WARNING: SAAJ0014
input.count=1
input.0.action="StreamInput0"
input.0.dataFile=data.txt
input.0.templateFile=template.xml
input.0.batchSize=1
output.count=1
output.0.actualResultFile=actual.txt
output.0.expectedResultFile=expectedOracle.txt
scriptFile=script.txt
netbeans_default_options=".... -J-Dorg.netbeans.modules.compapp.catd.context=oracle_solaris"The driver tests will pick up the context value as "oracle_solaris" when running tests from Netbeans.
<target name="-check-catd-context">
<condition property="no.catd.context">
<not>
<isset property="org.netbeans.modules.compapp.catd.context"/>
</not>
</condition>
</target>
<target name="-init-catd" if="no.catd.context">
<property name="org.netbeans.modules.compapp.catd.context" value=""/>
</target>
<target name="pre-init" depends="-check-netbeans-home,-init-caps,-check-catd-context,-init-catd"/>
Modify nbproject/build-impl.xml
<target name="-do-test-run" ...>
<junit ... >
....
<sysproperty key="NetBeansUserDir" value="${netbeans.user}"/>
<sysproperty key="org.netbeans.modules.compapp.catd.context" value="${org.netbeans.modules.compapp.catd.context}"/>
<test name="org.netbeans.modules.compapp.catd.ConfiguredTest" haltonfailure="no" todir="${test.results.dir}">
....
</junit>
</target>
and
<target name="-do-single-test-run" ...>
<junit ... >
....
<sysproperty key="NetBeansUserDir" value="${netbeans.user}"/>
<sysproperty key="org.netbeans.modules.compapp.catd.context" value="${org.netbeans.modules.compapp.catd.context}"/>
<test name="org.netbeans.modules.compapp.catd.ConfiguredTest" haltonfailure="no" todir="${test.results.dir}">
....
</junit>
</target>