The ex04_3 example implements the subresource locator example shown in Full Dynamic Dispatching in Chapter 4.
Perform the following steps:
There’s really not much to go over that wasn’t explained in Chapter 4.
The client code lives in src/test/java/com/restfully/shop/test/CustomerResourceTest.java:
public class CustomerResourceTest
{
@Test
public void testCustomerResource() throws Exception {
...
}
@Test
public void testFirstLastCustomerResource() throws Exception {
...
}
}
The code contains two methods: testCustomerResource() and testFirstLastCustomerResource().
The testCustomerResource() method first performs a POST to /customers/europe-db to create a customer using the CustomerResource subresource. It then retrieves the created customer using GET /customers/europe-db/1.
The testFirstLastCustomerResource() method performs a POST to /customers/northamerica-db to create a customer using the FirstLastCustomerResource subresource. It then uses GET /customers/northamerica-db/Bill-Burke to retrieve the created customer.