Path: blob/master/test/jdk/com/sun/jndi/dns/EnvTests/AddInherited.java
41155 views
/*1* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 820827926* @summary Tests that when we add environment properties to a context, its27* changes are reflected in the environment properties of any child28* context derived from the context.29* @library ../lib/30* @modules java.base/sun.security.util31* @run main AddInherited32*/3334import javax.naming.Context;35import javax.naming.directory.InitialDirContext;36import java.util.Hashtable;3738public class AddInherited extends EnvTestBase {3940public static void main(String[] args) throws Exception {41new AddInherited().run(args);42}4344/*45* Tests that when we add environment properties to a context, its46* changes are reflected in the environment properties of any child47* context derived from the context.48*/49@Override public void runTest() throws Exception {50setContext(new InitialDirContext(env()));5152addToEnvAndVerifyOldValIsNull("com.sun.jndi.dns.recursion", "false");53addToEnvAndVerifyOldValIsNull("some.irrelevant.property", "somevalue");5455Context child = (Context) context().lookup(getKey());5657Hashtable<?,?> envParent = context().getEnvironment();58Hashtable<?,?> envChild = child.getEnvironment();5960DNSTestUtils.debug(child);61DNSTestUtils.debug("Parent env: " + envParent);62DNSTestUtils.debug("Child env: " + envChild);6364verifyEnvProperty(envParent, "com.sun.jndi.dns.recursion", "false");65verifyEnvProperty(envParent, "some.irrelevant.property", "somevalue");66verifyEnvProperty(envChild, "com.sun.jndi.dns.recursion", "false");67verifyEnvProperty(envChild, "some.irrelevant.property", "somevalue");68}69}707172