Previous Topic: IntegratorsNext Topic: Testing Integrated Components


Handle Integrated Output

In addition to the transaction information, the integrated component must return the results of the component to DevTest Solutions. For servlets, this involves wrapping servlet responses. For Java-based components, this involves constructing a response object.

 

Wrapping Servlet Responses

DevTest integrates with web-based applications by embedding a streamed version of the integrator into the HTML output of the web server. The ServletIntegrator object is converted to ASCII text and wrapped in an HTML comment. The ServletIntegrator class provides a method, report, that takes an output stream and performs the described wrapping before sending it back to DevTest.

The following code wraps the servlet response and sends it back toDevTest if the ServletIntegrator indicates that DevTest is on:

if( ServletIntegrator.isLisaOn( request ) )
si.report( out );

For more information about the ServletIntegrator class, see the JavaDocs in the doc folder of your installation directory.

 

Constructing a Response Object

DevTest integrates with Java-based applications by enforcing that either the method returns value types or the class you are executing itself implements the com.itko.lisaint.java.HasLisaIntegrator interface.

For example, assume you have implemented an object with a LoginInfo object as a return value to the login (String uid, String pwd). The LoginInfo object maintains the information about whether the test succeeded or failed. To test that method, a test case author executes the login method, then queries the returned LoginInfo object to determine the success or failed state.

To implement the com.itko.lisaint.java.HasLisaIntegrator interface, implement the getLisaIntegrator() method to provide an XML representation of your integration object to DevTest.

Most implementations also provide a setLisaIntegrator() method and store the state in a member variable, as in the following code:

public class LoginInfo implements HasLisaIntegrator {
 
    private JavaIntegrator lisa;
 
    public String getLisaIntegrator() {
        return lisa.toXML();
    }
 
    public void setLisaIntegrator(JavaIntegrator obj) {
        lisa = obj;
    }
 
}

For more information about the HasLisaIntegrator and LoginInfo classes, see the JavaDocs in the doc folder of your installation directory.