public class EJBMockObjectFactory extends Object
UserTransaction from the JNDI context.
If there's no transaction bound to the context, the factory will create a
MockUserTransaction and bind it to the context.
If the bound transaction is no
MockUserTransaction,
the method getMockUserTransaction() returns null.
Use getUserTransaction() instead in this case.
You can configure the JNDI name of the UserTransaction and
the JNDI Context with the class
Configuration.| Constructor and Description |
|---|
EJBMockObjectFactory()
Creates a new set of mock objects.
|
EJBMockObjectFactory(Configuration configuration)
Creates a new set of mock objects based on the specified configuration.
|
| Modifier and Type | Method and Description |
|---|---|
MockUserTransaction |
createMockUserTransaction()
Creates the
MockUserTransaction using new. |
Context |
getContext()
Returns the JNDI context that is used by this factory.
|
org.mockejb.MockContainer |
getMockContainer()
Returns the MockEJB
MockContainer. |
MockUserTransaction |
getMockUserTransaction()
Returns the
MockUserTransaction. |
UserTransaction |
getUserTransaction()
Returns the
UserTransaction. |
void |
initMockContextFactory()
Calls
MockContextFactory.setAsInitial(), if
MockContextFactory is not already the current
context factory. |
void |
resetMockContextFactory()
Calls
MockContextFactory.revertSetAsInitial(), if
MockContextFactory is the current context factory. |
public EJBMockObjectFactory()
public EJBMockObjectFactory(Configuration configuration)
public MockUserTransaction createMockUserTransaction()
MockUserTransaction using new.
This method can be overridden to return a subclass of MockUserTransaction.MockUserTransactionpublic void initMockContextFactory()
throws NamingException
MockContextFactory.setAsInitial(), if
MockContextFactory is not already the current
context factory.NamingExceptionpublic void resetMockContextFactory()
MockContextFactory.revertSetAsInitial(), if
MockContextFactory is the current context factory.public MockUserTransaction getMockUserTransaction()
MockUserTransaction.
If the bound transaction is no MockUserTransaction,
this method returns null.MockUserTransactionpublic UserTransaction getUserTransaction()
UserTransaction.UserTransactionpublic org.mockejb.MockContainer getMockContainer()
MockContainer.MockContainerpublic Context getContext()
Context using Configuration.setContext(javax.naming.Context)},
the JNDI implementation of MockEJB is used.Copyright © 2003–2018. All rights reserved.