| java.lang.Object com.mockrunner.ejb.EJBTestModule
EJBTestModule | public class EJBTestModule (Code) | | Module for EJB tests.
|
Method Summary | |
public void | bindToContext(String name, Object object) | public Object | createBean(String name) Create an EJB. | public Object | createBean(String name, Object[] parameters) Create an EJB. | public Object | createBean(String name, String createMethod, Object[] parameters) Create an EJB. | public Object | createBean(String name, String createMethod, Object[] parameters, Class[] parameterTypes) Create an EJB. | public Object | createEntityBean(String name, Object primaryKey) Create an entity EJB. | public Object | createEntityBean(String name, Object[] parameters, Object primaryKey) Create an entity EJB. | public Object | createEntityBean(String name, String createMethod, Object[] parameters, Object primaryKey) Create an entity EJB. | public Object | createEntityBean(String name, String createMethod, Object[] parameters, Class[] parameterTypes, Object primaryKey) Create an entity EJB. | public void | deploy(BasicEjbDescriptor descriptor) Deploys a bean to the mock container using the specified
descriptor. | public void | deploy(BasicEjbDescriptor descriptor, TransactionPolicy policy) Deploys a bean to the mock container using the specified
descriptor. | public void | deployEntityBean(String jndiName, Class beanClass) Deploys an entity bean to the mock container. | public void | deployEntityBean(String jndiName, Class beanClass, TransactionPolicy policy) Deploys an entity bean to the mock container. | public void | deployMessageBean(String connectionFactoryJndiName, String destinationJndiName, ConnectionFactory connectionFactory, Destination destination, Object bean) Deploys a message driven bean to the mock container.
You have to specify JNDI names for connection factory and
destination. | public void | deployMessageBean(String connectionFactoryJndiName, String destinationJndiName, ConnectionFactory connectionFactory, Destination destination, Object bean, TransactionPolicy policy) Deploys a message driven bean to the mock container.
You have to specify JNDI names for connection factory and
destination. | public void | deploySessionBean(String jndiName, Class beanClass) Deploys a stateless session bean to the mock container. | public void | deploySessionBean(String jndiName, Class beanClass, boolean stateful) Deploys a session bean to the mock container. | public void | deploySessionBean(String jndiName, Class beanClass, TransactionPolicy policy) Deploys a stateless session bean to the mock container. | public void | deploySessionBean(String jndiName, Class beanClass, boolean stateful, TransactionPolicy policy) Deploys a session bean to the mock container. | public void | deploySessionBean(String jndiName, Object bean) Deploys a stateless session bean to the mock container. | public void | deploySessionBean(String jndiName, Object bean, boolean stateful) Deploys a session bean to the mock container. | public void | deploySessionBean(String jndiName, Object bean, TransactionPolicy policy) Deploys a stateless session bean to the mock container. | public void | deploySessionBean(String jndiName, Object bean, boolean stateful, TransactionPolicy policy) Deploys a session bean to the mock container. | public Object | findByPrimaryKey(String name, Object primaryKey) Finds an entity EJB by its primary key. | public Object | lookup(String name) Lookup an object. | public Object | lookupBean(String name) | public Object | lookupBean(String name, Object[] parameters) | public Object | lookupBean(String name, String createMethod, Object[] parameters) | public void | resetUserTransaction() Resets the
com.mockrunner.mock.ejb.MockUserTransaction . | public void | setBusinessInterfacePackage(String businessInterfacePackage) Sets the package for the bean remote (local respectively) interface. | public void | setBusinessInterfaceSuffix(String businessInterfaceSuffix) Sets the suffix of the remote (local respectively) interface. | public void | setHomeInterfacePackage(String homeInterfacePackage) Sets the package for the bean home (local home respectively) interface. | public void | setHomeInterfaceSuffix(String homeInterfaceSuffix) Sets the suffix of the home (local home respectively) interface. | public void | setImplementationSuffix(String impSuffix) Sets the suffix of the bean implementation class. | public void | setInterfacePackage(String interfacePackage) Sets the package for the bean home and remote interfaces. | public void | verifyCommitted() Verifies that the transaction was committed. | public void | verifyMarkedForRollback() Verifies that the transaction was marked for rollback using
the method setRollbackOnly() . | public void | verifyNotCommitted() Verifies that the transaction was not committed. | public void | verifyNotMarkedForRollback() Verifies that the transaction was not marked for rollback. | public void | verifyNotRolledBack() Verifies that the transaction was not rolled back. | public void | verifyRolledBack() Verifies that the transaction was rolled back. |
bindToContext | public void bindToContext(String name, Object object)(Code) | | Adds an object to the mock context by calling rebind
Parameters: name - JNDI name of the object Parameters: object - the object to add |
createBean | public Object createBean(String name)(Code) | | Create an EJB. The method looks up the home interface, calls
the 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 postfix.
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 .
Parameters: name - JNDI name of the bean the bean throws: RuntimeException - in case of error |
createBean | public Object createBean(String name, Object[] parameters)(Code) | | Create an EJB. The method looks up the home interface, calls
the 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 postfix.
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.
Parameters: name - JNDI name of the bean Parameters: parameters - the parameters, null parameters are not allowed,primitive types are automatically unwrapped the bean throws: RuntimeException - in case of error |
createBean | public Object createBean(String name, String createMethod, Object[] parameters)(Code) | | Create an EJB. The method looks up the home interface, calls
the 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.
Parameters: name - JNDI name of the bean Parameters: createMethod - the name of the create method Parameters: parameters - the parameters, null parameters are not allowed,primitive types are automatically unwrapped the bean throws: RuntimeException - in case of error |
createBean | public Object createBean(String name, String createMethod, Object[] parameters, Class[] parameterTypes)(Code) | | Create an EJB. The method looks up the home interface, calls
the 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.
Parameters: name - JNDI name of the bean Parameters: createMethod - the name of the create method Parameters: parameters - the parameters, null is allowed as a parameter Parameters: parameterTypes - the type of the specified parameters the bean throws: RuntimeException - in case of error |
createEntityBean | public Object createEntityBean(String name, Object primaryKey)(Code) | | Create an entity EJB. The method looks up the home interface, calls
the 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 postfix.
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.
Parameters: name - JNDI name of the bean Parameters: primaryKey - the primary key the bean throws: RuntimeException - in case of error |
createEntityBean | public Object createEntityBean(String name, Object[] parameters, Object primaryKey)(Code) | | Create an entity EJB. The method looks up the home interface, calls
the 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 postfix.
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.
Parameters: name - JNDI name of the bean Parameters: parameters - the parameters, null parameters are not allowed,primitive types are automatically unwrapped Parameters: primaryKey - the primary key the bean throws: RuntimeException - in case of error |
createEntityBean | public Object createEntityBean(String name, String createMethod, Object[] parameters, Object primaryKey)(Code) | | Create an entity EJB. The method looks up the home interface, calls
the 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.
Parameters: name - JNDI name of the bean Parameters: createMethod - the name of the create method Parameters: parameters - the parameters, null parameters are not allowed,primitive types are automatically unwrapped Parameters: primaryKey - the primary key the bean throws: RuntimeException - in case of error |
createEntityBean | public Object createEntityBean(String name, String createMethod, Object[] parameters, Class[] parameterTypes, Object primaryKey)(Code) | | Create an entity EJB. The method looks up the home interface, calls
the 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.
Parameters: name - JNDI name of the bean Parameters: createMethod - the name of the create method Parameters: parameters - the parameters, null is allowed as a parameter Parameters: primaryKey - the primary key the bean throws: RuntimeException - in case of error |
deploy | public void deploy(BasicEjbDescriptor descriptor)(Code) | | Deploys a bean to the mock container using the specified
descriptor. Sets the transaction policy SUPPORTS.
Determines the type of bean (session, entity, message driven)
using the descriptor.
Parameters: descriptor - the descriptor |
deploy | public void deploy(BasicEjbDescriptor descriptor, TransactionPolicy policy)(Code) | | Deploys a bean to the mock container using the specified
descriptor. Determines the type of bean (session, entity, message driven)
using the descriptor.
The specified transaction policy will be automatically set. If the
specified transaction policy is 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.
Parameters: descriptor - the descriptor Parameters: policy - the transaction policy |
deployEntityBean | public void deployEntityBean(String jndiName, Class beanClass)(Code) | | Deploys an entity bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
Sets the transaction policy SUPPORTS.
Parameters: jndiName - the JNDI name Parameters: beanClass - the bean implementation class |
deployEntityBean | public void deployEntityBean(String jndiName, Class beanClass, TransactionPolicy policy)(Code) | | Deploys an entity bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
The specified transaction policy will be automatically set.
Parameters: jndiName - the JNDI name Parameters: beanClass - the bean implementation class Parameters: policy - the transaction policy |
deployMessageBean | public void deployMessageBean(String connectionFactoryJndiName, String destinationJndiName, ConnectionFactory connectionFactory, Destination destination, Object bean)(Code) | | Deploys a message driven bean to the mock container.
You have to specify JNDI names for connection factory and
destination. For creating connection factory and destination
objects you can use
com.mockrunner.mock.jms.JMSMockObjectFactory and
com.mockrunner.jms.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.
Parameters: connectionFactoryJndiName - the JNDI name of the connection factory Parameters: destinationJndiName - the JNDI name of the destination Parameters: connectionFactory - the connection factory Parameters: destination - the destination Parameters: bean - the message driven bean instance |
deployMessageBean | public void deployMessageBean(String connectionFactoryJndiName, String destinationJndiName, ConnectionFactory connectionFactory, Destination destination, Object bean, TransactionPolicy policy)(Code) | | Deploys a message driven bean to the mock container.
You have to specify JNDI names for connection factory and
destination. For creating connection factory and destination
objects you can use
com.mockrunner.mock.jms.JMSMockObjectFactory and
com.mockrunner.jms.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.
Parameters: connectionFactoryJndiName - the JNDI name of the connection factory Parameters: destinationJndiName - the JNDI name of the destination Parameters: connectionFactory - the connection factory Parameters: destination - the destination Parameters: bean - the message driven bean instance Parameters: policy - the transaction policy |
deploySessionBean | public void deploySessionBean(String jndiName, Class beanClass)(Code) | | Deploys a stateless session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
Sets the transaction policy SUPPORTS.
Parameters: jndiName - the JNDI name Parameters: beanClass - the bean implementation class |
deploySessionBean | public void deploySessionBean(String jndiName, Class beanClass, boolean stateful)(Code) | | Deploys a session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
Sets the transaction policy SUPPORTS.
Parameters: jndiName - the JNDI name Parameters: beanClass - the bean implementation class Parameters: stateful - is the bean stateful |
deploySessionBean | public void deploySessionBean(String jndiName, Class beanClass, TransactionPolicy policy)(Code) | | Deploys a stateless session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
The specified transaction policy will be automatically set.
Parameters: jndiName - the JNDI name Parameters: beanClass - the bean implementation class Parameters: policy - the transaction policy |
deploySessionBean | public void deploySessionBean(String jndiName, Class beanClass, boolean stateful, TransactionPolicy policy)(Code) | | Deploys a session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
The specified transaction policy will be automatically set.
Parameters: jndiName - the JNDI name Parameters: beanClass - the bean implementation class Parameters: stateful - is the bean stateful Parameters: policy - the transaction policy |
deploySessionBean | public void deploySessionBean(String jndiName, Object bean)(Code) | | Deploys a stateless session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
Sets the transaction policy SUPPORTS.
Parameters: jndiName - the JNDI name Parameters: bean - the bean implementation |
deploySessionBean | public void deploySessionBean(String jndiName, Object bean, boolean stateful)(Code) | | Deploys a session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
Sets the transaction policy SUPPORTS.
Parameters: jndiName - the JNDI name Parameters: bean - the bean implementation Parameters: stateful - is the bean stateful |
deploySessionBean | public void deploySessionBean(String jndiName, Object bean, TransactionPolicy policy)(Code) | | Deploys a stateless session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
The specified transaction policy will be automatically set.
Parameters: jndiName - the JNDI name Parameters: bean - the bean implementation Parameters: policy - the transaction policy |
deploySessionBean | public void deploySessionBean(String jndiName, Object bean, boolean stateful, TransactionPolicy policy)(Code) | | Deploys a session bean to the mock container. You have to specify
the implementation class and the JNDI name. The frameworks
determines the home and remote interfaces based on the
information specified with the setSuffix
and setPackage methods.
The specified transaction policy will be automatically set.
Parameters: jndiName - the JNDI name Parameters: bean - the bean implementation Parameters: stateful - is the bean stateful Parameters: policy - the transaction policy |
findByPrimaryKey | public Object findByPrimaryKey(String name, Object primaryKey)(Code) | | Finds an entity EJB by its primary key. The method looks up the home interface,
calls the 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 .
Parameters: name - JNDI name of the bean Parameters: primaryKey - the primary key the bean throws: RuntimeException - in case of error |
lookup | public Object lookup(String name)(Code) | | Lookup an object. If the object is not bound to the InitialContext ,
a RuntimeException will be thrown.
Parameters: name - JNDI name of the object the object throws: RuntimeException - if an object with the specified name cannot be found. |
setBusinessInterfacePackage | public void setBusinessInterfacePackage(String businessInterfacePackage)(Code) | | Sets the package for the bean remote (local respectively) interface. Per
default, the framework expects that the interfaces are in the
same package as the bean implementation classes.
Parameters: businessInterfacePackage - the package name for remote interface |
setBusinessInterfaceSuffix | public void setBusinessInterfaceSuffix(String businessInterfaceSuffix)(Code) | | Sets the suffix of the remote (local respectively) interface. The
default is an empty string, i.e. if the implementation class is
TestBean , the remote interface is Test
Parameters: businessInterfaceSuffix - the bean remote interface suffix |
setHomeInterfacePackage | public void setHomeInterfacePackage(String homeInterfacePackage)(Code) | | Sets the package for the bean home (local home respectively) interface. Per
default, the framework expects that the interfaces are in the
same package as the bean implementation classes.
Parameters: homeInterfacePackage - the package name for home interface |
setHomeInterfaceSuffix | public void setHomeInterfaceSuffix(String homeInterfaceSuffix)(Code) | | Sets the suffix of the home (local home respectively) interface. The
default is "Home", i.e. if the implementation class is
TestBean , the home interface is TestHome
Parameters: homeInterfaceSuffix - the bean home interface suffix |
setImplementationSuffix | public void setImplementationSuffix(String impSuffix)(Code) | | Sets the suffix of the bean implementation class. The
default is "Bean", i.e. if the remote interface has
the name Test the implementation class is
TestBean .
Parameters: impSuffix - the bean implementation suffix |
setInterfacePackage | public void setInterfacePackage(String interfacePackage)(Code) | | Sets the package for the bean home and remote interfaces. Per
default, the framework expects that the interfaces are in the
same package as the bean implementation classes.
Parameters: interfacePackage - the package name for home and remote interfaces |
verifyCommitted | public void verifyCommitted()(Code) | | Verifies that the transaction was committed. If you are using
container managed transactions, you have to set an appropriate
transaction policy, e.g. REQUIRED. Otherwise the container
will not commit the mock transaction.
Note: If you do not use the
com.mockrunner.mock.ejb.MockUserTransaction implementation, this method throws a VerifyFailedException .
throws: VerifyFailedException - if verification fails |
verifyNotCommitted | public void verifyNotCommitted()(Code) | | Verifies that the transaction was not committed. If you are using
container managed transactions, you have to set an appropriate
transaction policy, e.g. REQUIRED.
Note: If you do not use the
com.mockrunner.mock.ejb.MockUserTransaction implementation, this method throws a VerifyFailedException .
throws: VerifyFailedException - if verification fails |
verifyNotRolledBack | public void verifyNotRolledBack()(Code) | | Verifies that the transaction was not rolled back. If you are using
container managed transactions, you have to set an appropriate
transaction policy, e.g. REQUIRED.
Note: If you do not use the
com.mockrunner.mock.ejb.MockUserTransaction implementation, this method throws a VerifyFailedException .
throws: VerifyFailedException - if verification fails |
verifyRolledBack | public void verifyRolledBack()(Code) | | Verifies that the transaction was rolled back. If you are using
container managed transactions, you have to set an appropriate
transaction policy, e.g. REQUIRED. Otherwise the container
will not rollback the mock transaction.
Note: If you do not use the
com.mockrunner.mock.ejb.MockUserTransaction implementation, this method throws a VerifyFailedException .
throws: VerifyFailedException - if verification fails |
|
|