}
@Test
public void testListenerIsNotified()
{
ServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc = new ServletContainerContextImpl();
WebAppRegistry registry = new WebAppRegistry();
//
container.register(scc);
// Add 2 web apps
scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
scc.registration.registerWebApp(new WebAppContextImpl("/bar"));
// Add listener
container.addWebAppListener(registry);
// Assert we received events during the registration
assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());
// Add a new web app
scc.registration.registerWebApp(new WebAppContextImpl("/juu"));
// Assert we now have 3 web apps
assertEquals(Tools.toSet("/foo", "/bar", "/juu"), registry.getKeys());
// Remove one web app
scc.registration.unregisterWebApp("/foo");
// Assert we have 2 web apps
assertEquals(Tools.toSet("/bar", "/juu"), registry.getKeys());
// Remove registration
container.removeWebAppListener(registry);
// Assert we receveived events during removal
assertEquals(Tools.toSet(), registry.getKeys());
// W Add a new web app