Tutorials > Management Center > Create the Project BOD service module

< Previous | Next >


Validate the Project service module with JUnit

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

Within the generated unit test project, one single Test class, ProjectFacadeClientTest, is also created. This test class extends from the JUnit TestCase class and contains test methods for every service that the service module supports. 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, ProjectFacadeClientTest, to validate the Project service module.


Procedure

  1. Import the provided ProjectFacadeClientTest JUnit Test:

    1. In the Enterprise Explorer view, right-click the Project-UnitTests/src/com.mycompany.commerce.project.facade package.

    2. Click Import. Expand General and select File System. Click Next.

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

    4. Browse to the com.mycompany.commerce.Project.facade.client folder.

    5. Select ProjectFacadeClientTest.java.

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

    7. In the ProjectFacadeClientTest.java file, search for the comment // TODO Change the username and password to match the server. Update the WebSphere Commerce Site Administrator user name and password in the class to match the server.

    8. Look for the comment // TODO: modify the test storeID. Replace the number 11301 with the storeId of the store.

    9. Save the changes.

    10. From the Project menu, select Clean, if Build Automatically is not selected, then select Build Project.

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

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the Project-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. On the Server page, right-click the WebSphere Commerce Test Server and select Start.

  4. 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 Project 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. Insert the test data into the WebSphere Commerce database:

    1. Navigate to the temporary location where you unzipped RecipeServices.zip, and in the data folder, open data.txt in a text editor.

    2. Replace the number 11301 with the storeId you are using.

    3. Open a new browser window and enter the following URL: http://localhost/webapp/wcs/admin/servlet/db.jsp.

    4. Paste the contents of the text editor into the text box in the browser window.

    5. Click Submit Query.

  7. Switch back to WebSphere Commerce Developer, and verify that there are no compilation errors in all projects in the Enterprise Explorer view.

  8. Run the JUnit test:

    1. Right-click the ProjectFacadeClientTest.java class and select Run As > JUnit Test.

    2. The JUnit Test is running. 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. You can also click the Console tab and you should see a message indicating that the test case has passed.

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