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