@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;
  }
Exemplo n.º 2
0
  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);
    }
  }
 @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);
 }