Previous Topic: Integrating ComponentsNext Topic: Collect Transaction Information


Integrate Server-Side Components

This procedure describes how to DevTest-enable a server-side component.

Follow these steps:

  1. Import the necessary classes.

    The component must at least import the appropriate integrator and the TransInfo class. For example, to import the classes necessary to integrate a servlet, add the following import statements:

    import com.itko.lisaint.servlet.ServletIntegrator;
    import com.itko.lisaint.TransInfo;
    

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

  2. Declare local variables to hold state.

    The integrated component needs at least an integrator and a TransInfo variable, as seen in the following code:

    ServletIntegrator si = null;
    TransInfo ti = null;
    
  3. Start a transaction.

    The integration API lets you control when the integrated component begins to communicate with the DevTest software. All the communication must happen in context of a transaction. Therefore, before beginning to communicate, start a transaction using the application-specific integrator. You can ensure that DevTest is on before that by checking with the application-specific integrator class. The following code checks if DevTest is on, then retrieves the servlet integrator from the integrator class and stores it in the variable si. The code then starts the transaction using the servlet integrator and stores the result in the TransInfo object.

    if( ServletIntegrator.isLisaOn( request ) ) {
        si = ServletIntegrator.getServletIntegrator( request );
        ti = si.startTransaction( "Hello World" );
    }
    
  4. Interact with the test case.

    Report component status. The TransInfo class provides a method, setBuildStatus(), that allows you to specify information that the system can use to determine how to run the test. For example, to tell DevTest that the component has failed, set the build status to STATUS_FAILED, as seen in the following code:

    if( /* component failed */ ) {
        // ...
        ti.setBuildStatus( TransInfo.STATUS_FAILED, failMsg );
    }
    

    For more information about valid build status codes, see Build Status under Collect Transaction Information.

  5. Send the response back to DevTest.

    For more information about sending responses back to DevTest, see Handle Integrated Output.

 

JSP Tag Library

In addition to the Java API shown previously, DevTest provides a JSP tag library for Java web development. This API makes using the Integration API easy for JSP developers.

 

Pure XML Integration

DevTest makes available a pure XML form of the Integration for web applications on an as-needed basis. If you require this form of integration, contact your sales or support representative.

 

Test Components

Sometimes a server-side application has a number of checks and it is not clear where the test step failed. You can separate out parts of the transaction using subcomponents and can report their individual statuses. The com.itko.lisaint.CompInfo class represents a subcomponent.

For example, the following code creates a subcomponent of the transaction and sets its build status to STATUS_SUCCESS:

CompInfo ci = ti.newChildComp( "SUBCOMP" );
ci.setBuildStatus( CompInfo.STATUS_SUCCESS, "" );
ci.finished();

Subcomponents are treated as part of the overall transaction. If one subcomponent fails, the entire transaction fails. The following code creates a subcomponent and sets the build status to STATUS_FAILED. In this case, the entire transaction fails.

CompInfo ci = ti.newChildComp( "SUBCOMP" );
ci.setBuildStatus( CompInfo.STATUS_FAILED, "" );

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