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()
Exception
public static void unregister()
public Context getInitialContext(Hashtable<?,?> aEnvironment) throws NamingException
getInitialContext
in interface InitialContextFactory
NamingException
Copyright © 2022. All rights reserved.