@Override public Session getSession() throws Exception { StandaloneContainer container = StandaloneContainer.getInstance(); RepositoryService repositoryServices = (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class); Repository repository = repositoryServices.getDefaultRepository(); Credentials credentials = new CredentialsImpl("__system", "admin".toCharArray()); Session session = repository.login(credentials, "ws"); return session; }
@Override public void doPrepare(TestCase tc, JCRTestContext context) throws Exception { super.doPrepare(tc, context); container = StandaloneContainer.getInstance(); registryService = (RegistryService) container.getComponentInstanceOfType(RegistryService.class); sessionProvider = new SessionProvider(ConversationState.getCurrent()); // fill class field sumIterations with adequate number if ((tc.hasParam("japex.runIterations")) && (tc.getIntParam("japex.runIterations") > 0)) { sumIterations += tc.getIntParam("japex.runIterations"); } if ((tc.hasParam("japex.warmupIterations")) && (tc.getIntParam("japex.warmupIterations") > 0)) { sumIterations += tc.getIntParam("japex.warmupIterations"); } // create content. May be overridden in child class with stub method to // avoid any preparation. createContent(tc, context); }
private static void initJCR() { try { repositoryService = (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class); // Initialize datas Session session = repositoryService.getRepository(REPO_NAME).getSystemSession(KNOWLEDGE_WS); root_ = session.getRootNode(); sessionProviderService = (SessionProviderService) container.getComponentInstanceOfType(SessionProviderService.class); JCRSessionManager sessionManager = new JCRSessionManager(KNOWLEDGE_WS, repositoryService); KSDataLocation ksDataLocation = (KSDataLocation) container.getComponentInstanceOfType(KSDataLocation.class); ksDataLocation.setSessionManager(sessionManager); } catch (Exception e) { throw new RuntimeException("Failed to initialize JCR: ", e); } }
private static void initContainer() { try { ExoContainer container_ = RootContainer.getInstance(); if (container_ != null) { container_.stop(); container_.dispose(); } String containerConf = ForumServiceTestCase.class.getResource("/conf/portal/configuration.xml").toString(); StandaloneContainer.addConfigurationURL(containerConf); container = StandaloneContainer.getInstance(); String loginConf = Thread.currentThread() .getContextClassLoader() .getResource("conf/portal/login.conf") .toString(); if (System.getProperty("java.security.auth.login.config") == null) System.setProperty("java.security.auth.login.config", loginConf); ExoContainerContext.setCurrentContainer(container); } catch (Exception e) { log.error("Failed to initialize standalone container: ", e); } }