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;
}
Aggregations