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 |
Object | lookup(String name) If the name is the expected name specified in the constructor,
return the object provided in the constructor. |
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
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.
to Class java.lang.String