use of com.sun.appserv.management.config.CustomMBeanConfig in project Payara by payara.
the class CustomMBeanConfigTest method testCreateRemove.
public synchronized void testCreateRemove() {
if (!checkNotOffline("testCreateRemove")) {
return;
}
final DomainConfig domainConfig = getDomainConfig();
final Map<String, String> optional = createProps();
final Set<CustomMBeanConfig> created = new HashSet<CustomMBeanConfig>();
final Map<String, CustomMBeanConfig> existing = getDomainConfig().getResourcesConfig().getCustomMBeanConfigMap();
unregisterAnyTestMBeans();
final Set<ObjectName> customsBefore = getRegisteredCustoms();
if (customsBefore.size() != 0) {
printVerbose("custom MBeans already registered:\n" + CollectionUtil.toString(customsBefore, "\n"));
}
final int NUM = 3;
for (int i = 0; i < NUM; ++i) {
final String testName = TEST_NAME_BASE + i;
if (existing.containsKey(testName)) {
RefHelper.removeAllRefsTo(existing.get(testName), true);
// leftover from a failed test...
removeCustomMBean(testName);
}
final CustomMBeanConfig config = create(domainConfig, TEST_NAME_BASE + i, optional);
assert (getCustomMBeanConfigs().get(config.getName()) == config);
created.add(config);
sanityCheck(config);
verifyPropsAdded(config, optional);
}
_testGetAll();
_testAttrs();
for (final CustomMBeanConfig config : created) {
// printVerbose( "removing: " + Util.getObjectName( config ) );
final String name = config.getName();
removeCustomMBean(name);
assert (getCustomMBeanConfigs().get(name) == null);
}
_testGetAll();
mySleep(100);
final Set<ObjectName> customsAfter = getRegisteredCustoms();
customsAfter.removeAll(customsBefore);
if (customsAfter.size() != 0) {
warning("after removing custom MBeans, " + "they are still registered (not an AMX bug):\n" + CollectionUtil.toString(customsAfter, "\n"));
}
unregisterAnyTestMBeans();
}
Aggregations