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;
19:
20: import java.io.IOException;
21: import java.util.Enumeration;
22: import java.util.Hashtable;
23:
24: import javax.naming.Context;
25: import javax.naming.InitialContext;
26: import javax.naming.NamingException;
27:
28: import junit.framework.TestCase;
29: import org.apache.harmony.jndi.tests.javax.naming.util.Log;
30:
31: public class InitialContextSysTest extends TestCase {
32: private final Log log = new Log(InitialContextSysTest.class);
33:
34: public void testConstructor_sys() throws NamingException,
35: IOException {
36: log.setMethod("testConstructor_sys");
37: /*
38: * Set System properties
39: */
40: System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
41: "dazzle.jndi.testing.spi.DazzleContextFactory");
42: // C
43: System.setProperty("java.naming.factory.control",
44: "java.naming.factory.control.sys");
45: System.setProperty("java.naming.factory.object",
46: "java.naming.factory.object.sys");
47: System.setProperty("java.naming.factory.state",
48: "java.naming.factory.state.sys");
49: System.setProperty("java.naming.factory.url.pkgs",
50: "java.naming.factory.url.pkgs.sys");
51: // F
52: System.setProperty("java.naming.provider.url",
53: "java.naming.provider.url.sys");
54: System.setProperty("java.naming.authoritative",
55: "java.naming.authoritative.sys");
56: System.setProperty("java.naming.batchsize",
57: "java.naming.batchsize.app1");
58: System.setProperty("java.naming.dns.url",
59: "java.naming.dns.url.sys");
60: System.setProperty("java.naming.language",
61: "java.naming.language.sys");
62: System.setProperty("java.naming.referral",
63: "java.naming.referral.sys");
64: System.setProperty("java.naming.security.authentication",
65: "java.naming.security.authentication.sys");
66: System.setProperty("java.naming.security.credentials",
67: "java.naming.security.credentials.sys");
68: System.setProperty("java.naming.security.principal",
69: "java.naming.security.principal.sys");
70: System.setProperty("java.naming.security.protocol",
71: "java.naming.security.protocol.sys");
72:
73: // other
74: System.setProperty("dazzle.jndi.testing.spi.sys",
75: "dazzle.jndi.testing.spi.sys.sys");
76: // junk
77: System.setProperty("sys.type", "sys.type.sys");
78:
79: InitialContext context = new InitialContext();
80: Hashtable<?, ?> props = context.getEnvironment();
81: // printHashtable(props);
82: Hashtable<?, ?> expected = InitialContextLibTest
83: .readAllProps(null);
84: assertEquals(expected, props);
85: }
86:
87: void printHashtable(Hashtable<?, ?> env) {
88: // TO DO: Need to remove
89: Enumeration<?> keys = env.keys();
90: while (keys.hasMoreElements()) {
91: Object key = keys.nextElement();
92: log.log(key + "=" + env.get(key));
93: }
94: }
95: }
|