private Object param(final Class<?> c) { if (SessionScoped.class == c) { return new MockHttpSession(); } return null; } }
public MockServletContextEvent() { super(new MockServletContext()); }
@Override public void beforeStartApplication(Object object) { this.mockHttpSession = new MockHttpSession(); this.servletContextEvent = new MockServletContextEvent(); WebBeansContext webBeansContext = getWebBeansContext(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(RequestScoped.class, null); contextsService.startContext(SessionScoped.class, mockHttpSession); contextsService.startContext(ConversationScoped.class, null); contextsService.startContext(ApplicationScoped.class, this.servletContextEvent.getServletContext()); }
@SuppressWarnings("unchecked") public void before(final Object inputTestInstance) throws Exception { fixFakeClassFinder(inputTestInstance); startContainer(inputTestInstance); servletContext = new MockServletContext(); session = new MockHttpSession(); deployApp(inputTestInstance); }
final ServletContextEvent sce = new MockServletContextEvent(); servletContextEvents.put(webAppInfo, sce);
@Override public void beforeStopApplication(Object endObject) { WebBeansContext webBeansContext = getWebBeansContext(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.endContext(RequestScoped.class, null); contextsService.endContext(SessionScoped.class, this.mockHttpSession); contextsService.endContext(ConversationScoped.class, null); contextsService.endContext(ApplicationScoped.class, this.servletContextEvent.getServletContext()); //Comment out for OWB-502 //ContextFactory.cleanUpContextFactory(); // clean up the EL caches after each request ELContextStore elStore = ELContextStore.getInstance(false); if (elStore != null) { elStore.destroyELContextStore(); } }
@Override public URL getResource(final String path) throws MalformedURLException { if (resourceProviders.isEmpty()) { return super.getResource(path); } for (final ResourceProvider provider : resourceProviders) { final URL resource = provider.getResource(path); if (resource != null) { return resource; } } return super.getResource(path); }
@Override public InputStream getResourceAsStream(final String path) { if (resourceProviders.isEmpty()) { return super.getResourceAsStream(path); } for (final ResourceProvider provider : resourceProviders) { final URL resource = provider.getResource(path); if (resource != null) { try { return resource.openStream(); } catch (final IOException e) { // no-op } } } return super.getResourceAsStream(path); }
private OpenEjbContainer(final Map<?, ?> map, final AppContext appContext) { webBeanContext = appContext.getWebBeansContext(); globalJndiContext = new GlobalContext(appContext.getGlobalJndiContext()); final Properties properties = new Properties(); properties.putAll(map); options = new Options(properties); startNetworkServices(); servletContext = new MockServletContext(); session = new MockHttpSession(); try { startContexts(webBeanContext.getContextsService(), servletContext, session); } catch (final Exception e) { logger().warning("can't start all CDI contexts", e); } }
private void startCdiContexts(final String name) { final WebBeansContext wbc = this.container.getAppContexts(name).getWebBeansContext(); if (wbc != null && wbc.getBeanManagerImpl().isInUse()) { final MockHttpSession session = new MockHttpSession(); wbc.getContextsService().startContext(RequestScoped.class, null); wbc.getContextsService().startContext(SessionScoped.class, session); wbc.getContextsService().startContext(ConversationScoped.class, null); SESSIONS.put(name, session); } }
final ServletContextEvent sce = component == null ? new MockServletContextEvent() : new ServletContextEvent(new LightServletContext(component, webContext.getClassLoader())); servletContextEvents.put(webAppInfo, sce);
private OpenEjbContainer(final Map<?, ?> map, final AppContext appContext) { webBeanContext = appContext.getWebBeansContext(); globalJndiContext = new GlobalContext(appContext.getGlobalJndiContext()); final Properties properties = new Properties(); properties.putAll(map); options = new Options(properties); startNetworkServices(); if (webBeanContext != null) { servletContext = new MockServletContext(); session = new MockHttpSession(); try { startContexts(webBeanContext.getContextsService(), servletContext, session); } catch (final Exception e) { logger().warning("can't start all CDI contexts", e); } } }
private void startCdiContexts(final String name) { final WebBeansContext wbc = this.container.getAppContexts(name).getWebBeansContext(); if (wbc.getBeanManagerImpl().isInUse()) { final MockHttpSession session = new MockHttpSession(); wbc.getContextsService().startContext(RequestScoped.class, null); wbc.getContextsService().startContext(SessionScoped.class, session); wbc.getContextsService().startContext(ConversationScoped.class, null); SESSIONS.put(name, session); } }
private DeploymentInfo quickDeploy(final Archive<?> archive, final TestClass testClass) throws DeploymentException { final String name = archive.getName(); DeploymentInfo info = DEPLOYMENT_INFO.get(name); if (info == null) { try { final AppModule module = OpenEJBArchiveProcessor.createModule(archive, testClass); final AppInfo appInfo = configurationFactory.configureApplication(module); final AppContext appCtx = assembler.createApplication(appInfo, module.getClassLoader()); final ServletContext appServletContext = new MockServletContext(); final HttpSession appSession = new MockHttpSession(); startContexts(appCtx.getWebBeansContext().getContextsService(), appServletContext, appSession); info = new DeploymentInfo(appServletContext, appSession, appInfo, appCtx); if (configuration.isSingleDeploymentByArchiveName(name)) { DEPLOYMENT_INFO.putIfAbsent(name, info); } } catch (final Exception e) { throw new DeploymentException("can't deploy " + name, e); } } return info; }
final ServletContext appServletContext = new MockServletContext(); final HttpSession appSession = new MockHttpSession();
servletContext = new MockServletContext(); session = new MockHttpSession();