KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > naming > MockContext


1 package com.mockobjects.naming;
2
3 import com.mockobjects.ExpectationList;
4 import com.mockobjects.ExpectationValue;
5 import com.mockobjects.MockObject;
6 import com.mockobjects.ReturnObjectList;
7
8 import javax.naming.*;
9
10 public class MockContext extends MockObject implements Context {
11     private final ReturnObjectList myLookupObjects =
12         new ReturnObjectList("lookups");
13     private final ReturnObjectList mySubContexts =
14         new ReturnObjectList("sub contexts");
15     private ExpectationList mySubContextNames = new ExpectationList(
16         MockContext.class.getName() + "sub context name");
17     private ExpectationValue myBindName = new ExpectationValue(
18         MockContext.class.getName() + "myBindName");
19     private ExpectationValue myBindObject = new ExpectationValue(
20         MockContext.class.getName() + "myBindObject");
21     private ExpectationValue myRebindName = new ExpectationValue(
22         MockContext.class.getName() + "myRebindName");
23     private ExpectationValue myLookupName = new ExpectationValue(
24         MockContext.class.getName() + "myLookupName");
25
26     public void setupAddLookup(Object JavaDoc aObjectToReturn) {
27         this.myLookupObjects.addObjectToReturn(aObjectToReturn);
28     }
29
30     public void setExpectedLookupName(String JavaDoc aLookupName) {
31         this.myLookupName.setExpected(aLookupName);
32     }
33
34     public Object JavaDoc lookup(Name name) throws NamingException {
35         this.myLookupName.setActual(name);
36         return myLookupObjects.nextReturnObject();
37     }
38
39     public Object JavaDoc lookup(String JavaDoc name) throws NamingException {
40         this.myLookupName.setActual(name);
41         return myLookupObjects.nextReturnObject();
42     }
43
44     public void bind(Name aBindName, Object JavaDoc aBindObject) throws NamingException {
45         this.myBindName.setExpected(aBindName);
46         this.myBindObject.setExpected(aBindObject);
47     }
48
49     public void setExpectedBind(String JavaDoc aBindName, Object JavaDoc aBindObject) {
50         this.myBindName.setExpected(aBindName);
51         this.myBindObject.setExpected(aBindObject);
52     }
53
54     public void setExpectedReBind(String JavaDoc aBindName, Object JavaDoc aBindObject) {
55         this.myRebindName.setExpected(aBindName);
56         this.myRebindName.setExpected(aBindObject);
57     }
58
59     public void bind(String JavaDoc aBindName, Object JavaDoc aBindObject) throws NamingException {
60         this.myBindName.setActual(aBindName);
61         this.myBindObject.setActual(aBindObject);
62     }
63
64     public void rebind(Name aBindName, Object JavaDoc aBindObject) throws NamingException {
65         this.myRebindName.setActual(aBindName);
66         this.myRebindName.setActual(aBindObject);
67     }
68
69     public void rebind(String JavaDoc aBindName, Object JavaDoc aBindObject) throws NamingException {
70         this.myRebindName.setActual(aBindName);
71         this.myRebindName.setActual(aBindObject);
72     }
73
74     public void unbind(Name name) throws NamingException {
75         notImplemented();
76     }
77
78     public void unbind(String JavaDoc name) throws NamingException {
79         notImplemented();
80     }
81
82     public void rename(Name name, Name name2) throws NamingException {
83         notImplemented();
84     }
85
86     public void rename(String JavaDoc name, String JavaDoc name2) throws NamingException {
87         notImplemented();
88     }
89
90     public NamingEnumeration list(Name name) throws NamingException {
91         notImplemented();
92         return null;
93     }
94
95     public NamingEnumeration list(String JavaDoc name) throws NamingException {
96         notImplemented();
97         return null;
98     }
99
100     public NamingEnumeration listBindings(Name name) throws NamingException {
101         notImplemented();
102         return null;
103     }
104
105     public NamingEnumeration listBindings(String JavaDoc name) throws NamingException {
106         notImplemented();
107         return null;
108     }
109
110     public void destroySubcontext(Name name) throws NamingException {
111         notImplemented();
112     }
113
114     public void destroySubcontext(String JavaDoc name) throws NamingException {
115         notImplemented();
116     }
117
118     public Context createSubcontext(Name name) throws NamingException {
119         notImplemented();
120         return null;
121     }
122
123     public void setupAddCreateSubContext(Context aContext){
124         mySubContexts.addObjectToReturn(aContext);
125     }
126
127     public void setExpectedCreateSubContext(String JavaDoc name){
128         this.mySubContextNames.addExpected(name);
129     }
130
131     public Context createSubcontext(String JavaDoc name) throws NamingException {
132         mySubContextNames.addActual(name);
133         return (Context) mySubContexts.nextReturnObject();
134     }
135
136     public Object JavaDoc lookupLink(Name name) throws NamingException {
137         notImplemented();
138         return null;
139     }
140
141     public Object JavaDoc lookupLink(String JavaDoc name) throws NamingException {
142         notImplemented();
143         return null;
144     }
145
146     public NameParser getNameParser(Name name) throws NamingException {
147         notImplemented();
148         return null;
149     }
150
151     public NameParser getNameParser(String JavaDoc name) throws NamingException {
152         notImplemented();
153         return null;
154     }
155
156     public Name composeName(Name name, Name name2) throws NamingException {
157         notImplemented();
158         return null;
159     }
160
161     public String JavaDoc composeName(String JavaDoc name, String JavaDoc name2) throws NamingException {
162         notImplemented();
163         return null;
164     }
165
166     public Object JavaDoc addToEnvironment(String JavaDoc name, Object JavaDoc object) throws NamingException {
167         notImplemented();
168         return null;
169     }
170
171     public Object JavaDoc removeFromEnvironment(String JavaDoc name) throws NamingException {
172         notImplemented();
173         return null;
174     }
175
176     public java.util.Hashtable JavaDoc getEnvironment() throws NamingException {
177         notImplemented();
178         return null;
179     }
180
181     public void close() throws NamingException {
182         notImplemented();
183     }
184
185     public String JavaDoc getNameInNamespace() throws NamingException {
186         notImplemented();
187         return null;
188     }
189
190 }
191
Popular Tags