/**
   * Check that for two different repositories we get the connections from two different pools. If
   * not, TransactionCachingInterceptor will return a session from the first repository when asked
   * for a new session for the second repository.
   */
  @Test
  public void testMultipleRepositoriesPerTransaction() throws Exception {
    // config for second repo available only for H2
    assumeTrue("Test only works with H2", database.isVCSH2());

    DatabaseH2 db = (DatabaseH2) DatabaseHelper.DATABASE;
    db.setUp2();
    deployContrib(
        "org.nuxeo.ecm.core.storage.sql.test", "OSGI-INF/test-pooling-h2-repo2-contrib.xml");
    // open a second repository
    try (CoreSession session2 =
        CoreInstance.openCoreSession(
            database.getRepositoryName() + "2", SecurityConstants.ADMINISTRATOR)) {
      doTestMultipleRepositoriesPerTransaction(session2);
    }
  }
示例#2
0
 protected CoreSession getRestrictedSession(String userName) {
   RepositoryManager rm = Framework.getLocalService(RepositoryManager.class);
   Map<String, Serializable> ctx = new HashMap<>();
   ctx.put("principal", new UserPrincipal(userName, null, false, false));
   return CoreInstance.openCoreSession(rm.getDefaultRepositoryName(), ctx);
 }
 public CoreSession openSessionAs(NuxeoPrincipal principal) throws ClientException {
   return CoreInstance.openCoreSession(repositoryName, principal);
 }
 public CoreSession openSessionAs(String username) throws ClientException {
   return CoreInstance.openCoreSession(repositoryName, username);
 }
 protected CoreSession openSessionAs(String username) {
   return CoreInstance.openCoreSession(session.getRepositoryName(), username);
 }