master
Sam Brannen 16 years ago
parent be7bbcd228
commit 18039162b9
  1. 28
      org.springframework.test/src/main/java/org/springframework/mock/jndi/ExpectedLookupTemplate.java

@ -21,12 +21,11 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.naming.NamingException; import javax.naming.NamingException;
import org.springframework.core.CollectionFactory;
import org.springframework.jndi.JndiTemplate; import org.springframework.jndi.JndiTemplate;
/** /**
* Simple extension of the JndiTemplate class that always returns * Simple extension of the JndiTemplate class that always returns a given
* a given object. Very useful for testing. Effectively a mock object. * object. Very useful for testing. Effectively a mock object.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
@ -37,16 +36,18 @@ public class ExpectedLookupTemplate extends JndiTemplate {
/** /**
* Construct a new JndiTemplate that will always return given objects * Construct a new JndiTemplate that will always return given objects for
* for given names. To be populated through <code>addObject</code> calls. * given names. To be populated through <code>addObject</code> calls.
*
* @see #addObject(String, Object) * @see #addObject(String, Object)
*/ */
public ExpectedLookupTemplate() { public ExpectedLookupTemplate() {
} }
/** /**
* Construct a new JndiTemplate that will always return the * Construct a new JndiTemplate that will always return the given object,
* given object, but honour only requests for the given name. * but honour only requests for the given name.
*
* @param name the name the client is expected to look up * @param name the name the client is expected to look up
* @param object the object that will be returned * @param object the object that will be returned
*/ */
@ -54,10 +55,10 @@ public class ExpectedLookupTemplate extends JndiTemplate {
addObject(name, object); addObject(name, object);
} }
/** /**
* Add the given object to the list of JNDI objects that this * Add the given object to the list of JNDI objects that this template will
* template will expose. * expose.
*
* @param name the name the client is expected to look up * @param name the name the client is expected to look up
* @param object the object that will be returned * @param object the object that will be returned
*/ */
@ -65,11 +66,10 @@ public class ExpectedLookupTemplate extends JndiTemplate {
this.jndiObjects.put(name, object); this.jndiObjects.put(name, object);
} }
/** /**
* If the name is the expected name specified in the constructor, * If the name is the expected name specified in the constructor, return the
* return the object provided in the constructor. If the name is * object provided in the constructor. If the name is unexpected, a
* unexpected, a respective NamingException gets thrown. * respective NamingException gets thrown.
*/ */
public Object lookup(String name) throws NamingException { public Object lookup(String name) throws NamingException {
Object object = this.jndiObjects.get(name); Object object = this.jndiObjects.get(name);

Loading…
Cancel
Save