/* * @test * @bug 4278121 * @summary Ensure that calling unbind() on an unbound name returns * successfully. * @library ../../../../../../java/rmi/testlibrary * @build TestLibrary * @run main UnbindIdempotent */ import java.rmi.registry.Registry; import javax.naming.*; public class UnbindIdempotent { public static void main(String[] args) throws Exception { int registryPort = -1; // Create registry if one is not already running. try { Registry registry = TestLibrary.createRegistryOnUnusedPort(); registryPort = TestLibrary.getRegistryPort(registry); } catch (java.rmi.RemoteException e) { } Context ictx = new InitialContext(); Context rctx; try { rctx = (Context)ictx.lookup("rmi://localhost:" + Integer.toString(registryPort)); } catch (NamingException e) { // Unable to set up for test. return; } // Attempt to unbind a name that is not already bound. try { rctx.unbind("_bogus_4278121_"); } catch (NameNotFoundException e) { throw new Exception("Test failed: unbind() call not idempotent"); } } }