Package lumis.lptf.portal.serviceinterface
Service Interface Tests
The client system has two options to use LumisXP Test Framework in order to perform Service Interface tests:
- Test cases as subclasses of
ServiceInterfaceTestCase
- Using
StructureHelper
(to create the necessary portal structure, and in it the service interface instance to be called) andRequestCycleFactory
(to instantiate the needed RequestCycle implementation, used for calling the interface's render, processAction methods; or for providing request and response objects)
Using ServiceInterfaceTestCase
In the first case, the client must have a subclass of
ServiceInterfaceTestCase
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 IRenderRequestCycle and IActionRequestCycle. Using these objects, it can get the mocks for request and response. IRequestCycle specific classes also provide the common actions needed to perform service interface tests like render and processAction methods.
ServiceInterfaceTestCase
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 TestMyInterface extends ServiceInterfaceTestCase
{
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.close();
// calls the render method:
this.renderRequestCycle.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.renderRequestCycle.getResponse() object
}
}
Using StructureHelper
and RequestCycleFactory
In the second solution, the client may use
StructureHelper
in create an
instance of the needed service interface.
It also may use
RequestCycleFactory
to create the IRenderRequestCycle
or IActionRequestCycle
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
.
- Since:
- 5.6.0
- Version:
- $Revision$ $Date$
-
Interface Summary Interface Description IActionRequestCycle Interface for action request cycle.IMockServiceInterfaceActionRequest Interface for aIServiceInterfaceActionRequest
mock object.IMockServiceInterfaceActionResponse Interface for aIServiceInterfaceActionResponse
mock object.IMockServiceInterfaceRenderRequest Interface for aIServiceInterfaceRenderRequest
mock object.IMockServiceInterfaceRenderResponse Interface for aIServiceInterfaceRenderResponse
mock object.IMockServiceInterfaceRequest Interface for aIServiceInterfaceRequest
mock object.IMockServiceInterfaceResponse Interface for aIServiceInterfaceResponse
mock object.IRenderRequestCycle Interface for the render request cycle. -
Class Summary Class Description ActionRequestCycle Represents the action request cycle - containing mocks for request and response and process actions.MockServiceInterfaceActionRequest Implementation for IMockServiceInterfaceActionRequest interface.MockServiceInterfaceActionResponse Implementation for IMockServiceInterfaceActionResponse interface.MockServiceInterfaceRenderRequest Implementation for IMockServiceInterfaceRenderRequest interface.MockServiceInterfaceRenderResponse Implementation for IMockServiceInterfaceRenderResponse interface.RenderRequestCycle Represents the render request cycle - containing mocks for request and response and performing render operations.RequestCycle Represents the request cycle.RequestCycleFactory Creates and initializes RequestCycle instances.ServiceInterfaceTestCase Generic test case for Service Interfaces.