01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.jndi.tests.javax.naming.spi.mock;
19:
20: import java.util.Hashtable;
21:
22: import javax.naming.NamingException;
23: import javax.naming.ldap.Control;
24: import javax.naming.ldap.ExtendedRequest;
25: import javax.naming.ldap.ExtendedResponse;
26: import javax.naming.ldap.LdapContext;
27:
28: public class MockLdapContext extends MockDirContext implements
29: LdapContext {
30: Hashtable<String, Object> ldapProps;
31:
32: @SuppressWarnings("unchecked")
33: public MockLdapContext(Hashtable<?, ?> h) {
34: super (h);
35: this .ldapProps = (Hashtable<String, Object>) h.clone();
36: }
37:
38: public Hashtable<String, Object> getProps() {
39: return this .ldapProps;
40: }
41:
42: public ExtendedResponse extendedOperation(ExtendedRequest e)
43: throws NamingException {
44: InvokeRecord.set((String) this .props.get("url.schema"), e);
45: takeActions();
46: return null;
47: }
48:
49: public LdapContext newInstance(Control[] ac) throws NamingException {
50: InvokeRecord.set((String) this .props.get("url.schema"), ac);
51: takeActions();
52: return null;
53: }
54:
55: public void reconnect(Control[] ac) throws NamingException {
56: InvokeRecord.set((String) this .props.get("url.schema"), ac);
57: takeActions();
58: }
59:
60: public Control[] getConnectControls() throws NamingException {
61: InvokeRecord.set((String) this .props.get("url.schema"),
62: "getConnectControls");
63: takeActions();
64: return null;
65: }
66:
67: public void setRequestControls(Control[] ac) throws NamingException {
68: InvokeRecord.set((String) this .props.get("url.schema"), ac);
69: takeActions();
70: }
71:
72: public Control[] getRequestControls() throws NamingException {
73: InvokeRecord.set((String) this .props.get("url.schema"),
74: "getRequestControls");
75: takeActions();
76: return null;
77: }
78:
79: public Control[] getResponseControls() throws NamingException {
80: InvokeRecord.set((String) this .props.get("url.schema"),
81: "getResponseControls");
82: takeActions();
83: return null;
84: }
85:
86: }
|