net.sourceforge.sqlunit.test.mock
Class MockInitialContext

java.lang.Object
  extended by javax.naming.InitialContext
      extended by net.sourceforge.sqlunit.test.mock.MockInitialContext
All Implemented Interfaces:
javax.naming.Context

public class MockInitialContext
extends javax.naming.InitialContext

Overrides the InitialContext to provide an in-memory lookup mechanism instead of network lookup. The only methods overriden are bind() and lookup().

Version:
$Revision: 1.2 $
Author:
Sujit Pal (spal@users.sourceforge.net)

Field Summary
 
Fields inherited from class javax.naming.InitialContext
defaultInitCtx, gotDefault, myProps
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
MockInitialContext()
          Default constructor used by the MockInitialContextFactory.
 
Method Summary
 void bind(java.lang.String name, java.lang.Object obj)
          Binds an Object into the Context by name.
 java.lang.Object lookup(java.lang.String name)
          Retrieves an Object from the Context by name.
 
Methods inherited from class javax.naming.InitialContext
addToEnvironment, bind, close, composeName, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, getDefaultInitCtx, getEnvironment, getNameInNamespace, getNameParser, getNameParser, getURLOrDefaultInitCtx, getURLOrDefaultInitCtx, init, list, list, listBindings, listBindings, lookup, lookupLink, lookupLink, rebind, rebind, removeFromEnvironment, rename, rename, unbind, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockInitialContext

public MockInitialContext()
                   throws javax.naming.NamingException
Default constructor used by the MockInitialContextFactory.

Throws:
javax.naming.NamingException - if an error occurs in initialization.
Method Detail

bind

public final void bind(java.lang.String name,
                       java.lang.Object obj)
                throws javax.naming.NamingException
Binds an Object into the Context by name.

Specified by:
bind in interface javax.naming.Context
Overrides:
bind in class javax.naming.InitialContext
Parameters:
name - the key to look the Object up by.
obj - the Object to bind into the Context.
Throws:
javax.naming.NamingException - if there is a problem with binding.

lookup

public final java.lang.Object lookup(java.lang.String name)
                              throws javax.naming.NamingException
Retrieves an Object from the Context by name.

Specified by:
lookup in interface javax.naming.Context
Overrides:
lookup in class javax.naming.InitialContext
Parameters:
name - the name of the Object in the context.
Returns:
the value of the Object.
Throws:
javax.naming.NamingException - if there is a problem with lookup.