// new Throwable().printStackTrace();
}
}
public void run() throws Exception {
LookupDiscovery disc = null;
DiscoveryAdmin admin = null;
// Create a LookupDiscovery object.
disc = new LookupDiscovery(Util.makeGroups("start", 700),
getConfig().getConfiguration());
logger.log(Level.INFO,
"constructed with " + disc.getGroups().length + " elements");
Thread.sleep(10000);
disc.addDiscoveryListener(new Ignorer());
ServiceRegistrar reg = createLookup();
admin = getAdmin(reg);
String[] actualGroups = new String[] {
reg.getServiceID().toString() };
admin.setMemberGroups(actualGroups);
disc.addGroups(Util.makeGroups("added", 200));
logger.log(Level.INFO, "increased to " + disc.getGroups().length
+ " elements");
Thread.sleep(10000);
disc.removeGroups(Util.makeGroups("start", 300));
logger.log(Level.INFO,
"reduced to " + disc.getGroups().length + " elements");
Thread.sleep(10000);
disc.setGroups(Util.makeGroups("toasty", 100));
logger.log(Level.INFO,
"changed to " + disc.getGroups().length + " elements");
Thread.sleep(10000);
disc.setGroups(DiscoveryGroupManagement.ALL_GROUPS);
logger.log(Level.INFO, "set to ALL_GROUPS");
Thread.sleep(60000);
try {
disc.addGroups(actualGroups);
throw new TestException("addGroups to null didn't throw anything");
} catch (UnsupportedOperationException e) {
// expected
}
try {
disc.removeGroups(actualGroups);
throw new TestException("removeGroups from null didn't "
+ "throw anything");
} catch (UnsupportedOperationException e) {
// expected
}
disc.setGroups(DiscoveryGroupManagement.NO_GROUPS);
logger.log(Level.INFO, "set to NO_GROUPS");
Thread.sleep(10000);
Discarder arder = new Discarder(reg.getServiceID(), disc);
disc.addDiscoveryListener(arder);
disc.addGroups(actualGroups);
logger.log(Level.INFO, "increased to " + disc.getGroups().length
+ " elements");
Thread.sleep(30000);
if (arder.discovery != true) {
throw new TestException("no discovered event reported");
}
if (arder.discardery != true) {
throw new TestException("no discarded event reported");
}
if (arder.unexpected == true) {
throw new TestException( "unexpected event reported");
}
disc.terminate();
try {
disc.addGroups(actualGroups);
throw new TestException("addGroups after terminate didn't "
+ "throw anything");
} catch (IllegalStateException e) {
}
try {
disc.removeGroups(actualGroups);
throw new TestException("removeGroups after terminate didn't "
+ "throw anything");
} catch (IllegalStateException e) {
}
try {
disc.setGroups(actualGroups);
throw new TestException("setGroups after terminate didn't "
+ "throw anything");
} catch (IllegalStateException e) {
}
}