001: /*
002: * $Id: InMemoryContext.java 8083 2007-08-28 02:25:36Z aperepel $
003: * --------------------------------------------------------------------------------------
004: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
005: *
006: * The software in this package is published under the terms of the CPAL v1.0
007: * license, a copy of which has been included with this distribution in the
008: * LICENSE.txt file.
009: */
010:
011: package org.mule.tck.jndi;
012:
013: import java.util.HashMap;
014: import java.util.Hashtable;
015: import java.util.Map;
016:
017: import javax.naming.Context;
018: import javax.naming.Name;
019: import javax.naming.NameParser;
020: import javax.naming.NamingEnumeration;
021: import javax.naming.NamingException;
022:
023: /**
024: * Simple in-memory JNDI context for unit testing.
025: */
026: public class InMemoryContext implements Context {
027: private Map context = new HashMap();
028:
029: public Object lookup(Name name) throws NamingException {
030: return context.get(name);
031: }
032:
033: public Object lookup(String name) throws NamingException {
034: return context.get(name);
035: }
036:
037: public void bind(Name name, Object obj) throws NamingException {
038: context.put(name, obj);
039: }
040:
041: public void bind(String name, Object obj) throws NamingException {
042: context.put(name, obj);
043: }
044:
045: public void unbind(Name name) throws NamingException {
046: context.remove(name);
047: }
048:
049: public void unbind(String name) throws NamingException {
050: context.remove(name);
051: }
052:
053: public void rebind(Name name, Object obj) throws NamingException {
054: unbind(name);
055: bind(name, obj);
056: }
057:
058: public void rebind(String name, Object obj) throws NamingException {
059: unbind(name);
060: bind(name, obj);
061: }
062:
063: //////////////////////////////////////////////////////////////////////
064: // The remaining methods are not implemented.
065: //////////////////////////////////////////////////////////////////////
066:
067: public Object addToEnvironment(String propName, Object propVal)
068: throws NamingException {
069: return null;
070: }
071:
072: public void close() throws NamingException {
073: // nop
074: }
075:
076: public Name composeName(Name name, Name prefix)
077: throws NamingException {
078: return null;
079: }
080:
081: public String composeName(String name, String prefix)
082: throws NamingException {
083: return null;
084: }
085:
086: public Context createSubcontext(Name name) throws NamingException {
087: return null;
088: }
089:
090: public Context createSubcontext(String name) throws NamingException {
091: return null;
092: }
093:
094: public void destroySubcontext(Name name) throws NamingException {
095: // nop
096: }
097:
098: public void destroySubcontext(String name) throws NamingException {
099: // nop
100: }
101:
102: public Hashtable getEnvironment() throws NamingException {
103: return null;
104: }
105:
106: public String getNameInNamespace() throws NamingException {
107: return null;
108: }
109:
110: public NameParser getNameParser(Name name) throws NamingException {
111: return null;
112: }
113:
114: public NameParser getNameParser(String name) throws NamingException {
115: return null;
116: }
117:
118: public NamingEnumeration list(Name name) throws NamingException {
119: return null;
120: }
121:
122: public NamingEnumeration list(String name) throws NamingException {
123: return null;
124: }
125:
126: public NamingEnumeration listBindings(Name name)
127: throws NamingException {
128: return null;
129: }
130:
131: public NamingEnumeration listBindings(String name)
132: throws NamingException {
133: return null;
134: }
135:
136: public Object lookupLink(Name name) throws NamingException {
137: return null;
138: }
139:
140: public Object lookupLink(String name) throws NamingException {
141: return null;
142: }
143:
144: public Object removeFromEnvironment(String propName)
145: throws NamingException {
146: return null;
147: }
148:
149: public void rename(Name oldName, Name newName)
150: throws NamingException {
151: // nop
152: }
153:
154: public void rename(String oldName, String newName)
155: throws NamingException {
156: // nop
157: }
158: }
|