TapestryApplicationContext extends XmlWebApplicationContext { @Override protected DefaultListableBeanFactory createBeanFactory() { Registry registry = (Registry) getServletContext().getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME); if (registry == null) throw new IllegalStateException( "Expected a Tapestry IoC Registry to be stored in the ServletContext, but the attribute was null."); return new TapestryBeanFactory(getInternalParentBeanFactory(), registry); }    }
@Test public void no_registry_in_servlet_context() { ServletContext context = mockServletContext(); train_getAttribute(context, TapestryFilter.REGISTRY_CONTEXT_NAME, null); replay(); TapestryApplicationContext tac = new TapestryApplicationContext(); tac.setServletContext(context); try { tac.createBeanFactory(); unreachable(); } catch (IllegalStateException ex) { } verify(); }