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();
}
}
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));
}
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();
}
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())));
}
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);
}
Aggregations