use of com.sun.appserv.management.base.Container in project Payara by payara.
the class AMXTest method checkMapsHaveCreateRemove.
/**
* Verify that all getAbcConfigMgr() calls return a non-null result.
*/
public void checkMapsHaveCreateRemove(final ObjectName objectName) throws Exception {
final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
if (proxy instanceof Container && proxy.getGroup().equals(AMX.GROUP_CONFIGURATION)) {
final Extra extra = Util.getExtra(proxy);
final String[] attrNames = extra.getAttributeNames();
for (int i = 0; i < attrNames.length; ++i) {
final String name = attrNames[i];
final String SUFFIX = "ObjectNameMap";
final String PREFIX = JMXUtil.GET;
if (name.endsWith(SUFFIX)) {
final String base = StringUtil.stripPrefixAndSuffix(name, PREFIX, SUFFIX);
if (base.endsWith("ConnectorModuleConfig")) {
// these are created via deployment not directly
continue;
}
final String createName = "create" + base;
final String removeName = "remove" + base;
final String j2eeType = proxy.getJ2EEType();
if (ignoreCreateRemove(proxy.getJ2EEType(), createName)) {
continue;
}
final MBeanOperationInfo[] creates = JMXUtil.findOperations(extra.getMBeanInfo().getOperations(), createName);
boolean haveCreate = false;
for (int op = 0; op < creates.length; ++op) {
final MBeanOperationInfo info = creates[op];
if (info.getReturnType().equals(ObjectName.class.getName())) {
haveCreate = true;
break;
}
}
assert (haveCreate) : "Missing operation " + createName + "() for " + objectName;
final MBeanOperationInfo[] removes = JMXUtil.findOperations(extra.getMBeanInfo().getOperations(), removeName);
boolean haveRemove = false;
for (int op = 0; op < removes.length; ++op) {
final MBeanOperationInfo info = removes[op];
if (info.getReturnType().equals("void") && info.getSignature().length <= 2) {
haveRemove = true;
break;
}
}
assert (haveRemove) : "Missing operation " + removeName + "() for " + objectName;
}
}
}
}
use of com.sun.appserv.management.base.Container in project Payara by payara.
the class ConfigMgrTestBase method testCreateRemove.
public final synchronized void testCreateRemove() throws Exception {
if (!checkNotOffline("testCreateRemove")) {
return;
}
final long start = now();
String name = getProgenyTestName();
final String progenyJ2EEType = getProgenyJ2EEType();
AMXConfig proxy = getProgeny(name);
if (proxy != null) {
final ObjectName objectName = Util.getExtra(proxy).getObjectName();
remove(name);
waitUnregistered(objectName);
assert (!getConnection().isRegistered(objectName));
assert (getProgeny(name) == null);
proxy = null;
}
final Container container = getProgenyContainer();
final CreateRemoveListener listener = new CreateRemoveListener(container, progenyJ2EEType, name);
// create it
try {
proxy = createProgeny(name, null);
} catch (Exception e) {
trace(getStackTrace(ExceptionUtil.getRootCause(e)));
failure("Can't create item of j2eeType=" + progenyJ2EEType + ",name=" + name);
}
assert (proxy.getName().equals(name));
final ObjectName objectName = Util.getObjectName(proxy);
assert (getConnection().isRegistered(objectName));
assert (container.getContainee(progenyJ2EEType, name) != null);
assert (container.getContainee(progenyJ2EEType, name) == proxy);
final AMXConfig progeny = getProgeny(name);
assert (progeny == proxy);
// remove it
final ProxyFactory factory = Util.getExtra(proxy).getProxyFactory();
assert (name.equals(progeny.getName()));
remove(name);
waitUnregistered(objectName);
assert (!getConnection().isRegistered(objectName));
waitProxyGone(factory, objectName);
assert (getProgeny(name) == null);
listener.waitNotifs();
printElapsed("testCreateRemove: created/remove/listen for: " + progenyJ2EEType, start);
}
Aggregations