| org.mockejb.OptionalCactusTestCase org.mockejb.test.FundamentalsTest
FundamentalsTest | public class FundamentalsTest extends OptionalCactusTestCase implements Interceptor(Code) | | Main MockEjb test case. Demonstrates the basic scenarios of MockEjb usage.
This test runs in two modes. When Cactus mode is turned on (using
"mockejb.cactus.mode" system property), it will run as the Cactus test (on the server).
In this case, the test class will use EJBs deployed by the app server.
Otherwise it will run outside of the app server under MockContainer.
Cactus mode is supported by OptionalCactusTestCase superclass.
author: Alexander Ananiev |
Inner Class :public static class ExternalServiceMockBean | |
Method Summary | |
public void | intercept(InvocationContext invocationContext) Implementation of the Interceptor interface that can be used
for testing various preconditions/postconditions of the EJB call. | public void | setUp() Deploys and creates EJBs needed for our tests. | public void | tearDown() Performs the necessary cleanup by restoring the system properties that
were modified by MockContextFactory.setAsInitial().
This is needed in case if the test runs inside the container, so it would
not affect the tests that run after it. | public void | testCustomInterceptor() Demonstrates the use of custom interceptors. | public void | testExceptionHandling() Test MockEJB exception handling. | public void | testHome() Tests standard Home and EJBMetaData methods. | public void | testInvocationRecorder() InvocationRecorder interceptor provides an easy way to inspect the
data about the calls.
If it added to the interceptor list, it will record the information about
all calls to the bean.
We'll use it to check that SampleBean called HelperBean and passed non-null
parameter.
We can only run this test if it is being executed outside of the
container. | public void | testSecurity() This method demonstrates how to test beans that makes the use of
use of the security-related methods of EJBContext (getCallerPrincipal, isCallerInRole). | public void | testSimpleCalls() |
intercept | public void intercept(InvocationContext invocationContext) throws Exception(Code) | | Implementation of the Interceptor interface that can be used
for testing various preconditions/postconditions of the EJB call.
Here we use it for very simple check to make sure that non-null parameter
is passed to the HelperBean.
|
setUp | public void setUp() throws Exception(Code) | | Deploys and creates EJBs needed for our tests.
Note that JUnit runs this method for every test method, but since
MockEjb deployment is purely an in-memory operation,
it does not have any performance penalty.
During deployment, MockEjb simply re-binds EJBs to the same keys in the JNDI tree.
|
tearDown | public void tearDown()(Code) | | Performs the necessary cleanup by restoring the system properties that
were modified by MockContextFactory.setAsInitial().
This is needed in case if the test runs inside the container, so it would
not affect the tests that run after it.
|
testCustomInterceptor | public void testCustomInterceptor() throws Exception(Code) | | Demonstrates the use of custom interceptors.
This test class implements Interceptor interface. It will verify
that not-null parameter is passed to HelperBean.
The same thing can be done using InvocationRecorder
(see testInvocationRecorder).
We can only run this test if it is being executed outside of the
container.
|
testExceptionHandling | public void testExceptionHandling() throws Exception(Code) | | Test MockEJB exception handling.
According to the EJB spec, system exception must be wrapped in
RemoteException.
The exception from the local interface must be wrapped in EJBException.
MockEjb treats all runtime and transaction-related exceptions as system exceptions.
|
testHome | public void testHome() throws Exception(Code) | | Tests standard Home and EJBMetaData methods.
|
testInvocationRecorder | public void testInvocationRecorder() throws Exception(Code) | | InvocationRecorder interceptor provides an easy way to inspect the
data about the calls.
If it added to the interceptor list, it will record the information about
all calls to the bean.
We'll use it to check that SampleBean called HelperBean and passed non-null
parameter.
We can only run this test if it is being executed outside of the
container.
|
testSecurity | public void testSecurity() throws Exception(Code) | | This method demonstrates how to test beans that makes the use of
use of the security-related methods of EJBContext (getCallerPrincipal, isCallerInRole).
|
testSimpleCalls | public void testSimpleCalls() throws Exception(Code) | | Tests simple EJB invocations
|
|
|