private Object param(final Class<?> c) { if (SessionScoped.class == c) { return new MockHttpSession(); } return null; } }
@SuppressWarnings("unchecked") public void before(final Object inputTestInstance) throws Exception { fixFakeClassFinder(inputTestInstance); startContainer(inputTestInstance); servletContext = new MockServletContext(); session = new MockHttpSession(); deployApp(inputTestInstance); }
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 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 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); } }
@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()); }
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 HttpSession appSession = new MockHttpSession();
session = new MockHttpSession();