Search in sources :

Example 16 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class TestHelper method getSearchManager.

public static SearchManager getSearchManager(Session session) throws NotExecutableException, RepositoryException {
    Repository r = session.getRepository();
    if (!(r instanceof RepositoryImpl)) {
        throw new NotExecutableException();
    }
    RepositoryImpl ri = (RepositoryImpl) r;
    return ri.getSearchManager(session.getWorkspace().getName());
}
Also used : Repository(javax.jcr.Repository) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 17 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class ConnectionFactoryTest method testExceptionHandling.

/**
     * Tests if a NoSuchWorkspaceException is thrown if a wrong workspace name is given to login
     */
public void testExceptionHandling() throws Exception {
    Object cf = mcf.createConnectionFactory();
    Repository repository = (Repository) cf;
    try {
        repository.login(JCR_SUPERUSER, "xxx");
    } catch (Exception e) {
        assertTrue(e instanceof NoSuchWorkspaceException);
    }
}
Also used : NoSuchWorkspaceException(javax.jcr.NoSuchWorkspaceException) Repository(javax.jcr.Repository) NoSuchWorkspaceException(javax.jcr.NoSuchWorkspaceException)

Example 18 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetSpi2davRepository.

public void testGetSpi2davRepository() throws RepositoryException {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("org.apache.jackrabbit.spi.RepositoryServiceFactory", "org.apache.jackrabbit.spi2dav.Spi2davRepositoryServiceFactory");
    parameters.put("org.apache.jackrabbit.spi2dav.uri", "http://localhost/");
    try {
        Repository repo = factory.getRepository(parameters);
        assertNotNull(repo);
    } catch (RepositoryException e) {
        // factory is working correctly, it is safe to ignore them.
        if (!(ConnectException.class.isInstance(e.getCause()) || DavException.class.isInstance(e.getCause()))) {
            throw e;
        }
    }
}
Also used : Repository(javax.jcr.Repository) HashMap(java.util.HashMap) RepositoryException(javax.jcr.RepositoryException)

Example 19 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetRepositoryWithLogger.

public void testGetRepositoryWithLogger() throws RepositoryException {
    List<Object> lwprovider = new ArrayList<Object>();
    lwprovider.add(null);
    lwprovider.add(true);
    lwprovider.add(new Slf4jLogWriterProvider());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("org.apache.jackrabbit.jcr2spi.RepositoryConfig", RepositoryConfigImpl.INSTANCE);
    for (Object aLwprovider : lwprovider) {
        params.put("org.apache.jackrabbit.spi.commons.logging.LogWriterProvider", aLwprovider);
        Repository repo = factory.getRepository(params);
        assertNotNull(repo);
    }
}
Also used : Repository(javax.jcr.Repository) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Slf4jLogWriterProvider(org.apache.jackrabbit.spi.commons.logging.Slf4jLogWriterProvider)

Example 20 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetRepositoryUnknownParams.

public void testGetRepositoryUnknownParams() throws RepositoryException {
    Repository repo = factory.getRepository(Collections.emptyMap());
    assertNull(repo);
}
Also used : Repository(javax.jcr.Repository)

Aggregations

Repository (javax.jcr.Repository)107 Session (javax.jcr.Session)31 RepositoryException (javax.jcr.RepositoryException)26 SimpleCredentials (javax.jcr.SimpleCredentials)15 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 Node (javax.jcr.Node)12 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)10 SlingRepository (org.apache.sling.jcr.api.SlingRepository)10 JackrabbitRepository (org.apache.jackrabbit.api.JackrabbitRepository)9 Oak (org.apache.jackrabbit.oak.Oak)7 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)7 IOException (java.io.IOException)6 Map (java.util.Map)6 InitialContext (javax.naming.InitialContext)6 NamingException (javax.naming.NamingException)6 ServletContext (javax.servlet.ServletContext)5 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)5 File (java.io.File)4 OutputStreamWriter (java.io.OutputStreamWriter)4