WebSphere test environment setup

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.

Testing overview

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.

Development decisions that affect testing

Two choices at development time will affect the setup of your testing
  • Did you specify a JNDI name? If so, then your server will have the connection properties and you do not need to specify them in the WebSphere test environment. You will need to set up the resource adapter on the server and add the JNDI name to the server to match the JNDI name you specified, if it has not been set up for you. Conversely, if you did not specify a JNDI name then the connection properties you either discovered or declared at development time will be used.
  • Did you specify a resource authentication alias? You likely did if you discovered your connection properties, specified them, or specified a resource authentication alias in addition to the JNDI lookup name. If you did, then you must also add the resource authentication alias to the WebSphere test environment using the administration console.

Testing an import created with PeopleSoft

If you created your own import in a similar way to section Creating an import using PeopleSoft, here is one way you could test it.
  1. Select the component in the assembly editor and in the properties view, select the Binding. Select the Connection tab and expand Authentication Properties. Add a name for the J2C Authentication Data Entry field, also known as the resource authentication alias. Typically, the name consists of a node and a name. For example, widNode/psoft.
  2. Start the test server. Right-click the server in the Servers view and from the pop-up menu select Start. Add the name you just created to the J2C Authentication Data field. Launch the Administration Console from the same popup menu. Select Security > Global security > JAAS Configuration > J2C Authentication data. Add the alias name, userid and password and save your additions.
  3. Add your project to the server. Return to the server menu and launch Add and remove projects, and add your project.
  4. In the navigation, right-click your module and then select Test > Test Module from the pop-up menu. There will be a key field with unique values, such as a vendor identification number. Enter the value and select an operation, typically, create, replace, update, delete, and other similar operations performed on databases.
  5. Then invoke the test environment, specify the server you put your project on and click Finish. The operation should complete. Note that if you experience problems, analyzing the errors in the log files can help you. See Problem analysis for EIS imports and exports.

Testing an import created with CICS®

If you created your own import in a similar way to section Creating an import component using CICS, then here is one way you could test it.
  1. We used the following COBOL code for our particular example:
    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.
  2. In our case, we did specify a JNDI name, so connection properties and authentication take place at the server. One simple way to test this type of situation is to create a JSP that will invoke the service. Since a JSP is not in the Service Component Architecture, it will need to be referenced through a standalone references component.
  3. In the assembly editor, select Stand-alone References from the palette and drag it onto the canvas. Then use the wire tool to connect the stand-alone references component with your CICS import component.
  4. Create another module with a Dynamic Web Project called CICSImportClient and add the CICS import component module to its classpath. Then open the CICS import component Module Dependency Editor, expand the J2EE section and add the CICSImportClient project as a dependency. Then remove CICSImportClient from the CICS import project classpath to prevent a circular dependency between these projects.
  5. Add a JSP to the WebContent folder in the CICSImportClient project for testing your program on the CICS server. The JSP we used follows. You should be able to modify this one for your own particular case.
    <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>
  6. Add your projects to the server as you did in the previous section. Select the JSP and click Run on Server.

Testing an import created with IMS™

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.
Connection properties with JNDI lookup name and J2C authentication data entry specified
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.

  1. In the Server view, right click WebSphere Process Server v6.0 and select Start from the menu. When the status has changed to Started, a process that often takes a few minutes, right click WebSphere Process Server v6.0 a second time and select Run administrative console. Logon to the WebSphere Administrative console using the userid testims.
  2. Expand Resources and select Resource Adapters. Click Install RAR.
    Installing the resource adapter
  3. In the Install RAR File page, select the Local path radio button and browse to the JCA 1.5 IMS resource adapter RAR file. It will be in <installdir>\Resource Adapters\ims15. Select Next.
    Specifying resource adapter path
  4. The General Properties page opens. Leave all fields empty. By doing so, the resource adapter name will become IMS Connector for Java™, which you will see later. Click OK.
  5. The Resource adapters page returns. Click IMS Connector for Java, which is now listed. On the following page beneath Additional Properties, which is found on the right side of the page, click J2C connection factories.
    J2C connection factories
  6. Configure the connection factory as follows:
    1. In the J2C connection factories page, click New.
    2. Beneath the General Properties section, in the Name field, enter imsTarget. Leave the JNDI name field empty, as leaving it empty will result in the correct JNDI name, eis/imsTarget, being generated. Click Apply at the bottom of this section.
      General properties
    3. Beneath Additional Properties, which is found on the right side of the page, click Custom properties.
      Custom properties
    4. Enter the appropriate property values for your environment and the features that you are using. For example, you only need to enter values in the Value column for the DataStoreName, HostName, and PortNumber properties in this example since you are using a non-SSL TCP/IP connection using COBOL rather than MFS source. For each property value that you set, click the field to be set, enter a value in the resulting page and then select OK for that property. When finished, click Save in the Messages box.
      DataStoreName, HostName and PortNumber settings
    5. The Resource adapters page returns. Click Save to save all your updates.
  7. Collapse the Resources navigation. Expand Security. Select Global security.
  8. The Global security page opens. On the right side of the page beneath Authentication, expand JAAS Configuration. Click J2C Authentication data.
    J2C Authentication data
  9. The J2EE Connector Architecture (J2C) authentication data entries page opens. Click New.
  10. Beneath the General Properties section, in the Alias field, enter myAlias. In the User ID and Password fields, enter your userid and password. Note values must be entered for userid and password even if your server does not check for them. Click OK.
    Alias name
  11. The J2EE Connector Architecture (J2C) authentication data entries page returns. widNode/myAlias has been added to the list. In the Messages box, click Save.
  12. The Global security page returns. Click Save to save all your updates.
  13. Close the Admin Console. Stop the server. Then restart it. Stopping and restarting WebSphere Process Server v6.0 is a way of making certain that the connection factory changes have been incorporated.
  14. Right-click the PhoneBook module and from the menu select Test > Test Module. Accept the default values for the Configuration, Module, Component, Interface and Operation fields. In the Initial request parameters table, enter the following values in the Value field for the following names in the Name field:
    Table 1. Input values
    Name Type Value
    in__ll short 59
    in__zz short 0
    in__trcd string IVTNO
    in__cmd string DISPLAY
    in__name1 string LAST1

    Initial input values
  15. Click Continue. The Deployment Location wizard opens. Select WebSphere Process Server v6.0 and click Finish.
  16. The application generated for your import component is published on the server, starts and runs. It returns the following values from the IMS server in the Return parameters table.
    Output values returned from IMS server
  17. Close the WebSphere test environment. Stop the WebSphere Process Server v6.0 server.

