|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mockrunner.ejb.EJBTestModule
public class EJBTestModule
Module for EJB tests.
Constructor Summary | |
---|---|
EJBTestModule(EJBMockObjectFactory mockFactory)
|
Method Summary | |
---|---|
void |
bindToContext(java.lang.String name,
java.lang.Object object)
Adds an object to the mock context by calling rebind |
java.lang.Object |
createBean(java.lang.String name)
Create an EJB. |
java.lang.Object |
createBean(java.lang.String name,
java.lang.Object[] parameters)
Create an EJB. |
java.lang.Object |
createBean(java.lang.String name,
java.lang.String createMethod,
java.lang.Object[] parameters)
Create an EJB. |
java.lang.Object |
createBean(java.lang.String name,
java.lang.String createMethod,
java.lang.Object[] parameters,
java.lang.Class[] parameterTypes)
Create an EJB. |
java.lang.Object |
createEntityBean(java.lang.String name,
java.lang.Object primaryKey)
Create an entity EJB. |
java.lang.Object |
createEntityBean(java.lang.String name,
java.lang.Object[] parameters,
java.lang.Object primaryKey)
Create an entity EJB. |
java.lang.Object |
createEntityBean(java.lang.String name,
java.lang.String createMethod,
java.lang.Object[] parameters,
java.lang.Class[] parameterTypes,
java.lang.Object primaryKey)
Create an entity EJB. |
java.lang.Object |
createEntityBean(java.lang.String name,
java.lang.String createMethod,
java.lang.Object[] parameters,
java.lang.Object primaryKey)
Create an entity EJB. |
void |
deploy(org.mockejb.BasicEjbDescriptor descriptor)
Deploys a bean to the mock container using the specified descriptor. |
void |
deploy(org.mockejb.BasicEjbDescriptor descriptor,
org.mockejb.TransactionPolicy policy)
Deploys a bean to the mock container using the specified descriptor. |
void |
deployEntityBean(java.lang.String jndiName,
java.lang.Class beanClass)
Deploys an entity bean to the mock container. |
void |
deployEntityBean(java.lang.String jndiName,
java.lang.Class beanClass,
org.mockejb.TransactionPolicy policy)
Deploys an entity bean to the mock container. |
void |
deployMessageBean(java.lang.String connectionFactoryJndiName,
java.lang.String destinationJndiName,
javax.jms.ConnectionFactory connectionFactory,
javax.jms.Destination destination,
java.lang.Object bean)
Deploys a message driven bean to the mock container. |
void |
deployMessageBean(java.lang.String connectionFactoryJndiName,
java.lang.String destinationJndiName,
javax.jms.ConnectionFactory connectionFactory,
javax.jms.Destination destination,
java.lang.Object bean,
org.mockejb.TransactionPolicy policy)
Deploys a message driven bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Class beanClass)
Deploys a stateless session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Class beanClass,
boolean stateful)
Deploys a session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Class beanClass,
boolean stateful,
org.mockejb.TransactionPolicy policy)
Deploys a session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Class beanClass,
org.mockejb.TransactionPolicy policy)
Deploys a stateless session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Object bean)
Deploys a stateless session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Object bean,
boolean stateful)
Deploys a session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Object bean,
boolean stateful,
org.mockejb.TransactionPolicy policy)
Deploys a session bean to the mock container. |
void |
deploySessionBean(java.lang.String jndiName,
java.lang.Object bean,
org.mockejb.TransactionPolicy policy)
Deploys a stateless session bean to the mock container. |
java.lang.Object |
findByPrimaryKey(java.lang.String name,
java.lang.Object primaryKey)
Finds an entity EJB by its primary key. |
java.lang.Object |
lookup(java.lang.String name)
Lookup an object. |
java.lang.Object |
lookupBean(java.lang.String name)
Deprecated. use createBean(String) |
java.lang.Object |
lookupBean(java.lang.String name,
java.lang.Object[] parameters)
Deprecated. use createBean(String, Object[]) |
java.lang.Object |
lookupBean(java.lang.String name,
java.lang.String createMethod,
java.lang.Object[] parameters)
Deprecated. use createBean(String, String, Object[]) |
void |
resetUserTransaction()
Resets the MockUserTransaction . |
void |
setBusinessInterfacePackage(java.lang.String businessInterfacePackage)
Sets the package for the bean remote (local respectively) interface. |
void |
setBusinessInterfaceSuffix(java.lang.String businessInterfaceSuffix)
Sets the suffix of the remote (local respectively) interface. |
void |
setHomeInterfacePackage(java.lang.String homeInterfacePackage)
Sets the package for the bean home (local home respectively) interface. |
void |
setHomeInterfaceSuffix(java.lang.String homeInterfaceSuffix)
Sets the suffix of the home (local home respectively) interface. |
void |
setImplementationSuffix(java.lang.String impSuffix)
Sets the suffix of the bean implementation class. |
void |
setInterfacePackage(java.lang.String interfacePackage)
Sets the package for the bean home and remote interfaces. |
void |
verifyCommitted()
Verifies that the transaction was committed. |
void |
verifyMarkedForRollback()
Verifies that the transaction was marked for rollback using the method setRollbackOnly() . |
void |
verifyNotCommitted()
Verifies that the transaction was not committed. |
void |
verifyNotMarkedForRollback()
Verifies that the transaction was not marked for rollback. |
void |
verifyNotRolledBack()
Verifies that the transaction was not rolled back. |
void |
verifyRolledBack()
Verifies that the transaction was rolled back. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EJBTestModule(EJBMockObjectFactory mockFactory)
Method Detail |
---|
public void setImplementationSuffix(java.lang.String impSuffix)
Test
the implementation class is
TestBean
.
impSuffix
- the bean implementation suffixpublic void setBusinessInterfaceSuffix(java.lang.String businessInterfaceSuffix)
TestBean
, the remote interface is Test
businessInterfaceSuffix
- the bean remote interface suffixpublic void setHomeInterfaceSuffix(java.lang.String homeInterfaceSuffix)
TestBean
, the home interface is TestHome
homeInterfaceSuffix
- the bean home interface suffixpublic void setInterfacePackage(java.lang.String interfacePackage)
interfacePackage
- the package name for home and remote interfacespublic void setHomeInterfacePackage(java.lang.String homeInterfacePackage)
homeInterfacePackage
- the package name for home interfacepublic void setBusinessInterfacePackage(java.lang.String businessInterfacePackage)
businessInterfacePackage
- the package name for remote interfacepublic void deploy(org.mockejb.BasicEjbDescriptor descriptor)
descriptor
- the descriptorpublic void deploy(org.mockejb.BasicEjbDescriptor descriptor, org.mockejb.TransactionPolicy policy)
null
, no transaction policy
will be set. This makes sense for BMT EJBs. Please note that the
deploy
methods of this class without a transaction policy
argument automatically set the SUPPORTS policy, which also
works fine for BMT EJBs.
descriptor
- the descriptorpolicy
- the transaction policypublic void deploySessionBean(java.lang.String jndiName, java.lang.Class beanClass)
setSuffix
and setPackage
methods.
Sets the transaction policy SUPPORTS.
jndiName
- the JNDI namebeanClass
- the bean implementation classpublic void deploySessionBean(java.lang.String jndiName, java.lang.Class beanClass, boolean stateful)
setSuffix
and setPackage
methods.
Sets the transaction policy SUPPORTS.
jndiName
- the JNDI namebeanClass
- the bean implementation classstateful
- is the bean statefulpublic void deploySessionBean(java.lang.String jndiName, java.lang.Class beanClass, org.mockejb.TransactionPolicy policy)
setSuffix
and setPackage
methods.
The specified transaction policy will be automatically set.
jndiName
- the JNDI namebeanClass
- the bean implementation classpolicy
- the transaction policypublic void deploySessionBean(java.lang.String jndiName, java.lang.Class beanClass, boolean stateful, org.mockejb.TransactionPolicy policy)
setSuffix
and setPackage
methods.
The specified transaction policy will be automatically set.
jndiName
- the JNDI namebeanClass
- the bean implementation classstateful
- is the bean statefulpolicy
- the transaction policypublic void deploySessionBean(java.lang.String jndiName, java.lang.Object bean)
setSuffix
and setPackage
methods.
Sets the transaction policy SUPPORTS.
jndiName
- the JNDI namebean
- the bean implementationpublic void deploySessionBean(java.lang.String jndiName, java.lang.Object bean, boolean stateful)
setSuffix
and setPackage
methods.
Sets the transaction policy SUPPORTS.
jndiName
- the JNDI namebean
- the bean implementationstateful
- is the bean statefulpublic void deploySessionBean(java.lang.String jndiName, java.lang.Object bean, org.mockejb.TransactionPolicy policy)
setSuffix
and setPackage
methods.
The specified transaction policy will be automatically set.
jndiName
- the JNDI namebean
- the bean implementationpolicy
- the transaction policypublic void deploySessionBean(java.lang.String jndiName, java.lang.Object bean, boolean stateful, org.mockejb.TransactionPolicy policy)
setSuffix
and setPackage
methods.
The specified transaction policy will be automatically set.
jndiName
- the JNDI namebean
- the bean implementationstateful
- is the bean statefulpolicy
- the transaction policypublic void deployEntityBean(java.lang.String jndiName, java.lang.Class beanClass)
setSuffix
and setPackage
methods.
Sets the transaction policy SUPPORTS.
jndiName
- the JNDI namebeanClass
- the bean implementation classpublic void deployEntityBean(java.lang.String jndiName, java.lang.Class beanClass, org.mockejb.TransactionPolicy policy)
setSuffix
and setPackage
methods.
The specified transaction policy will be automatically set.
jndiName
- the JNDI namebeanClass
- the bean implementation classpolicy
- the transaction policypublic void deployMessageBean(java.lang.String connectionFactoryJndiName, java.lang.String destinationJndiName, javax.jms.ConnectionFactory connectionFactory, javax.jms.Destination destination, java.lang.Object bean)
JMSMockObjectFactory
and DestinationManager
.
The specified objects are automatically bound to JNDI using
the specified names. The mock container automatically creates
a connection and session.
Sets the transaction policy NOT_SUPPORTED.
connectionFactoryJndiName
- the JNDI name of the connection factorydestinationJndiName
- the JNDI name of the destinationconnectionFactory
- the connection factorydestination
- the destinationbean
- the message driven bean instancepublic void deployMessageBean(java.lang.String connectionFactoryJndiName, java.lang.String destinationJndiName, javax.jms.ConnectionFactory connectionFactory, javax.jms.Destination destination, java.lang.Object bean, org.mockejb.TransactionPolicy policy)
JMSMockObjectFactory
and DestinationManager
.
The specified objects are automatically bound to JNDI using
the specified names. The mock container automatically creates
a connection and session.
The specified transaction policy will be automatically set.
connectionFactoryJndiName
- the JNDI name of the connection factorydestinationJndiName
- the JNDI name of the destinationconnectionFactory
- the connection factorydestination
- the destinationbean
- the message driven bean instancepolicy
- the transaction policypublic void bindToContext(java.lang.String name, java.lang.Object object)
rebind
name
- JNDI name of the objectobject
- the object to addpublic java.lang.Object lookup(java.lang.String name)
InitialContext
,
a RuntimeException
will be thrown.
name
- JNDI name of the object
java.lang.RuntimeException
- if an object with the specified name cannot be found.public java.lang.Object lookupBean(java.lang.String name)
createBean(String)
public java.lang.Object createBean(java.lang.String name)
create
method and returns the result, which
you can cast to the remote interface. This method only works
with create
methods that have an empty parameter list.
The create
method must have the name create
with no suffix.
It works with the mock container but may fail with a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
name
- JNDI name of the bean
java.lang.RuntimeException
- in case of errorpublic java.lang.Object lookupBean(java.lang.String name, java.lang.Object[] parameters)
createBean(String, Object[])
public java.lang.Object createBean(java.lang.String name, java.lang.Object[] parameters)
create
method with the specified parameters
and returns the result, which you can cast to the remote interface.
The create
method must have the name create
with no suffix.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
This method does not allow null
as a parameter, because
the type of the parameter cannot be determined in this case.
name
- JNDI name of the beanparameters
- the parameters, null
parameters are not allowed,
primitive types are automatically unwrapped
java.lang.RuntimeException
- in case of errorpublic java.lang.Object lookupBean(java.lang.String name, java.lang.String createMethod, java.lang.Object[] parameters)
createBean(String, String, Object[])
public java.lang.Object createBean(java.lang.String name, java.lang.String createMethod, java.lang.Object[] parameters)
create
method with the specified parameters
and returns the result, which you can cast to the remote interface.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
This method does not allow null
as a parameter, because
the type of the parameter cannot be determined in this case.
name
- JNDI name of the beancreateMethod
- the name of the create methodparameters
- the parameters, null
parameters are not allowed,
primitive types are automatically unwrapped
java.lang.RuntimeException
- in case of errorpublic java.lang.Object createBean(java.lang.String name, java.lang.String createMethod, java.lang.Object[] parameters, java.lang.Class[] parameterTypes)
create
method with the specified parameters
and returns the result, which you can cast to the remote interface.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
This method does allow null
as a parameter.
name
- JNDI name of the beancreateMethod
- the name of the create methodparameters
- the parameters, null
is allowed as a parameterparameterTypes
- the type of the specified parameters
java.lang.RuntimeException
- in case of errorpublic java.lang.Object createEntityBean(java.lang.String name, java.lang.Object primaryKey)
create
method and returns the result, which
you can cast to the remote interface. This method only works
with create
methods that have an empty parameter list.
The create
method must have the name create
with no suffix.
It works with the mock container but may fail with a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
The created entity EJB is added to the mock database automatically
using the provided primary key.
name
- JNDI name of the beanprimaryKey
- the primary key
java.lang.RuntimeException
- in case of errorpublic java.lang.Object createEntityBean(java.lang.String name, java.lang.Object[] parameters, java.lang.Object primaryKey)
create
method with the specified parameters
and returns the result, which you can cast to the remote interface.
The create
method must have the name create
with no suffix.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
The created entity EJB is added to the mock database automatically
using the provided primary key.
This method does not allow null
as a parameter, because
the type of the parameter cannot be determined in this case.
name
- JNDI name of the beanparameters
- the parameters, null
parameters are not allowed,
primitive types are automatically unwrappedprimaryKey
- the primary key
java.lang.RuntimeException
- in case of errorpublic java.lang.Object createEntityBean(java.lang.String name, java.lang.String createMethod, java.lang.Object[] parameters, java.lang.Object primaryKey)
create
method with the specified parameters
and returns the result, which you can cast to the remote interface.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
The created entity EJB is added to the mock database automatically
using the provided primary key.
This method does not allow null
as a parameter, because
the type of the parameter cannot be determined in this case.
name
- JNDI name of the beancreateMethod
- the name of the create methodparameters
- the parameters, null
parameters are not allowed,
primitive types are automatically unwrappedprimaryKey
- the primary key
java.lang.RuntimeException
- in case of errorpublic java.lang.Object createEntityBean(java.lang.String name, java.lang.String createMethod, java.lang.Object[] parameters, java.lang.Class[] parameterTypes, java.lang.Object primaryKey)
create
method with the specified parameters
and returns the result, which you can cast to the remote interface.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the corresponding create
method cannot be found, this
method returns null
.
The created entity EJB is added to the mock database automatically
using the provided primary key.
This method does allow null
as a parameter.
name
- JNDI name of the beancreateMethod
- the name of the create methodparameters
- the parameters, null
is allowed as a parameterprimaryKey
- the primary key
java.lang.RuntimeException
- in case of errorpublic java.lang.Object findByPrimaryKey(java.lang.String name, java.lang.Object primaryKey)
findByPrimaryKey
method and returns the result,
which you can cast to the remote interface.
This method works with the mock container but may fail with
a real remote container.
This method throws a RuntimeException
if no object with the
specified name can be found. If the found object is no EJB home interface,
or if the findByPrimaryKey
method cannot be found, this
method returns null
.
If the mock container throws an exception because the primary key
cannot be found in the entity database, this method returns null
.
name
- JNDI name of the beanprimaryKey
- the primary key
java.lang.RuntimeException
- in case of errorpublic void resetUserTransaction()
MockUserTransaction
.
Note: If you do not use the MockUserTransaction
implementation, this method does nothing.
public void verifyCommitted()
MockUserTransaction
implementation, this method throws a VerifyFailedException
.
VerifyFailedException
- if verification failspublic void verifyNotCommitted()
MockUserTransaction
implementation, this method throws a VerifyFailedException
.
VerifyFailedException
- if verification failspublic void verifyRolledBack()
MockUserTransaction
implementation, this method throws a VerifyFailedException
.
VerifyFailedException
- if verification failspublic void verifyNotRolledBack()
MockUserTransaction
implementation, this method throws a VerifyFailedException
.
VerifyFailedException
- if verification failspublic void verifyMarkedForRollback()
setRollbackOnly()
.
Note: If you do not use the MockUserTransaction
implementation, this method throws a VerifyFailedException
.
VerifyFailedException
- if verification failspublic void verifyNotMarkedForRollback()
MockUserTransaction
implementation, this method throws a VerifyFailedException
.
VerifyFailedException
- if verification fails
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |