UnbindIdempotent.java revision 0
0N/A/*
0N/A * @test
0N/A * @bug 4278121
0N/A * @summary Ensure that calling unbind() on an unbound name returns
0N/A * successfully.
0N/A */
0N/A
0N/Aimport javax.naming.*;
0N/A
0N/Apublic class UnbindIdempotent {
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A
0N/A // Create registry on port 1099 if one is not already running.
0N/A try {
0N/A java.rmi.registry.LocateRegistry.createRegistry(1099);
0N/A } catch (java.rmi.RemoteException e) {
0N/A }
0N/A
0N/A Context ictx = new InitialContext();
0N/A Context rctx;
0N/A try {
0N/A rctx = (Context)ictx.lookup("rmi://localhost:1099");
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}