Step 4: Test the Controls

In this step you are going to test the two controls and examine whether their behavior is as intended. To do so, you must create a client application, such as a web application, to invoke the custom control. Here you will build a test web service instead.

The tasks in this step are:


To Create the Web Service Project

Web service development is done in a separate project in the application.

  1. In the Application tab, right-click the GettingStarted_Control folder and select New-->Project.
  2. In the New Project dialog, in the upper left-hand pane, select Web Services.
    In the upper right-hand pane, select Web Service Project.
    In the Project Name field, enter MyControlTestProject.

  3. Click Create.
  4. In the Application tab, right-click MyControlTestProject and select New-->Folder. Enter hello.
  5. Click OK.


To Generate the Test Web Service

A test web service is a web service that exposes the methods of a control. In this particular case the test web service is a client application that calls the methods on the custom control Hello. To learn more about web services, see the Getting Started Tutorial: Web Services.

To Run the Test Web Service

Let's run the test web service and test the behavior of the Java controls.

  1. Make sure the HelloTest web service is open.
  2. Click the Start button.



    Workshop launches the Workshop Test Browser.
  3. If this is the first time you have ever run this application, click the createTable button to make the table the database control is going to query.
  4. Scroll down to the Service Response section, and notice that no exceptions are thrown.
  5. Scroll back up and click the Test Operations link.
  6. Enter your name in the String field and click the hello button.
  7. Scroll down to the Service Response section, and notice that the response is Hello, <your name>!

    In the preceding two steps the web service invoked the hello method on the custom control. The control called the getVisits method of the VisitDB database control to find out the number of previous visits. Because you were running this test for the first time, this method returned 0, your name was added to the database using the database controls insertVisitor method, and the Hello control returned the appropriate response.
  8. Click the Test Operations link, enter your name again, click the hello button, and notice that the response is Hello again, <your name>!

    In this step the Hello control again invoked the getVisits method of the VisitDB database control to find out the number of previous visits. This method returned 1, the database record was updated to reflect that this was your second visit using the VisitDB's updateVisits method, and the Hello control returned the appropriate response.
  9. Click the Test Operations link, enter your name again, click the hello button, and notice that the response is Hello <your name>! This is visit number 3.
  10. Repeat the test with a different name and observe the outcome.
  11. Return to WebLogic Workshop and press the Stop button to close the Test Browser.

Click one of the following arrows to navigate through the tutorial: