Search in sources :

Example 1 with CreateRemoveListener

use of org.glassfish.admin.amxtest.support.CreateRemoveListener 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);
}
Also used : Container(com.sun.appserv.management.base.Container) ProxyFactory(com.sun.appserv.management.client.ProxyFactory) AMXConfig(com.sun.appserv.management.config.AMXConfig) CreateRemoveListener(org.glassfish.admin.amxtest.support.CreateRemoveListener) ObjectName(javax.management.ObjectName)

Aggregations

Container (com.sun.appserv.management.base.Container)1 ProxyFactory (com.sun.appserv.management.client.ProxyFactory)1 AMXConfig (com.sun.appserv.management.config.AMXConfig)1 ObjectName (javax.management.ObjectName)1 CreateRemoveListener (org.glassfish.admin.amxtest.support.CreateRemoveListener)1