You can unit test outbound and inbound processing by creating and specifying JCA contracts and operations. You then test and compare data before and after applying the tests. The EIS Simulator Adapter code sample illustrates these steps.
The Java EE Connector Architecture (JCA) specification defines an unmanaged mode for running adapters. This means running the adapter outside of a JCA container and in process with the caller. This is the environment for developing JUnit tests.
Through a series of common client interface (CCI) and service provider interface (SPI) calls, you can force the adapter to perform an operation you want to test. First you must create instances of ManagedConnectionFactory and ResourceAdapter then set the appropriate properties in the client code.
Your adapter cannot be dependent on "live" data inside the EIS. If so, you must either return the data to a known state after every test, or create a mock implementation of the EIS API so that EIS data remains untouched.
setUp()
In the setup method for outbound, perform the following step:
Test
When you have completed the steps for setting up the test, you are ready to call the CCI interaction and validate the result. The following procedure creates an object, retrieves it, and validates its content.
In contrast to the outbound direction, inbound communication is not defined for unmanaged operation. To test the inbound capability of the adapter outside of a JCA container, you must implement some of the JCA container contracts. The following includes:
For more details on these contracts, study the EIS Simulator Adapter samples that are shipped with WebSphere® Adapter Toolkit.
setUp()
The setUp() method for inbound is like that for outbound. You can, however, not need an outbound connection through the adapter. Accordingly, you only need to perform the following tasks:
Test
The test methods for inbound must do the following:
For more details on the procedures described in this topic, study the EIS Simulator Adapter samples that are shipped with WebSphere Adapter Toolkit.