{
fail("Could not found JSR-77 JavaMailResource'" + TEST_MAIL + "'");
}
ObjectName lMail = (ObjectName) names.iterator().next();
Listener lLocalListener = new Listener();
ListenerRegistration lListenerFactory = jsr77MEJB.getListenerRegistry();
getLog().debug("+++ testNotificationDeliver, add Notification Listener to " + TEST_MAIL +
" with Listener Registry: " + lListenerFactory);
lListenerFactory.addNotificationListener(
lMail,
lLocalListener,
null,
null
);
getLog().debug("+++ testNotificationDeliver, stop " + TEST_MAIL + "");
jsr77MEJB.invoke(lMail, "stop", new Object[]{}, new String[]{});
getLog().debug("+++ testNotificationDeliver, start " + TEST_MAIL + "");
jsr77MEJB.invoke(lMail, "start", new Object[]{}, new String[]{});
// Wait 5 seconds to ensure that the notifications are delivered
Thread.sleep(5000);
if (lLocalListener.getNumberOfNotifications() < 2)
{
fail("Not enough notifications received: " + lLocalListener.getNumberOfNotifications());
}
getLog().debug("+++ testNotificationDeliver, remove Notification Listener from " + TEST_MAIL + "");
lListenerFactory.removeNotificationListener(
lMail,
lLocalListener
);
jsr77MEJB.remove();
}