Search in sources :

Example 1 with ContentRepository

use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.

the class PrivilegeDefinitionWriterTest method testMissingPrivilegeRoot.

@Test
public void testMissingPrivilegeRoot() throws Exception {
    ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
    Root tmpRoot = repo.login(null, null).getLatestRoot();
    try {
        PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(tmpRoot);
        writer.writeDefinition(new ImmutablePrivilegeDefinition("newName", true, null));
        fail("missing privilege root");
    } catch (RepositoryException e) {
    // success
    } finally {
        tmpRoot.getContentSession().close();
    }
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) ImmutablePrivilegeDefinition(org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) RepositoryException(javax.jcr.RepositoryException) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 2 with ContentRepository

use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.

the class OakTest method closeAsyncIndexers.

@Test
public void closeAsyncIndexers() throws Exception {
    final AtomicReference<AsyncIndexUpdate> async = new AtomicReference<AsyncIndexUpdate>();
    Whiteboard wb = new DefaultWhiteboard() {

        @Override
        public <T> Registration register(Class<T> type, T service, Map<?, ?> properties) {
            if (service instanceof AsyncIndexUpdate) {
                async.set((AsyncIndexUpdate) service);
            }
            return super.register(type, service, properties);
        }
    };
    Oak oak = new Oak().with(new OpenSecurityProvider()).with(wb).withAsyncIndexing("foo-async", 5);
    ContentRepository repo = oak.createContentRepository();
    ((Closeable) repo).close();
    assertNotNull(async.get());
    assertTrue(async.get().isClosed());
    assertNull(WhiteboardUtils.getService(wb, AsyncIndexUpdate.class));
}
Also used : DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Closeable(java.io.Closeable) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) AsyncIndexUpdate(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Map(java.util.Map) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Test(org.junit.Test)

Example 3 with ContentRepository

use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.

the class OakTest method commitContextInCommitInfo.

@Test
public void commitContextInCommitInfo() throws Exception {
    CommitInfoCapturingStore store = new CommitInfoCapturingStore();
    Oak oak = new Oak(store);
    ContentRepository repo = oak.with(new OpenSecurityProvider()).createContentRepository();
    assertThat(store.infos, is(not(empty())));
    for (CommitInfo ci : store.infos) {
        assertNotNull(ci.getInfo().get(CommitContext.NAME));
    }
    ((Closeable) repo).close();
}
Also used : Closeable(java.io.Closeable) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) Test(org.junit.Test)

Example 4 with ContentRepository

use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.

the class ContentRemoteRepositoryTest method testSuccessfulLoginWithBasicCredentials.

@Test
public void testSuccessfulLoginWithBasicCredentials() throws Exception {
    ContentRepository repository = mock(ContentRepository.class);
    when(repository.login(any(Credentials.class), anyString())).thenReturn(mock(ContentSession.class));
    ContentRemoteRepository remoteRepository = createRepository(repository);
    assertNotNull(remoteRepository.login(remoteRepository.createBasicCredentials("admin", "admin".toCharArray())));
}
Also used : ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) RemoteCredentials(org.apache.jackrabbit.oak.remote.RemoteCredentials) Credentials(javax.jcr.Credentials) Test(org.junit.Test)

Example 5 with ContentRepository

use of org.apache.jackrabbit.oak.api.ContentRepository in project sling by apache.

the class RepositoryTestHelper method createOakRepository.

public static Repository createOakRepository(NodeStore nodeStore) {
    DefaultWhiteboard whiteboard = new DefaultWhiteboard();
    final Oak oak = new Oak(nodeStore).with(new InitialContent()).with(JcrConflictHandler.createJcrConflictHandler()).with(new EditorHook(new VersionEditorProvider())).with(new OpenSecurityProvider()).with(new NamespaceEditorProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(//getDefaultWorkspace())
    "default").with(whiteboard);
    //        if (commitRateLimiter != null) {
    //            oak.with(commitRateLimiter);
    //        }
    final ContentRepository contentRepository = oak.createContentRepository();
    return new RepositoryImpl(contentRepository, whiteboard, new OpenSecurityProvider(), 1000, null);
}
Also used : InitialContent(org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent) NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Oak(org.apache.jackrabbit.oak.Oak) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) VersionEditorProvider(org.apache.jackrabbit.oak.plugins.version.VersionEditorProvider) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)

Aggregations

ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)28 Test (org.junit.Test)23 Root (org.apache.jackrabbit.oak.api.Root)15 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)12 Oak (org.apache.jackrabbit.oak.Oak)9 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)8 ThreeWayConflictHandler (org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler)8 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)6 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)6 Closeable (java.io.Closeable)5 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)5 InitialContent (org.apache.jackrabbit.oak.InitialContent)5 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)4 Tree (org.apache.jackrabbit.oak.api.Tree)3 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)3 TypeEditorProvider (org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)3 HashMap (java.util.HashMap)2 Credentials (javax.jcr.Credentials)2 SimpleCredentials (javax.jcr.SimpleCredentials)2