Validating the Project service module with JUnit
After you apply the HCL Commerce service module pattern, a Project-UnitTests project is created as a place to put JUnit tests for the services that you created.
About this task
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.
Use the provided JUnit test class, ProjectFacadeClientTest, to validate your Project service module.
Procedure
-
Import the provided ProjectFacadeClientTest JUnit Test:
- In the Enterprise Explorer view, expand right-click the com.mycompany.commerce.project.facade package.
- Click Import. Expand General and select File System. Click Next.
- Browse to the temporary location where you extracted the RecipeServices.zip.
- Browse to the com.mycompany.commerce.Project.facade folder.
- Select ProjectFacadeClientTest.java.
- Click Finish. Click Yes to All to overwrite the existing file.
- Open ProjectFacadeClientTest.java for editing.
-
Search for the comment
// TODO Change the username and password to match the server
. Update the HCL Commerce Site Administrator user name and password in the class to match your server. -
Search for the comment
// TODO: modify the test storeID
. Replace the number 11301 with the storeId of your store. - Save your changes.
- From the Project menu, select Build Project if Build Automatically is not selected.
-
Organize the imports for the Project-UnitTests project:
- Open the Java perspective in HCL Commerce Developer.
- Expand Project-UnitTests. Right-click src and select .
- Save all of the opened files. Select
-
Update the JAR dependencies for the HCL Commerce applications and Eclipse Modeling
Framework to the build path for the unit test project.
- Start or restart the HCL Commerce Test Server.
- Right-click the HCL Commerce Test Server and select Publish.
-
Set up a TCP/IP Monitor in HCL Commerce Developer. Use this TCP/IP Monitor to
observe the request and response documents that travel to and from the HCL Commerce
service you created.
-
Insert the test data into the HCL Commerce database:
- Navigate to the temporary location where you extracted the RecipeServices.zip file, and in the RecipeServices/data folder, open the data.txt file in a text editor.
- Replace the number 11301 with the storeId you are using.
- Open a new browser window and enter the following URL: http://localhost/webapp/wcs/admin/servlet/db.jsp.
- Paste the contents of your text editor into the input text box in your browser window.
- Click Submit Query.
- In the Enterprise Explorer view, verify that your projects have no compilation errors.
-
Run the JUnit test: