Search in sources :

Example 11 with JMRuntimeException

use of javax.management.JMRuntimeException in project wildfly-core by wildfly.

the class JmxRBACProviderHostScopedRolesTestCase method doOperation.

private void doOperation(boolean successExpected, String objectName, String operationName, JmxManagementInterface jmx) throws Exception {
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName(objectName);
    try {
        connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
        assertTrue("Failure was expected but success happened", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName)

Example 12 with JMRuntimeException

use of javax.management.JMRuntimeException in project wildfly-core by wildfly.

the class JmxRBACProviderServerGroupScopedRolesTestCase method setAttribute.

private void setAttribute(String userName, JmxManagementInterface jmx) throws Exception {
    boolean successExpected = isWriteAllowed(userName);
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("java.lang:type=Memory");
    try {
        connection.setAttribute(domain, new Attribute("Verbose", true));
        // back to default to not pollute the logs
        connection.setAttribute(domain, new Attribute("Verbose", false));
        assertTrue("Failure was expected", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
Also used : Attribute(javax.management.Attribute) JMRuntimeException(javax.management.JMRuntimeException) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName)

Example 13 with JMRuntimeException

use of javax.management.JMRuntimeException in project wildfly-core by wildfly.

the class JmxRBACProviderServerGroupScopedRolesTestCase method doOperation.

private void doOperation(boolean successExpected, String objectName, String operationName, JmxManagementInterface jmx) throws Exception {
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName(objectName);
    try {
        connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
        assertTrue("Failure was expected but success happened", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName)

Example 14 with JMRuntimeException

use of javax.management.JMRuntimeException in project wildfly-core by wildfly.

the class AbstractJmxNonCoreMBeansSensitivityTestCase method setAttribute.

private void setAttribute(String userName, JmxManagementInterface jmx) throws Exception {
    boolean successExpected = isWriteAllowed(userName);
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("java.lang:type=Memory");
    try {
        connection.setAttribute(domain, new Attribute("Verbose", true));
        // back to default to not pollute the logs
        connection.setAttribute(domain, new Attribute("Verbose", false));
        assertTrue("Failure was expected", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
Also used : Attribute(javax.management.Attribute) JMRuntimeException(javax.management.JMRuntimeException) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName)

Example 15 with JMRuntimeException

use of javax.management.JMRuntimeException in project wildfly-core by wildfly.

the class JmxManagementInterface method getAttribute.

private ModelNode getAttribute(ObjectName objectName, String name) {
    MBeanServerConnection connection = getConnection();
    Object result = null;
    JMRuntimeException exception = null;
    try {
        result = connection.getAttribute(objectName, name);
    } catch (JMRuntimeException e) {
        exception = e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return modelNodeResult(result, exception);
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) JMRuntimeException(javax.management.JMRuntimeException) MBeanServerConnection(javax.management.MBeanServerConnection) JMRuntimeException(javax.management.JMRuntimeException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException) JMException(javax.management.JMException)

Aggregations

JMRuntimeException (javax.management.JMRuntimeException)39 ObjectName (javax.management.ObjectName)18 MBeanServerConnection (javax.management.MBeanServerConnection)13 Attribute (javax.management.Attribute)11 InstanceNotFoundException (javax.management.InstanceNotFoundException)10 MalformedObjectNameException (javax.management.MalformedObjectNameException)8 MBeanInfo (javax.management.MBeanInfo)7 IOException (java.io.IOException)6 JMException (javax.management.JMException)6 OperationFailedException (org.jboss.as.controller.OperationFailedException)6 RealmUnavailableException (org.wildfly.security.auth.server.RealmUnavailableException)6 AttributeList (javax.management.AttributeList)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)5 DynamicMBean (javax.management.DynamicMBean)5 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)5 MBeanException (javax.management.MBeanException)5 ReflectionException (javax.management.ReflectionException)5 RuntimeErrorException (javax.management.RuntimeErrorException)5 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 MBeanRegistrationException (javax.management.MBeanRegistrationException)4