Tutorials > Management Center > Add new properties to a WebSphere Commerce service using the data service layer

< Previous


Validate the Catalog customization with JUnit

This step demonstrates how to test the customization using JUnit. This unit tests assumes a starter store with a store ID of 10101 and a catalog ID of 10101 has been published to the WebSphere Commerce Development environment.


Procedure

  1. Download the following unit test project to a temporary directory: CatalogExtensions-UnitTests.zip.

  2. Import the CatalogExtensions-UnitTest project into your workspace:

    1. Select File > Import > Other > Project Interchange > Next.

    2. Beside the From zip file label, click Browse and navigate to the CatalogExtensions-UnitTest.zip file downloaded in the previous step.

    3. Click Open.

    4. Select the CatalogExtensions-UnitTest project.

    5. Click Finish.

  3. Add the com.ibm.ws.webservices.thinclient_7.0.0.jar unit test project, found in SDP\runtimes\base_v7\runtimes, to the classpath.

  4. In the Enterprise Explorer view, Open CatalogExtensions-UnitTest\src\com.mycompany.commerce.catalog.facade.client\CatalogFacadeExtensionClientTest.java

  5. Replace the following constants with their machine specific values:

    • USER_ID = An administrator user ID on the WebSphere Commerce server.

    • PASSWORD = The password to the above administrator ID.

    • STORE_ID = The store ID of the published starter store.

    • CATALOG_ID = The catalog ID of the published starter store.

    Find the following snippet and replace the catEntryId value with the unique ID of a catalog entry that exists in the published starter store:

    * The catentry to find.
         */
        public String catEntryId = "10101";
        public String[] catEntryIdArray = {catEntryId};
        
    

    Save the changes and close the file.

  6. On the Server page, right-click the WebSphere Commerce Test Server and select Start.

  7. 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.

    4. Click Finish.

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

  8. 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 page click 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

    5. Click OK.

    6. Select the created TCP/IP monitor.

    7. Click Start.

    8. Click OK.

  9. Right-click the CatalogExtensionFacadeClientTest.java class and select Run As > JUnit Test.

    Running the JUnit test multiple times will cause it to fail on the second run, due to it having updated the row it retrieves. The warterm = 30 assertion will fail.

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

  10. Verify the results:

    • This test performs a Get request to retrieve a CatalogEntry noun including the warranty and care instruction data.

    • The Get request uses the XPath key of /CatalogEntry[CatalogEntryIdentifier[(UniqueID=)]] and the MyCompany_All access profile defined in step three.

    • The data service layer uses the XPath key and access profile to identify the SQL query template to run against the database and populate physical data objects with the results.

    • The business object mediator transforms the physical data objects into logical nouns. This process populates warranty information into the CatalogEntry noun's UserData element and populates care instructions into the Catalog description noun part's attributes element.

< Previous


+

Search Tips   |   Advanced Search