use of javax.management.MBeanServerConnection in project wildfly by wildfly.
the class DependsTestCase method testMBean.
@Test
@SuppressWarnings("unchecked")
public void testMBean() throws Exception {
final MBeanServerConnection mbeanServer = JMXConnectorFactory.connect(managementClient.getRemoteJMXURL(), DefaultConfiguration.credentials()).getMBeanServerConnection();
final ObjectName a1ObjectName = new ObjectName("test:service=A1");
final ObjectName aObjectName = (ObjectName) mbeanServer.getAttribute(a1ObjectName, "ObjectName");
Assert.assertTrue(aObjectName.equals(new ObjectName("test:service=A")));
final ObjectName bObjectName = new ObjectName("test:service=B");
final List<ObjectName> objectNames = (List<ObjectName>) mbeanServer.getAttribute(bObjectName, "ObjectNames");
Assert.assertTrue(objectNames.contains(new ObjectName("test:service=A")));
Assert.assertTrue(objectNames.contains(new ObjectName("test:service=A1")));
}
use of javax.management.MBeanServerConnection in project wildfly by wildfly.
the class SarResourceInjectionTestCase method testMBean.
@Test
public void testMBean() throws Exception {
final JMXConnector connector = JMXConnectorFactory.connect(managementClient.getRemoteJMXURL(), DefaultConfiguration.credentials());
try {
final MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();
final ObjectName objectName = new ObjectName("jboss:name=X");
Assert.assertTrue((Boolean) mbeanServer.invoke(objectName, "resourcesInjected", null, null));
} finally {
IoUtils.safeClose(connector);
}
}
use of javax.management.MBeanServerConnection in project wildfly by wildfly.
the class SarValueFactoryInjectionTestCase method testMBean.
@Test
public void testMBean() throws Exception {
final JMXConnector connector = JMXConnectorFactory.connect(managementClient.getRemoteJMXURL());
try {
final MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();
final ObjectName objectName = new ObjectName("jboss:name=TargetBean");
Assert.assertEquals("Injection using value-factory without method arguments failed", 2, ((Integer) mbeanServer.getAttribute(objectName, "SourceCount")).intValue());
Assert.assertEquals("Injection using value-factory with method argument failed", 4, ((Integer) mbeanServer.getAttribute(objectName, "CountWithArgument")).intValue());
} finally {
IoUtils.safeClose(connector);
}
}
use of javax.management.MBeanServerConnection in project wildfly by wildfly.
the class SarTestCase method testMBean.
@Test
public void testMBean() throws Exception {
final JMXConnector connector = JMXConnectorFactory.connect(managementClient.getRemoteJMXURL());
try {
MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();
ObjectName objectName = new ObjectName("jboss:name=test,type=config");
mbeanServer.getAttribute(objectName, "IntervalSeconds");
mbeanServer.setAttribute(objectName, new Attribute("IntervalSeconds", 2));
} finally {
IoUtils.safeClose(connector);
}
}
use of javax.management.MBeanServerConnection in project Activiti by Activiti.
the class JobExecutorJMXClientTest method testJobExecutorJMXClient.
@Test
public void testJobExecutorJMXClient() throws InterruptedException, IOException, MalformedObjectNameException, AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException {
String hostName = Utils.getHostName();
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/activiti");
ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
processEngineConfig.buildProcessEngine();
// wait for jmx server to come up
Thread.sleep(500);
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
ObjectName jobExecutorBeanName = new ObjectName("org.activiti.jmx.Mbeans:type=JobExecutor");
processEngineConfig.getJobExecutor().shutdown();
// first check that job executor is not activated and correctly reported as being inactive
assertFalse(processEngineConfig.isJobExecutorActivate());
assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
// now activate it remotely
mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[] { true }, new String[] { Boolean.class.getName() });
// check if it has the effect and correctly reported
// assertTrue(processEngineConfig.getJobExecutor().isActive());
assertTrue((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
//agani disable and check it
mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[] { false }, new String[] { Boolean.class.getName() });
// check if it has the effect and correctly reported
assertFalse(processEngineConfig.isJobExecutorActivate());
assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
}
Aggregations