Package lumis.lptf.doui.serviceinterface

Package class diagram package lumis.lptf.doui.serviceinterface
This package contains the the test base class useful to perform tests on Doui service interfaces.

See:
          Description

Interface Summary
IDouiActionRequestCycle Interface for Doui action request cycle.
IDouiRenderRequestCycle Interface for Doui render request cycle.
IDouiRequestCycle Interface for Doui request cycle.
 

Class Summary
DouiRequestCycleFactory Creates and initializes DouiRequestCycle instances.
DouiServiceInterfaceTestCase Generic test case for Doui Service Interfaces.
 

Exception Summary
DouiServiceInterfaceTestException Base exception for LPTF Doui package.
 

Package lumis.lptf.doui.serviceinterface Description

This package contains the the test base class useful to perform tests on Doui service interfaces.

Doui Service Interface Tests

The client system has two options to use Lumis Portal Test Framework in order to perform Doui Service Interface tests:

Using DouiServiceInterfaceTestCase

In the first case, the client must have a subclass of DouiServiceInterfaceTestCase and implement the methods getServiceId and getServiceInterfaceId in order to provide the identifiers for the service and the service interface respectively.

In the test methods, the test class will have access to IDouiRenderRequestCycle and IDouiActionRequestCycle. Using these objects, it can get the mocks for request and response. IDouiRequestCycle specific classes also provide the common actions needed to perform service interface tests like render and processAction methods.

DouiServiceInterfaceTestCase starts a transaction and a session in setUp method. Also, it disposes the transaction and ends the session in tearDown. During the execution of the test methods the subclass must handle the other operations needed. It is common, for example, that before calling render or processAction methods in order to test them, it will be needed to commit the current transaction and starts another. The transaction instance is available to the subclass in order to allow these operations. The tearDown method also calls the cleanup method from the StructureHelper instance. So, all the structure created for the tests (like channels, pages and service interface instances) will be discarded.

Example:

        public class TestMyDouiInterface extends DouiServiceInterfaceTestCase
        {

                public String getServiceId()
                {
                        // return the service id
                }
                
                public String getServiceInterfaceId()
                {
                        // return the service interface id
                }

                public void testRender() throws Exception
                {
                        // performs specific actions for this test
                        // like creating data used by the interface implementation
                        ... 

                        // commit the current transaction if it was used above
                        this.transaction.commit();
                        this.transaction.dispose();
                        
                        // calls the render method:
                        this.douiRenderCycle.render();
                                
                        // if necessary for the assertions, the transaction could also be re-created as example below:
                        this.transaction = PortalTransactionFactory.createTransaction();
                        this.transaction.begin();

                        // asserts the response using 
                        // this.douiRenderCycle.getResponse() object
                }
        }
 

Using StructureHelper and DouiRequestCycleFactory

In the second solution, the client may use StructureHelper in create an instance of the needed service interface. It also may use DouiRequestCycleFactory to create the IDouiRenderRequestCycle or IDouiActionRequestCycle objects (and then use them, or get the request and response objects from them).

As in the first option, the test classes must handle the session and transaction instances. The StructureHelper uses the current session and current transaction for almost all its methods but cleanup that uses its own transaction and session.

The common implementation for these test cases, will instantiate a helper in the setUp and call the cleanup in tearDown.

Doui Request Cycles

In order to facilitate the Doui Service Interface tests, the cycles expose the steps for the major process executed by DouiServiceInterface. Using IDouiRenderRequestCycle and IDouiActionRequestCycle types, the client can execute render or processAction methods from DouiServiceInterface or it can execute step by step of each one.

The client can execute Doui request cycle (action or render) until one of the possible steps or the entire process.

Also, the DouiContext can be retrieved calling the method getDouiContext. This operation is valid only if the process was executed step by step. If the method render or processAction was used instead, the call to getDouiContext will throw an IllegalStateException.

The steps of each request cycle type are listed below:

IDouiRenderRequestCycle

IDouiActionRequestCycle

Since:
5.6.0


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.