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: package org.apache.harmony.jndi.tests.javax.naming.spi.mock;
18:
19: import java.util.Hashtable;
20:
21: import javax.naming.Context;
22: import javax.naming.Name;
23: import javax.naming.NamingException;
24: import javax.naming.directory.Attributes;
25: import javax.naming.spi.DirStateFactory;
26:
27: import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
28: import org.apache.harmony.jndi.tests.javax.naming.util.Log;
29:
30: public class MockDirStateFactory implements DirStateFactory {
31:
32: static Log log = new Log(MockDirStateFactory.class);
33:
34: public MockDirStateFactory() {
35: super ();
36: }
37:
38: /*
39: * (non-Javadoc)
40: *
41: * @see javax.naming.spi.DirStateFactory#getStateToBind(java.lang.Object,
42: * javax.naming.Name, javax.naming.Context, java.util.Hashtable,
43: * javax.naming.directory.Attributes)
44: */
45: public Result getStateToBind(Object o, Name n, Context c,
46: Hashtable<?, ?> h, Attributes a) throws NamingException {
47: NamingManagerTest.issueIndicatedExceptions(h);
48: if (NamingManagerTest.returnNullIndicated(h)) {
49: return null;
50: }
51: Hashtable<String, Object> r = new Hashtable<String, Object>();
52: if (null != o) {
53: r.put("o", o);
54: }
55: if (null != n) {
56: r.put("n", n);
57: }
58: if (null != c) {
59: r.put("c", c);
60: }
61: if (null != h) {
62: r.put("h", h);
63: }
64: if (null != a) {
65: r.put("a", a);
66: }
67: return new Result(r, a);
68:
69: }
70:
71: /*
72: * (non-Javadoc)
73: *
74: * @see javax.naming.spi.StateFactory#getStateToBind(java.lang.Object,
75: * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
76: */
77: public Object getStateToBind(Object o, Name n, Context c,
78: Hashtable<?, ?> h) throws NamingException {
79: return getStateToBind(o, n, c, h, null);
80: }
81:
82: }
|