public class StubInitialContextFactory extends Object implements InitialContextFactory
#bind(String, Object) to resp. register the initial context.
To start mocking the JNDI tree, call register().
To bind objects in the JNDI tree simply use the standard JNDI api:
InitialContext context = new InitialContext();
MyClass myObj = ...;
context.bind("a/b", myObj);
When finished with a test case, call unregister() to unregister the
JNDI tree again.| Constructor and Description |
|---|
StubInitialContextFactory() |
| Modifier and Type | Method and Description |
|---|---|
Context |
getInitialContext(Hashtable<?,?> aEnvironment) |
static void |
register()
This method must be called to register this initial context factory as
the default implementation for JNDI.
|
static void |
unregister()
Unregisters the initial context factory
|
public static void register()
Exceptionpublic static void unregister()
public Context getInitialContext(Hashtable<?,?> aEnvironment) throws NamingException
getInitialContext in interface InitialContextFactoryNamingExceptionCopyright © 2025. All rights reserved.