REST test harness demonstration
The CASL for REST services demonstration project (CaslRestDemo
)
showcases the usage of the CaslRest framework. It includes sample tests that cover the various types
of REST services found with WebSphere Commerce. It also includes a basic shopping flow example.
Prerequisites
- Publish the Aurora
starter store (ExtendedStites.sar). Notes:
- The extended sites store archive is published by default in the WebSphere Commerce Developer environment.
- The demonstration is run against the Aurora (B2C) storefront assets store, which is part of the ExtendedStites.sar file.
- Running the demonstration changes the state of the store. The changes are limited to the database. If you require the store to be in its original state after the tests are ran, then back up the store and database before you run the demonstration.
Test suites
- AllTests – This suite runs every test
- OnPremTests – This suite runs all the CaslRest demonstration test cases that work with on-premises
- ExtCustomizationTests - This suite runs all externalized customization extension test examples that are intended for Commerce on Cloud.
Test case documentation
All tests are documented within the Java code by way of JavaDocs. Refer to each test class/method for details on the purpose of each test case.
Configuration properties
# The WebSphere Commerce Server host name
HOSTNAME=localhost
MACHINE.1.ROLE=WebsphereCommerce
MACHINE.1.HOSTNAME=localhost
MACHINE.2.ROLE=SearchServer
MACHINE.2.HOSTNAME=localhost
#PRODUCT_TYPE=RUNTIME
PRODUCT_TYPE=TOOLKIT
##
#
# The port for the search web server
#
#For runtime:
#SEARCH_WEBSERVER_PORT=3737
#SEARCH_WEBSERVER_PREVIEW_PORT=3738
#For toolkit:
SEARCH_WEBSERVER_PORT=80
SEARCH_WEBSERVER_PREVIEW_PORT=443
RUNTIME
properties, and comment out the TOOLKIT
properties.Test details
Most of tests require a registered shopper. To ensure that a failing test that does not interfere with another test, a new shopper is created automatically each time a test is run.
The other CaslRest test examples demonstrate different types of REST calls made to WebSphere Commerce, including GET, PUSH, PUT, and DELETE. It also covers search-type REST calls and a negative test flow. By referring to the Swagger documentation for the Commerce REST API and these examples, you can use the CaslRest framework for any Commerce REST testing, including any new and customized REST resources the user creates.
Test class: com.ibm.commerce.caslrestdemo.tests.TestCaslRestExamples
Method | Purpose |
---|---|
testSearchFindResource |
Demonstrates usage of the search REST API. Here a search for products is conducted by search terms. |
testWcAddRestResource |
Demonstrates a POST-type REST call to WebSphere Commerce to add a payment instruction for the current contents of the cart. |
testWcAddWithJsonBody |
Demonstrates a POST-type REST call that has a JSON body, for example entity .
In this case, a registered shopper adds an item to their cart. |
testWcDeleteRestResource |
Demonstrates a DELETE-type REST call in which the user logs out. |
testWcGetRestResource |
Demonstrates a GET-type REST call against the WebSphere Commerce Transaction Server in which the user wants to get the member group information for a particular customer. |
testWcRestResourceWithException |
Demonstrates a negative test case. The expected result is an error response. The framework provides an error response object, making it easy to get and assert values from the response. |
testWcUpdateRestResource |
Demonstrates a PUT-type REST call to WebSphere Commerce to update the quantity of an item in the cart. |
Test class: com.ibm.commerce.caslrestdemo.tests.TestShoppingFlow
Method | Purpose |
---|---|
testTypicalShoppingFlow |
Demonstrates how CaslRest can be used to perform the following typical shopping flow:
|