Path: blob/master/test/jdk/com/sun/jndi/dns/FedTests/FedSubordinateNs.java
41155 views
/*1* Copyright (c) 2000, 2018, 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*/2223import com.sun.jndi.toolkit.dir.HierMemDirCtx;2425import javax.naming.NamingException;26import javax.naming.directory.Attributes;27import javax.naming.directory.BasicAttributes;28import javax.naming.directory.DirContext;2930/*31* This class is responsible for creating a temporary namespace to be32* used in federation tests.33*/34public class FedSubordinateNs {35static DirContext root = null;3637static {38try {39Attributes rootAttrs = new BasicAttributes("name", "root");40rootAttrs.put("description", "in-memory root");4142Attributes aAttrs = new BasicAttributes("name", "a");43aAttrs.put("description", "in-memory 1st level");4445Attributes bAttrs = new BasicAttributes("name", "b");46bAttrs.put("description", "in-memory 2nd level");4748Attributes cAttrs = new BasicAttributes("name", "c");49cAttrs.put("description", "in-memory 3rd level");5051root = new HierMemDirCtx();52root.modifyAttributes("", DirContext.ADD_ATTRIBUTE, rootAttrs);5354root.createSubcontext("a", aAttrs);55root.createSubcontext("a/b", bAttrs);56root.createSubcontext("a/b/c", cAttrs);57root.createSubcontext("x");58} catch (NamingException e) {59System.out.println("Problem in static initialization of root:" + e);60}61}6263static DirContext getRoot() {64return root;65}66}676869