ClasspathResourceFactoryImpl cf = new ClasspathResourceFactoryImpl();
cf.setClassResolver(cr);
i.setClasspathResourceFactory(cf);
HttpServlet servlet = new ServletFixture();
MockControl configControl = newControl(ServletConfig.class);
ServletConfig config = (ServletConfig) configControl.getMock();
trainForServletInit(configControl, config);
config.getInitParameter(ApplicationSpecificationInitializer.APP_SPEC_PATH_PARAM);
configControl.setReturnValue(null);
config.getServletContext();
configControl.setReturnValue(context);
config.getServletName();
configControl.setReturnValue("barney");
log.isDebugEnabled();
logControl.setReturnValue(false);
Resource r = new ContextResource(context, "/WEB-INF/barney.application");
context.getResource("/WEB-INF/barney/barney.application");
contextControl.setReturnValue(null);
log.isDebugEnabled();
logControl.setReturnValue(false);
context.getResource(r.getPath());
contextControl.setReturnValue(new URL("file:/context" + r.getPath()));
log.debug("Found " + r);
IApplicationSpecification as = new ApplicationSpecification();
MockControl parserControl = newControl(ISpecificationParser.class);
ISpecificationParser parser = (ISpecificationParser) parserControl.getMock();
i.setParser(parser);
parser.parseApplicationSpecification(r);
parserControl.setReturnValue(as);
ApplicationGlobals ag = new ApplicationGlobalsImpl();
i.setGlobals(ag);
replayControls();
servlet.init(config);
// The real ApplicationServlet will build a Registry and, indirectly, invoke this.
i.initialize(servlet);