public void testWorkQueueInstrumentation() throws Exception {
assertTrue("Instrumentation Manager should not be null", im != null);
//im.getAllInstrumentation();
WorkQueueManagerImpl wqm = new WorkQueueManagerImpl();
wqm.setBus(bus);
EventProcessor ep = bus.getExtension(EventProcessor.class);
QName eventID = new QName(ComponentEventFilter.COMPONENT_CREATED_EVENT);
if (null != ep) {
ep.sendEvent(new Event(wqm, eventID));
}
//NOTE: now the bus WorkQueueManager is lazy load , if WorkQueueManager
//create with bus , this test could be failed.
List<Instrumentation> list = im.getAllInstrumentation();
//NOTE: change for the BindingManager and TransportFactoryManager instrumentation
// create with the bus.
assertEquals("Too many instrumented items", 1, list.size());
Instrumentation it1 = list.get(0);
//Instrumentation it2 = list.get(3);
assertTrue("Item 1 not a WorkQueueInstrumentation",
WorkQueueInstrumentation.class.isAssignableFrom(it1.getClass()));
// not check for the instrumentation unique name
// sleep for the MBServer connector thread startup
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// do nothing
}
eventID = new QName(ComponentEventFilter.COMPONENT_REMOVED_EVENT);
if (null != ep) {
ep.sendEvent(new Event(wqm, eventID));
}
assertEquals("Instrumented stuff not removed from list", 0, list.size());
bus.shutdown(true);
assertEquals("Instrumented stuff not removed from list", 0, list.size());
}