2
|
1 |
/*
|
|
2 |
* @test
|
|
3 |
* @bug 4278121
|
|
4 |
* @summary Ensure that calling unbind() on an unbound name returns
|
|
5 |
* successfully.
|
|
6 |
*/
|
|
7 |
|
|
8 |
import javax.naming.*;
|
|
9 |
|
|
10 |
public class UnbindIdempotent {
|
|
11 |
|
|
12 |
public static void main(String[] args) throws Exception {
|
|
13 |
|
|
14 |
// Create registry on port 1099 if one is not already running.
|
|
15 |
try {
|
|
16 |
java.rmi.registry.LocateRegistry.createRegistry(1099);
|
|
17 |
} catch (java.rmi.RemoteException e) {
|
|
18 |
}
|
|
19 |
|
|
20 |
Context ictx = new InitialContext();
|
|
21 |
Context rctx;
|
|
22 |
try {
|
|
23 |
rctx = (Context)ictx.lookup("rmi://localhost:1099");
|
|
24 |
} catch (NamingException e) {
|
|
25 |
// Unable to set up for test.
|
|
26 |
return;
|
|
27 |
}
|
|
28 |
|
|
29 |
// Attempt to unbind a name that is not already bound.
|
|
30 |
try {
|
|
31 |
rctx.unbind("_bogus_4278121_");
|
|
32 |
} catch (NameNotFoundException e) {
|
|
33 |
throw new Exception("Test failed: unbind() call not idempotent");
|
|
34 |
}
|
|
35 |
}
|
|
36 |
}
|