5266N/A/*
5266N/A * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
5266N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5266N/A *
5266N/A * This code is free software; you can redistribute it and/or modify it
5266N/A * under the terms of the GNU General Public License version 2 only, as
5266N/A * published by the Free Software Foundation.
5266N/A *
5266N/A * This code is distributed in the hope that it will be useful, but WITHOUT
5266N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5266N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5266N/A * version 2 for more details (a copy is included in the LICENSE file that
5266N/A * accompanied this code).
5266N/A *
5266N/A * You should have received a copy of the GNU General Public License version
5266N/A * 2 along with this work; if not, write to the Free Software Foundation,
5266N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5266N/A *
5266N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5266N/A * or visit www.oracle.com if you need additional information or have any
5266N/A * questions.
5266N/A */
5266N/A
0N/A/*
0N/A * @test
0N/A * @bug 4278121
0N/A * @summary Ensure that calling unbind() on an unbound name returns
0N/A * successfully.
5266N/A * @library ../../../../../../java/rmi/testlibrary
5266N/A * @build TestLibrary
5266N/A * @run main UnbindIdempotent
0N/A */
0N/A
5266N/Aimport java.rmi.registry.Registry;
5267N/Aimport javax.naming.Context;
5266N/Aimport javax.naming.InitialContext;
5266N/Aimport javax.naming.NameNotFoundException;
5266N/Aimport javax.naming.NamingException;
0N/A
0N/Apublic class UnbindIdempotent {
0N/A
0N/A public static void main(String[] args) throws Exception {
5266N/A Registry registry = TestLibrary.createRegistryOnUnusedPort();
5266N/A int registryPort = TestLibrary.getRegistryPort(registry);
5266N/A InitialContext ictx = new InitialContext();
5266N/A Context rctx;
0N/A
0N/A try {
5266N/A rctx = (Context)ictx.lookup("rmi://localhost:" + Integer.toString(registryPort));
0N/A } catch (NamingException e) {
0N/A // Unable to set up for test.
0N/A return;
0N/A }
0N/A
0N/A // Attempt to unbind a name that is not already bound.
0N/A try {
0N/A rctx.unbind("_bogus_4278121_");
0N/A } catch (NameNotFoundException e) {
0N/A throw new Exception("Test failed: unbind() call not idempotent");
0N/A }
0N/A }
0N/A}