# How Do I: Generate a JWS File to Test a Java Control?

When you're developing a Java control, you can quickly generate a JWS (web service) file with which to test the control. The generated JWS includes methods that are designed to call methods of your control. The generated file is also conversational so that it can support your control's interface even if it is asynchronous.

While the generated file is obviously not a substitute for actual testing, it does provide an easy to find out if your code works as you expect.

To Generate a Test JWS File

1. In the Application window, locate the JCS file for your Java control.
2. Right-click the JCS file, then click Generate Test JWS File.

   WebLogic Workshop will open the newly generated JWS file in Design View. The generated file will include methods that call your control's methods. Where your control's methods have return values, those values will be returned by the test file's methods.

   In many cases, the template you created can be run as generated. However, in some cases you may need to make a few changes before using it to test.

   - If the JWS is for a control that's in a control project, you must move the JWS to a web application before you can use it.
   - If parameters of the control's operations are interfaces or types with no public constructor, you will need to modify the JWS before it will compile and run.
   - If the control's parameters are types that aren't supported in JWS operations, then the generated code will be commented. You must fix the code before using it. For example, if the parameter type is a DatabaseFilter class (as might be generated from a Database control JCX), then you should change the DatabaseFilter parameter to a String parameter and construct the DatabaseFilter class in JWS code.

- If your control exposes callbacks, be sure to separately implement support for testing them.

  The test JWS file does not include code to handle your control's callbacks. The test interface can receive the request, but it cannot respond to it because it does not implement the callback interface set by the service. To test callbacks, the callback handlers must be tested from a client that implements the callback interface. To do this you might create callbacks within the test JWS, then call these from your control's callback handlers.

3. Run the test JWS file.
4. In Test View, click startTestDrive to begin testing.

> This starts the web service's conversation.

3. After Test View refreshes, click the Continue this conversation link in Test View for access to test forms and buttons through which you can test each of your control's methods.
4. After Test View refreshes, use the test form provided to test your control's methods. After each test, click Continue this conversation to test another method.

5. When you are finished testing, click finishTestDrive to finish testing.

Samples

None.

Related Topics

None.