public class ExpectedLookupTemplate extends JndiTemplate
Very useful for testing. Effectively a mock object.
logger| Constructor and Description |
|---|
ExpectedLookupTemplate()
Construct a new JndiTemplate that will always return given objects for
given names.
|
ExpectedLookupTemplate(java.lang.String name,
java.lang.Object object)
Construct a new JndiTemplate that will always return the given object,
but honour only requests for the given name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObject(java.lang.String name,
java.lang.Object object)
Add the given object to the list of JNDI objects that this template will expose.
|
java.lang.Object |
lookup(java.lang.String name)
If the name is the expected name specified in the constructor, return the
object provided in the constructor.
|
bind, createInitialContext, execute, getContext, getEnvironment, lookup, rebind, releaseContext, setEnvironment, unbindpublic ExpectedLookupTemplate()
addObject calls.addObject(String, Object)public ExpectedLookupTemplate(java.lang.String name,
java.lang.Object object)
name - the name the client is expected to look upobject - the object that will be returnedpublic void addObject(java.lang.String name,
java.lang.Object object)
name - the name the client is expected to look upobject - the object that will be returnedpublic java.lang.Object lookup(java.lang.String name)
throws javax.naming.NamingException
lookup in class JndiTemplatename - the JNDI name of the objectnull; if a not so well-behaved
JNDI implementations returns null, a NamingException gets thrown)javax.naming.NamingException - if there is no object with the given
name bound to JNDI