Search in sources :

Example 1 with StatisticsMBean

use of org.apache.sling.event.jobs.jmx.StatisticsMBean in project sling by apache.

the class QueuesMBeanImplTest method addQueue.

public Queue addQueue() {
    Queue queue = Mockito.mock(Queue.class, Mockito.withSettings().extraInterfaces(Statistics.class));
    mockStatistics((Statistics) queue);
    Mockito.when(queue.getName()).thenReturn("queue-name");
    Mockito.when(bundleContext.registerService(Mockito.anyString(), Mockito.any(StatisticsMBean.class), Mockito.any(Dictionary.class))).thenReturn(serviceRegistration);
    mbean.sendEvent(new QueueStatusEvent(queue, null));
    Mockito.verify(bundleContext, Mockito.only()).registerService(serviceClass.capture(), serviceObject.capture(), serviceProperties.capture());
    Assert.assertEquals("Expected bean to be registerd as a StatisticsMBean ", StatisticsMBean.class.getName(), serviceClass.getValue());
    Assert.assertTrue("Expected service to be an instance of SatisticsMBean", serviceObject.getValue() instanceof StatisticsMBean);
    Assert.assertNotNull("Expected properties to have a jmx.objectname", serviceProperties.getValue().get("jmx.objectname"));
    testStatistics((StatisticsMBean) serviceObject.getValue());
    return queue;
}
Also used : Dictionary(java.util.Dictionary) StatisticsMBean(org.apache.sling.event.jobs.jmx.StatisticsMBean) Queue(org.apache.sling.event.jobs.Queue) Statistics(org.apache.sling.event.jobs.Statistics)

Aggregations

Dictionary (java.util.Dictionary)1 Queue (org.apache.sling.event.jobs.Queue)1 Statistics (org.apache.sling.event.jobs.Statistics)1 StatisticsMBean (org.apache.sling.event.jobs.jmx.StatisticsMBean)1