The following errors could occur while testing your component.

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.

  1. In the import created in Creating an import component using IMS, we specified a JNDI name, eis/imsTarget, and a resource authentication alias, widNode/myAlias, so connection properties and authentication take place at the server. One simple way to test this type of situation is to create a JSP that will invoke the service. Since a JSP is not in the Service Component Architecture, it will need to be referenced through a standalone references component.
  2. Right-click the PhoneBook module and select Open from the menu. The assembly editor opens and the import PhoneBookService is displayed.
  3. Expand Import in the palette, select Stand-alone References and drag it onto the canvas. From the palette, select the wire tool to connect the Stand-alone references component with your IMS import component.
    • When adding a wire connection, you may receive the following message: A matching reference will be created on the source node. Do you want to continue? Click OK.
    • When adding a wire connection, you may receive the following message: There are one or more references on this component that are described by WSDL interfaces. It is simpler to develop Java clients if they use component references that are described as Java interfaces. Would you like to convert the WSDL interfaces used by this component's references so that they use Java interfaces?. The answer to this question will determine how you code the JSP. For this example, click No.
  4. Save your changes in the assembly editor. Close the assembly editor.
    Stand-alone reference added
  5. Change to the J2EE perspective. From the menu, select Window > Open Perspective > Other. In the Select Perspective dialog box, select J2EE. Click OK.
  6. Create a dynamic web project. From the menu, select File > New > Other. Ensure the check box Show All Wizards is selected. Select Web > Dynamic Web Project . Click Next. You may receive the following message: This action requires the enablement of "Web Development (typical)". Enable the required capability? Click OK.
  7. The New Dynamic Web Project wizard opens.
    1. In the Name field, enter IMSImportClient.
    2. Click Show Advanced. Check the Servlet version is 2.4 and the Target server is WebSphere Process Server v6.0.
    3. Select Add module to an EAR project, if not selected. From the EAR project drop-down list, select PhoneBookApp. Click Next.
      Dynamic Web project settings
    4. The Module Dependencies page opens. Leave as is. Click Finish. Click No if asked to switch to the Web perspective.
  8. Right-click IMSImportClient and select Properties from the menu. The Properties for IMSImportClient window opens. Select Java Build Path. Select the Projects tab. Add the following projects: PhoneBook and PhoneBookEJB. Click OK.
  9. Expand IMSImportClient. Right-click WebContent. From the menu, select New > JSP File. The New JSP File window opens. In the File name field, enter TestIMS. Click Finish.
  10. The JSP editor opens with the JSP. Delete the line Place content here. Click the Source tab. Delete the code inside except for the top line, <!DOCTYPE HTML PUBLIC ...//EN">. Copy the following JSP code into the JSP.
    <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.
  11. Save the JSP. Close the JSP editor.
  12. Expand Enterprise Applications. Expand PhoneBookApp. Right-click Deployment Descriptor: PhoneBookApp and select Open. Beneath the Modules section in the Application Deployment Descriptor editor, a new Web module has been added: IMSImportClient.war. It contains the JSP to test PhoneBook. The other Web module, PhoneBookWeb.war is generated by WebSphere Integration Developer and is used when you test your component. Note that you should not add your JSP to this Web module. Close the Application Deployment Descriptor editor.
  13. To test the PhoneBook component using the JSP in a client project, right-click WebSphere Process Server v6.0 in the Servers view and from the menu select Add and remove projects. Check PhoneBookApp has been added to the Configured projects . For this example, this is the server on which you have configured the connection factory with JNDI name eis/imsTarget and the resource authentication alias, widNode/myAlias. Click Finish.
  14. Right-click WebSphere Process Server v6.0 and select Start.
  15. Once started, beneath Dynamic Web Projects, expand IMSImportClient. In the WebClient folder, right-click TestIMS.jsp. From the menu, select Run > Run on Server. The Server Selection window opens with the default WebSphere Process Server v6.0 server. Click Finish. The TestIMS.jsp is displayed in the Web browser.
  16. Enter the input data to run the IMS transaction that corresponds to your import component. In our case, we had the following input data. Click IMS Outbound Test.
    Input data
  17. The output data is returned from the IMS server in the JSP.
    Output data

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.