View Javadoc

1   /*
2    * $Id: InMemoryContext.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.tck.jndi;
12  
13  import java.util.HashMap;
14  import java.util.Hashtable;
15  import java.util.Map;
16  
17  import javax.naming.Context;
18  import javax.naming.Name;
19  import javax.naming.NameParser;
20  import javax.naming.NamingEnumeration;
21  import javax.naming.NamingException;
22  
23  /**
24   * Simple in-memory JNDI context for unit testing.
25   */
26  public class InMemoryContext implements Context
27  {
28      private Map context = new HashMap();
29  
30      public Object lookup(Name name) throws NamingException
31      {
32          return context.get(name);
33      }
34  
35      public Object lookup(String name) throws NamingException
36      {
37          return context.get(name);
38      }
39  
40      public void bind(Name name, Object obj) throws NamingException
41      {
42          context.put(name, obj);
43      }
44  
45      public void bind(String name, Object obj) throws NamingException
46      {
47          context.put(name, obj);
48      }
49  
50      public void unbind(Name name) throws NamingException
51      {
52          context.remove(name);
53      }
54  
55      public void unbind(String name) throws NamingException
56      {
57          context.remove(name);
58      }
59  
60      public void rebind(Name name, Object obj) throws NamingException
61      {
62          unbind(name);
63          bind(name, obj);
64      }
65  
66      public void rebind(String name, Object obj) throws NamingException
67      {
68          unbind(name);
69          bind(name, obj);
70      }
71  
72      //////////////////////////////////////////////////////////////////////
73      // The remaining methods are not implemented.
74      //////////////////////////////////////////////////////////////////////
75      
76      public Object addToEnvironment(String propName, Object propVal) throws NamingException
77      {
78          return null;
79      }
80  
81      public void close() throws NamingException
82      {
83          // nop
84      }
85  
86      public Name composeName(Name name, Name prefix) throws NamingException
87      {
88          return null;
89      }
90  
91      public String composeName(String name, String prefix) throws NamingException
92      {
93          return null;
94      }
95  
96      public Context createSubcontext(Name name) throws NamingException
97      {
98          return null;
99      }
100 
101     public Context createSubcontext(String name) throws NamingException
102     {
103         return null;
104     }
105 
106     public void destroySubcontext(Name name) throws NamingException
107     {
108         // nop
109     }
110 
111     public void destroySubcontext(String name) throws NamingException
112     {
113         // nop
114     }
115 
116     public Hashtable getEnvironment() throws NamingException
117     {
118         return null;
119     }
120 
121     public String getNameInNamespace() throws NamingException
122     {
123         return null;
124     }
125 
126     public NameParser getNameParser(Name name) throws NamingException
127     {
128         return null;
129     }
130 
131     public NameParser getNameParser(String name) throws NamingException
132     {
133         return null;
134     }
135 
136     public NamingEnumeration list(Name name) throws NamingException
137     {
138         return null;
139     }
140 
141     public NamingEnumeration list(String name) throws NamingException
142     {
143         return null;
144     }
145 
146     public NamingEnumeration listBindings(Name name) throws NamingException
147     {
148         return null;
149     }
150 
151     public NamingEnumeration listBindings(String name) throws NamingException
152     {
153         return null;
154     }
155 
156     public Object lookupLink(Name name) throws NamingException
157     {
158         return null;
159     }
160 
161     public Object lookupLink(String name) throws NamingException
162     {
163         return null;
164     }
165 
166     public Object removeFromEnvironment(String propName) throws NamingException
167     {
168         return null;
169     }
170 
171     public void rename(Name oldName, Name newName) throws NamingException
172     {
173         // nop
174     }
175 
176     public void rename(String oldName, String newName) throws NamingException
177     {
178         // nop
179     }
180 }
181 
182