Cross Reference: UnbindIdempotent.java
xref
: /
openjdk7
/
jdk
/
test
/
com
/
sun
/
jndi
/
rmi
/
registry
/
RegistryContext
/
UnbindIdempotent.java
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
UnbindIdempotent.java revision 0
0
N/A
/*
0
N/A
* @test
0
N/A
* @bug 4278121
0
N/A
* @summary Ensure that calling unbind() on an unbound name returns
0
N/A
* successfully.
0
N/A
*/
0
N/A
0
N/A
import
javax
.
naming
.*;
0
N/A
0
N/A
public
class
UnbindIdempotent
{
0
N/A
0
N/A
public
static
void
main
(
String
[]
args
)
throws
Exception
{
0
N/A
0
N/A
// Create registry on port 1099 if one is not already running.
0
N/A
try
{
0
N/A
java
.
rmi
.
registry
.
LocateRegistry
.
createRegistry
(
1099
);
0
N/A
}
catch
(
java
.
rmi
.
RemoteException
e) {
0
N/A
}
0
N/A
0
N/A
Context
ictx
=
new
InitialContext
();
0
N/A
Context
rctx
;
0
N/A
try
{
0
N/A
rctx
= (
Context
)
ictx
.
lookup
(
"rmi://localhost:1099"
);
0
N/A
}
catch
(
NamingException
e) {
0
N/A
// Unable to set up for test.
0
N/A
return
;
0
N/A
}
0
N/A
0
N/A
// Attempt to unbind a name that is not already bound.
0
N/A
try
{
0
N/A
rctx
.
unbind
(
"_bogus_4278121_"
);
0
N/A
}
catch
(
NameNotFoundException
e) {
0
N/A
throw
new
Exception
(
"Test failed: unbind() call not idempotent"
);
0
N/A
}
0
N/A
}
0
N/A
}