Search in sources :

Example 6 with Management

use of javax.management.j2ee.Management in project wildfly by wildfly.

the class Jsr77TestCase method testJSR77Availabilty.

/**
 * Test for simple MBean functionality
 *
 * Catches NamingException if a naming exception is encountered in lookup() method.
 * Catches CreateException Indicates a failure to create the EJB object in create() method.
 * Catches RemoteException A communication exception occurred during the execution of a remote method call CreateException in create(), getDefaultDomain() or getMBeanCount() method.
 */
@Test
public void testJSR77Availabilty() {
    try {
        Context ic = new InitialContext();
        Object obj = ic.lookup("ejb/mgmt/MEJB");
        ManagementHome mejbHome = (ManagementHome) obj;
        final Management management = mejbHome.create();
        Assert.assertNotNull(management.getDefaultDomain());
        Assert.assertTrue(management.getMBeanCount() > 0);
    } catch (NamingException | CreateException | RemoteException ne) {
        Assert.fail(ne.getMessage());
    }
}
Also used : InitialContext(javax.naming.InitialContext) Context(javax.naming.Context) ManagementHome(javax.management.j2ee.ManagementHome) NamingException(javax.naming.NamingException) Management(javax.management.j2ee.Management) RemoteException(java.rmi.RemoteException) CreateException(javax.ejb.CreateException) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

Management (javax.management.j2ee.Management)6 ManagementHome (javax.management.j2ee.ManagementHome)4 InitialContext (javax.naming.InitialContext)3 PortableRemoteObject (javax.rmi.PortableRemoteObject)3 Context (javax.naming.Context)2 ProgrammaticLogin (com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin)1 String (java.lang.String)1 RemoteException (java.rmi.RemoteException)1 CreateException (javax.ejb.CreateException)1 AttributeList (javax.management.AttributeList)1 MBeanInfo (javax.management.MBeanInfo)1 ObjectName (javax.management.ObjectName)1 NamingException (javax.naming.NamingException)1 J2EEManagedObject (org.glassfish.admin.amx.j2ee.J2EEManagedObject)1 Test (org.junit.Test)1