Testing EIS imports and exports can be done while still in the development environment using the WebSphere® test environment. This section shows how to test several imports and exports created in the help.
The WebSphere test environment is a comprehensive test environment for testing components developed in WebSphere Integration Developer. While still in the development environment, you can completely test your components. The following sections describe how at a high-level to use the WebSphere test environment to test components created in the help.
Note that the sections describe the pattern of testing generally. Since you will have used the enterprise service discovery wizard to create your own components from your own EIS systems, your components will differ slightly from those created in the help. Any particular names used here test components would need to be modified accordingly. However, the testing pattern should be similar.
identification division. program-id. TADERC01. data division. working-storage section. 01 tdeptname pic X(20) DISPLAY. 01 tname pic X(20) DISPLAY. 01 tage pic 9(5) COMP. 01 tphone pic X(8) DISPLAY. 01 tperson. 02 tpersonname PIC X(20) DISPLAY. 02 tpersonage PIC 9(5) COMP. 02 tpersonphone PIC X(8) DISPLAY. linkage section. 01 DFHCOMMAREA. 02 DEPT. 03 deptname PIC X(20) DISPLAY. 03 person occurs 3 TIMES. 04 name PIC X(20) DISPLAY. 04 age PIC 9(5) COMP. 04 phone PIC X(8) DISPLAY. procedure division. testcase-code. move 'D288' TO tdeptname. if tdeptname equal deptname move 'Harold Gartner' To tpersonname move 25 TO tpersonage move '448-4491' TO tpersonphone move tperson TO person(1) move 'Piotr Przybylski' To tpersonname move 25 TO tpersonage move '448-3688' TO tpersonphone move tperson TO person(2) move 'Ilene Seelemann' To tpersonname move 26 TO tpersonage move '448-2846' TO tpersonphone move tperson TO person(3) else move 'xxx1' To tpersonname move 1 TO tpersonage move '448-xxxx' TO tpersonphone move tperson TO person(1) move 'xxx2' To tpersonname move 1 TO tpersonage move '448-xxxx' TO tpersonphone move tperson TO person(2) move 'xxx3' To tpersonname move 1 TO tpersonage move '448-xxxx' TO tpersonphone move tperson TO person(3). EXEC CICS RETURN END-EXEC.
<HEAD> <TITLE>index.jsp</TITLE> </HEAD> <BODY> <%@ page import="com.ibm.websphere.sca.ServiceManager" %> <%@ page import="com.ibm.websphere.sca.Service" %> <%@ page import="com.ibm.websphere.bo.BOFactory" %> <%@ page import="commonj.sdo.DataObject" %> <%@ page import="java.util.*" %> <form action="index.jsp" method="get"> <p>Push the button to test. <br><br> String: <input type="text" name="sample"/> <input type="submit" name="message" value="CICS Outbound Test"></p> </form> <% try { if (request.getParameter("message")!=null) { out.println("<p> Creating new Service Manager... </p>"); ServiceManager serviceManager = new ServiceManager(); out.println("<p> Locate the reference to a SCAImportBinding which imports the CICS DepartmentInfo service</p>"); Service service = (Service) serviceManager.locateService("DepartmentInfoServicePartner"); targetReference = (Reference) ServiceManager.INSTANCE.getComponent().getReference("DepartmentInfoServicePartner"); OperationType opType = (OperationType) targetReference.getOperationType("getDepartmentInfo"); BOFactory factory = (BOFactory)ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOFactory"); DataObject wrapper = factory.createByType(opType.getInputType()); out.println("<p> Set input values</p>"); DataObject departmentInfo = factory.create("http://CICSOutbound/data", "DepartmentInfo"); departmentInfo.setString("deptname","D288"); wrapper.set(0,departmentInfo); out.println("<p> Invoke the service</p>"); DataObject wrapperOut = (DataObject)service.invoke("getDepartmentInfo",wrapper); DataObject departmentInfoOut = (DataObject)wrapperOut.get(0); out.println("<p> Print output</p>"); out.println("<p> " + departmentInfoOut.getString("deptname") + "</p>"); List departmentStaff = departmentInfoOut.getList("person"); for(Iterator it = departmentStaff.iterator(); it.hasNext(); ) { DataObject person = (DataObject) it.next(); out.println("<p> " + person.getString("name") + "</p>"); out.println("<p> " + new Integer(person.getInt("age")).toString() + "</p>"); out.println("<p> " + person.getString("phone") + "</p>"); System.out.println(person.getString("name")); System.out.println(new Integer(person.getInt("age")).toString()); System.out.println(person.getString("phone")); } } } catch (Exception e) { %><p>An exception occured during the invocation. See SystemOut.log and SystemErr.log for details.</p><% e.printStackTrace(); } %> </BODY> </HTML>
If you created your own import in a similar way to section Creating an import component using IMS, you can test your component in the WebSphere test environment.
In the Resource Adapter Connection Properties page of the
enterprise service discovery wizard, you provided a JNDI lookup name of a
connection factory called eis/imsTarget and the name of a
J2C authentication data entry called widNode/myAlias for
your import component, as shown in the following screen capture.
The following steps show
how to configure your import component's target server, WebSphere Process
Server 6.0, to test this example. You will then test your component by adding
input values, running the test environment and examining the output values.
Name | Type | Value |
---|---|---|
in__ll | short | 59 |
in__zz | short | 0 |
in__trcd | string | IVTNO |
in__cmd | string | DISPLAY |
in__name1 | string | LAST1 |
The following errors could occur while testing your component.
A value was not provided for the J2C Authentication Data Entry field on the Resource Adapter Connection Properties page of the enterprise service discovery wizard. Note that a J2C Authentication Data Entry (JAAS alias name) is optional. However, by default the application that is generated for the import component is generated for container-managed EIS sign-on. If you do not change this and you do not provide a JAAS alias name, IMS Connector for Java will throw an exception containing message ICO0064E.
A value was provided for the J2C Authentication Data Entry field on the Resource Adapter Connection Properties page of the enterprise service discovery wizard, but the JAAS alias was not defined on the target WebSphere server.
So far we've tested access to the server. Now that we can access the server and get the data returned that we expect, we will add a client application to invoke the component we created and present the returned data in a browser.
<HTML> <HEAD> <TITLE>TestIMS.jsp</TITLE> </HEAD> <BODY> <%@ page import="com.ibm.websphere.sca.ServiceManager" %> <%@ page import="com.ibm.websphere.sca.Service" %> <%@ page import="com.ibm.wsspi.sca.scdl.OperationType" %> <%@ page import="com.ibm.wsspi.sca.scdl.Reference" %> <%@ page import="com.ibm.websphere.bo.BOFactory" %> <%@ page import="commonj.sdo.DataObject" %> <form action="TestIMS.jsp" method="get"> <p><b>Push the button to test</b> <br><br> <input type="submit" name="message" value="IMS Outbound Test !!!"></p> <TABLE> <TR> <TD><input type="hidden" name="LL" value="59"/></TD> </TR> <TR> <TD><input type="hidden" name="ZZ" value="0"/></TD> </TR> <TR> <TD><input type="hidden" name="TRCD" value="IVTNO"/></TD> </TR> <TR> <TH>Command</TH> <TD><input type="text" name="CMD" value="DISPLAY"/></TD> </TR> <TR> <TH>Last Name</TH> <TD><input type="text" name="NAME1" value="LAST1"/></TD> </TR> <TR> <TH>First Name</TH> <TD><input type="text" name="NAME2" value=""/></TD> </TR> <TR> <TH>Extension</TH> <TD><input type="text" name="EXTN" value=""/></TD> </TR> <TR> <TH>Zip Code</TH> <TD><input type="text" name="ZIP" value=""/></TD> </TR> </TABLE> </form> <% try { if (request.getParameter("message")!=null) { out.println("<p> Creating a new Service Manager... </p>"); ServiceManager serviceManager = new ServiceManager(); out.println("<p> Locating the reference to a SCAImportBinding which imports the IMS PhoneBook service...</p>"); Service service = (Service) serviceManager.locateService("PhoneBookServicePartner"); Reference targetReference = (Reference) ServiceManager.INSTANCE.getComponent().getReference("PhoneBookServicePartner"); OperationType opType = (OperationType) targetReference.getOperationType("runPhoneBook"); BOFactory factory = (BOFactory)ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOFactory"); DataObject wrapper = factory.createByType(opType.getInputType()); out.println("<p> Setting input values...</p>"); DataObject phoneBook = factory.create("http://PhoneBook/sample/ims", "INPUTMSG"); phoneBook.setString("in__ll",request.getParameter("LL")); phoneBook.setString("in__zz",request.getParameter("ZZ")); phoneBook.setString("in__trcd",request.getParameter("TRCD")); phoneBook.setString("in__cmd",request.getParameter("CMD")); phoneBook.setString("in__name1",request.getParameter("NAME1")); phoneBook.setString("in__name2",request.getParameter("NAME2")); phoneBook.setString("in__extn",request.getParameter("EXTN")); phoneBook.setString("in__zip",request.getParameter("ZIP")); wrapper.set(0,phoneBook); out.println("<p> Invoking the service...</p>"); DataObject phoneBookOutWrapper = (DataObject)service.invoke("runPhoneBook",wrapper); DataObject phoneBookOut = (DataObject)phoneBookOutWrapper.get(0); out.println("<p> <b>Output from IMS transaction:</b> </p>"); out.println("<p> " + phoneBookOut.getString("outMsg") + "</p>"); out.println("<p> " + phoneBookOut.getString("out__name1") + "</p>"); out.println("<p> " + phoneBookOut.getString("out__name2") + "</p>"); out.println("<p> " + phoneBookOut.getString("out__extn") + "</p>"); out.println("<p> " + phoneBookOut.getString("out__zip") + "</p>"); } } catch (Exception e) { %><p>An exception occured during the invocation. See SystemOut.log and SystemErr.log for details.</p><% e.printStackTrace(); } %> </BODY> </HTML>Click the Design tab if you wish to see what the JSP will look like.