Tutorials > Program model > Web services > Create a new WebSphere Commerce BOD service module

< Previous | Next >


Deploy and validating the TutorialStore service module with JUnit

After applying the WebSphere Commerce service module pattern, a BODTutorialStore-UnitTests project is created as a place to put JUnit tests for services created.

Within the generated unit test project, one single Test class, BODTutorialStoreFacadeClientTest, is also created. This test class extends from the JUnit TestCase class and contains test methods for every service that the service module will support. These test methods build empty service request objects and use the generated client library class to issue the Web service request and receive the service response.

In this section of the tutorial, you are going to use the provided JUnit test class, BODTutorialStoreFacadeClientTest, to validate the TutorialStore service module. This case will perform the following actions:

The following diagram shows how using JUnit to drive testing through the client library fits into the overall customization process:


Procedure

  1. Import the provided BODTutorialStoreFacadeClientTest JUnit Test:

    1. In the Enterprise Explorer view, right-click the BODTutorialStore- UnitTest/src/com.mycompany.commerce.tutorialstore.facade.client package.

    2. Select Import > FileSystem. Click Next.

    3. Browse to the temporary location where you unzipped TutorialStore.zip.

    4. Browse to the BODTutorialStore-UnitTest\src\com.mycompany.commerce.tutorialstore.facade.client folder.

    5. Select BODTutorialStoreFacadeClientTest.java.

    6. Click Finish. Click Yes to All to overwrite the existing file.

    7. Inside the testTutorialStore method, look for the comment // TODO Change the username and password to match the server. Update the WebSphere Commerce Administrator user name and password in the class to match the server.

    8. Save the changes.

  2. Organize the imports for the BODTutorialStore-UnitTests project:

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the BODTutorialStore-UnitTests\src folder and select Source.

    3. Select Organize Imports.

    4. Save all of the opened files if you have not already done so. From the pull down menu, select File > Save All.

  3. Start the test server: On the Server page, right-click the WebSphere Commerce Test Server and select Start.

  4. If the WC project is not already published to the WebSphere Commerce Test Server, publish the WebSphere Commerce project:

    1. On the Server page, right-click the WebSphere Commerce Test Server and select Add and Remove Projects.

    2. Select the WC project.

    3. Click Add. Click Finish.

    If the WC project is already published, right-click the WebSphere Commerce Test Server and select Publish.

  5. Set up a TCP/IP monitor in WebSphere Commerce Developer. You will use this TCP/IP monitor to observe the request and response documents going to and from the WebSphere Commerce service you created. To create a TCP/IP Monitor to forward requests to WebSphere Commerce:

    1. Select Window > Preferences.

    2. From the Preferences panel select Run/Debug > TCP/IP Monitor.

    3. Click Add.

    4. Type the following information:

      • Local monitoring port:81.

      • Hostname: The hostname of the WebSphere Commerce Server where the TutorialStore service is running.

      • Port:80 for WebSphere Commerce Developer, 8007 for production

    5. Click OK.

    6. Select the created TCP/IP monitor.

    7. Click Start.

    8. Click OK.

  6. Run the JUnit test:

    1. Right-click the BODTutorialStoreFacadeClientTest.java class and select Run.

    2. Select JUnit Test. You should see the request and response XML documents transmitted between the client and server on the TCP/IP monitor.

    3. If the validation is successful, we will see a green bar on the JUnit view.

      If you receive an error message, ensure that you set the JNDI - CMP Connection Factory Binding property of the BODTutorialStore-Server module (ejb-jar.xml).

From the TCP/IP Monitor, you can review the request and response BOD messages sent between the client and server as part of the test.

< Previous | Next >


+

Search Tips   |   Advanced Search