| |
|
| java.lang.Object org.mockejb.jndi.MockContextFactory
MockContextFactory | public class MockContextFactory implements InitialContextFactory(Code) | | Creates
MockContext . In case if delegate
environment was provided, obtains delegate InitialContext.
Delegate context is used by MockContext for unresolved lookups.
author: Alexander Ananiev author: Dimitar Gospodinov |
Method Summary | |
public Context | getInitialContext(Hashtable environment) Singleton for initial context.
Instantiates and returns root/initial MockContext object that
will be used as starting point for all naming operations.
MockContext is then used by javax.naming.InitialContext object.
It also creates the delegate context if the delegate environment is set. | public static void | revertSetAsInitial() Restores the properties changed by setAsInitial()
This method should be called in tearDown() to clean up
all changes to the environment in case if the test is running in the app
server. | public static void | setAsInitial() Sets the MockContextFactory as the initial context factory. | public static void | setDelegateContext(Context ctx) Sets the delegate context. | public static void | setDelegateEnvironment(Hashtable env) Sets the environment of the delegate JNDI context. |
revertSetAsInitial | public static void revertSetAsInitial()(Code) | | Restores the properties changed by setAsInitial()
This method should be called in tearDown() to clean up
all changes to the environment in case if the test is running in the app
server.
This method also cleans the initial context.
|
setAsInitial | public static void setAsInitial() throws NamingException(Code) | | Sets the MockContextFactory as the initial context factory.
This helper method sets the Context.INITIAL_CONTEXT_FACTORY
and Context.URL_PKG_PREFIXES system properties. The second one is needed to
be able to handle java:comp context correctly.
The method also saves the current values of these properties so they can be
restored later on using revertSetAsInitial .
This method is normally called from setUp
You can also set these properties directly:
java.naming.factory.initial=org.mockejb.jndi.MockContextFactory
java.naming.factory.url.pkgs=org.mockejb.jndi
throws: NamingException - |
setDelegateContext | public static void setDelegateContext(Context ctx)(Code) | | Sets the delegate context. Normally,
this is the initial context of the application server.
MockContext first tries to look up the object in its local tree.
If the object is not found, it will look in the delegate context.
Example:
MockContextFactory.setDelegateContext( new InitialContext() );
Parameters: ctx - delegate context |
setDelegateEnvironment | public static void setDelegateEnvironment(Hashtable env)(Code) | | Sets the environment of the delegate JNDI context. Normally,
this is the environment of the application server.
At the very minimum, the environment includes PROVIDER_URL and INITIAL_CONTEXT_FACTORY.
MockContext first tries to look up the object in its local tree.
If the object is not found, it will look in the delegate context.
Parameters: env - JNDI properties of the delegate environment |
|
|
|