Search in sources :

Example 21 with QueryExp

use of javax.management.QueryExp in project sling by apache.

the class MetricServiceTest method jmxRegistration.

@Test
public void jmxRegistration() throws Exception {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    activate();
    Meter meter = service.meter("test");
    assertNotNull(meter);
    QueryExp q = Query.isInstanceOf(Query.value(JmxReporter.JmxMeterMBean.class.getName()));
    Set<ObjectName> names = server.queryNames(new ObjectName("org.apache.sling:name=*,type=" + JMX_TYPE_METRICS), q);
    assertThat(names, is(not(empty())));
    MockOsgi.deactivate(service, context.bundleContext());
    names = server.queryNames(new ObjectName("org.apache.sling:name=*"), q);
    assertThat(names, is(empty()));
}
Also used : Meter(org.apache.sling.commons.metrics.Meter) QueryExp(javax.management.QueryExp) JmxReporter(com.codahale.metrics.JmxReporter) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

QueryExp (javax.management.QueryExp)21 ObjectName (javax.management.ObjectName)18 MBeanServer (javax.management.MBeanServer)7 Test (org.junit.Test)5 AttributeValueExp (javax.management.AttributeValueExp)3 StringValueExp (javax.management.StringValueExp)3 UnitTest (org.apache.geode.test.junit.categories.UnitTest)3 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 MBeanException (javax.management.MBeanException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ObjectInstance (javax.management.ObjectInstance)2 ReflectionException (javax.management.ReflectionException)2 JMXConnector (javax.management.remote.JMXConnector)2 JMXServiceURL (javax.management.remote.JMXServiceURL)2 JmxReporter (com.codahale.metrics.JmxReporter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 URI (java.net.URI)1