Path: blob/master/test/jdk/com/sun/jndi/dns/EnvTests/SubcontextAdd.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 child context,27* its changes do not affect the environment properties of the parent28* context.29* @library ../lib/30* @modules java.base/sun.security.util31* @run main SubcontextAdd32*/3334import javax.naming.Context;35import javax.naming.directory.InitialDirContext;36import java.util.Hashtable;3738public class SubcontextAdd extends EnvTestBase {3940public static void main(String[] args) throws Exception {41new SubcontextAdd().run(args);42}4344/*45* Tests that when we add environment properties to a child context,46* its changes do not affect the environment properties of the parent47* context.48*/49@Override public void runTest() throws Exception {50setContext(new InitialDirContext(env()));5152Context child = (Context) context().lookup(getKey());5354addToEnvAndVerifyOldValIsNull(child, "com.sun.jndi.dns.recursion",55"false");56addToEnvAndVerifyOldValIsNull(child, "some.irrelevant.property",57"somevalue");5859Hashtable<?,?> envParent = context().getEnvironment();60Hashtable<?,?> envChild = child.getEnvironment();6162DNSTestUtils.debug(child);63DNSTestUtils.debug("Parent env: " + envParent);64DNSTestUtils.debug("Child env: " + envChild);6566verifyEnvProperty(envParent, "com.sun.jndi.dns.recursion", null);67verifyEnvProperty(envParent, "some.irrelevant.property", null);68verifyEnvProperty(envChild, "com.sun.jndi.dns.recursion", "false");69verifyEnvProperty(envChild, "some.irrelevant.property", "somevalue");70}71}727374