/**
* Two listeners, one MBean, two ObjectNames
*/
public void testAddUnregister4() throws Exception
{
NotificationListenerMBeanServerInterceptor interceptor = new NotificationListenerMBeanServerInterceptor();
interceptor.setEnabled(true);
List chain = new ArrayList();
chain.add(interceptor);
chain.add(new NoOpMBeanServerInterceptor());
interceptor.setChain(chain);
MBeanMetaData metadata1 = new NotificationListenerMBeanMetaData(this, ObjectName.getInstance(":type=test1"));
MBeanMetaData metadata2 = new NotificationListenerMBeanMetaData(this, ObjectName.getInstance(":type=test2"));
NotificationListener listener1 = new NotificationListener()
{
public void handleNotification(Notification notification, Object handback)
{
}
};
NotificationListener listener2 = new NotificationListener()
{
public void handleNotification(Notification notification, Object handback)
{
}
};
interceptor.addNotificationListener(metadata1, listener1, null, null);
interceptor.addNotificationListener(metadata2, listener2, null, null);
interceptor.registration(metadata1, MBeanServerInterceptor.POST_DEREGISTER);
assertEquals(1, interceptor.getNotificationListenerWrappers().size());
assertEquals(1, interceptor.getObjectNames().size());
interceptor.registration(metadata2, MBeanServerInterceptor.POST_DEREGISTER);
assertEquals(0, interceptor.getNotificationListenerWrappers().size());
assertEquals(0, interceptor.getObjectNames().size());
}