Validating the catalog customization with JUnit
In this lesson, you test your customization with a JUnit validation.
About this task
Procedure
- Download the following unit test project to a temporary directory: CatalogExtensions-UnitTests.zip.
-
Import the downloaded CatalogExtensions-UnitTest project into your
workspace.
- In IBM WebSphere Commerce Developer, click .
- In the Import wizard, expand .
- Select Existing Projects into Workspace and click Next.
- Select the Select archive file option and browse for the CatalogExtensions-UnitTest.zip project that you downloaded.
- Select the project and click Open.
- In the Import wizard, select the CatalogExtensions-UnitTest project and click Finish.
-
Add the unit test project JAR file to the Java Build Path for your Unit Test:
- Expand .
- Open the CatalogExtensionFacadeClientTest.java file for editing.
-
Replace the following constants with your environment-specific values:
- USER_ID = An administrator user ID on your WebSphere Commerce server.
- PASSWORD = The password to the administrator ID.
- STORE_ID = The store ID of the published starter store.
- CATALOG_ID = The catalog ID of the published starter store.
- catEntryId = The catalog entry ID of a catalog entry in your published starter store that you identified in earlier lessons.
- Save your changes.
- Start the WebSphere Commerce Test Server.
-
If the WC project is not already published to the WebSphere Commerce
Test Server, publish the WebSphere Commerce project:
- On the Server page, right-click the WebSphere Commerce Test Server and select Add and Remove.
- Select the WC project.
- Click Add.
- Click Finish.
If the WC project is already published, right-click the WebSphere Commerce Test Server and select Publish.
-
Set up a TCP/IP Monitor in WebSphere Commerce Developer to observe
the document requests to and from the WebSphere Commerce service that you created:
-
Right-click the CatalogExtensionFacadeClientTest.java class and select .
Note: Running the JUnit test multiple times causes it to fail on the second run because the test updates the row it retrieves. The warterm = 30 assertion fails.
You can observe the request and response XML documents that are transmitted between the client and server on the TCP/IP Monitor.
-
Verify the results:
- This test performs a Get request to retrieve a CatalogEntry noun that includes the warranty and care instruction data.
- The Get request uses the XPath key of /CatalogEntry[CatalogEntryIdentifier[(UniqueID=)]] and the MyCompany_All access profile that is defined in step 3.
- 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 UserData element and populates care instructions into the Catalog description noun part's attributes element.