Testing the REST Service in Cloud Foundry

You can now test the REST service using the built-in tester and the Swagger UI.

Procedure

  1. In the Project Explorer, expand the tibco.bwce.sample.binding.rest.BookStore.application process and expand the Package Unit > Properties folder.
  2. In the Properties window, expand the tibco.bwce.sample.binding.rest.BookStore.application and set the default Application Profile to PCF as shown in the next image. The bracketed profile in the column head is the one that is selected:
  3. Expand the Package Unit and select Overview.
  4. In the Overview window select Export Application for Deployment.
  5. Enter the location of your EAR file (this would be the same directory as the manifest.yml file ).
  6. In your Cloud Foundry environment, navigate to the directory containing your EAR.
  7. Execute
    cf push -f manifest.yml
    
    
    If the application deploys successfully, you will get a routable URL.
  8. Launch the Google Chrome browser and open http://<BWCE-APP-URL>/swagger. Click Books or Events to see the operations. Click MyBooks to see the REST service operations you just added. See the section called Testing the POST and GET Operations for information.
  9. Expand the Books and Events headers, and test out the operations as listed below.

Result

Click Books or Events in the Swagger UI to view the following operations for Books and Events:

Books

  • Post books
  • GET books
  • GET book by ISBN
  • PUT book by ISBN
  • DELETE book by ISBN
Events
  • POST Events
  • GET Events
  • GET Event by EventID
  • PUT Event by EventID
  • DELETE Event by EventID

GET books returns an output similar to the following:

{
  "Book": [
    {
      "isbn": "0061122416",
      "name": "The Alchemist",
      "description": "Every few decades a book is published that changes the lives of its readers forever. The Alchemist is such a book",
      "authorName": "Paul Coelho",
      "releaseDate": "2006-04-25",
      "vintage": true,
      "signed": true,
      "price": 11.9
    },
    {
      "isbn": "0071450149",
      "name": "The Power to Predict",
      "description": "How Real Time Businesses Anticipate Customer Needs, Create Opportunities, and Beat the Competition",
      "authorName": "Vivek Ranadive",
      "releaseDate": "2006-01-26",
      "vintage": false,
      "signed": true,
      "price": 15.999
    }
 ]    
}

GET books by ISBN returns an output similar to the following for ISBN 0061122416:

  {
      "isbn": "0061122416",
      "name": "The Alchemist",
      "description": "Every few decades a book is published that changes the lives of its readers forever. The Alchemist is such a book",
      "authorName": "Paul Coelho",
      "releaseDate": "2006-04-25",
      "vintage": true,
      "signed": true,
      "price": 11.9
    }