Testing in TIBCO Business Studio™ Container Edition

Prerequisites

  • Access to a locally running PostgreSQL database.
  • A web browser.

Procedure

  1. From the File Explorer, navigate to the samples > Container > cloudfoundry > binding > rest > Bookstore folder and double-click tibco.bwce.sample.binding.rest.BookStore.
  2. From the Project Explorer expand the tibco.bwce.sample.binding.rest.BookStore.application project.
  3. Expand tibco.bwce.sample.binding.rest.Bookstore.application > Package Unit folder. Provide valid values for the application properties. Provide a valid dbUserName, dbPassword and dbURL to connect to your locally running PostgreSQL database.
  4. Set the ApplicationProfile to local. See Setting the Default Application Profile.
  5. Verify your JDBC connection.
    1. Expand the Resources directory.
    2. Double-click JDBCConnectionResource.jdbcResource.
    3. Click the Test Connection button to verify the connection.
  6. Click File > Save.
  7. From the Project Explorer expand the Processes folder and the tibco.bwce.sample.binding.rest.BookStore package within that folder.
  8. Click Run > Debug.
  9. From the Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  10. Click the Applications tab and then click the Deselect All button if you have multiple applications.
  11. Select the checkbox next to tibco.bwce.sample.binding.rest.BookStore.
  12. Click Debug.
    The sample now runs in the debug mode.

    The console window shows engine messages similar to:

    Started BW Application [tibco.bwce.sample.binding.rest.BookStore. [tibco.bwce.sample.binding.rest.BookStore.application:1.0].
     The OSGI command to list REST and Swagger URLs is 
    				lrestdoc, which lists the discovery URL:[Application Name]: tibco.bwce.sample.binding.rest.BookStore.application [Discovery Url]:http://localhost:7777/tibco.bwce.sample.binding.rest.BookStore.application 
    			 
    
  13. Launch the browser and open:
    http://localhost:7777/tibco.bwce.sample.binding.rest.BookStore.application
    
    
    The following page is displayed

  14. Click on any of the listed operations GET, PUT, PUT, or DELETE.
  15. Click the Terminate icon when you have completed using the listed operations.

Result

The web page lists 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 the 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
    }

The books.log file is generated with the following information:

POST Books------->{"Book":[{"isbn":"1451648537","name":"Steve Jobs","description":"Biography of Apple Co-Founder Steve Jobs","authorName":"Walter Isaacson","releaseDate":"2012-10-24","vintage":false,"signed":false,"price":21},{"isbn":"0385537859","name":"Inferno","description":"Robert Langdon returns in Dan Brown's latest fast paced action thirller","authorName":"Dan Brown","releaseDate":"2013-05-14","vintage":false,"signed":true,"price":14.09},{"isbn":"0399103421","name":"The Godfather","description":"The Godfather is an epic story of a New York's top mafia family, loyalty, and how men of honor live in their own world, and die by their own laws.","authorName":"Mario Puzo","releaseDate":"1969-03-10","vintage":true,"signed":true,"price":50}]}**************************************************************

GET Books------->{"Book":[{"isbn":"1451648537","name":"Steve Jobs","description":"Biography of Apple Co-Founder Steve Jobs","authorName":"Walter Isaacson","releaseDate":"2012-10-24+05:30","vintage":false,"signed":false,"price":21},{"isbn":"0385537859","name":"Inferno","description":"Robert Langdon returns in Dan Brown's latest fast paced action thirller","authorName":"Dan Brown","releaseDate":"2013-05-14+05:30","vintage":false,"signed":true,"price":14.09},{"isbn":"0399103421","name":"The Godfather","description":"The Godfather is an epic story of a New York's top mafia family, loyalty, and how men of honor live in their own world, and die by their own laws.","authorName":"Mario Puzo","releaseDate":"1969-03-10+05:30","vintage":true,"signed":true,"price":50}]}**************************************************************

GET Book By ISBN------->{"isbn":"1451648537","name":"Steve Jobs","description":"Biography of Apple Co-Founder Steve Jobs","authorName":"Walter Isaacson","releaseDate":"2012-10-24+05:30","vintage":false,"signed":false,"price":21}**************************************************************

DELETE Book By ISBN-------->"Deleted book with ISBN - 1451648537"**************************************************************

GET Events By ISBN---->{}**************************************************************