org.springframework.jndi.support
Class ExpectedLookupTemplate

org.springframework.jndi.JndiTemplate
  |
  +--org.springframework.jndi.support.ExpectedLookupTemplate

public class ExpectedLookupTemplate
extends JndiTemplate

Simple implementation of JndiTemplate interface that always returns a given object. Very useful for testing. Effectively a mock object.

Author:
Rod Johnson
Version: $Id: ExpectedLookupTemplate.java,v 1.3 2004/02/09 10:46:58 jhoeller Exp $
See Also: DriverManagerDataSource

Constructor Summary
ExpectedLookupTemplate(String name, Object object)
          Construct a new JndiTemplate that will always return the given object, but honour only requests for the given name.

Method Summary
 Objectlookup(String name)
          If the name is the expected name specified in the constructor, return the object provided in the constructor.

Methods inherited from class org.springframework.jndi.JndiTemplate
bind, execute, getEnvironment, setEnvironment, unbind

Constructor Detail

ExpectedLookupTemplate

public ExpectedLookupTemplate(String name, Object object)
Construct a new JndiTemplate that will always return the given object, but honour only requests for the given name.
Parameters:
name - the name the client is expected to look up
object - the object that will be returned
Method Detail

lookup

public Object lookup(String name)
throws javax.naming.NamingException
If the name is the expected name specified in the constructor, return the object provided in the constructor. If the name is unexpected, a respective NamingException gets thrown.

Association Links

to Class java.lang.String