use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class ThreeWayConflictHandlerTest method deleteChangedProperty.
@Test
public void deleteChangedProperty() throws Exception {
AtomicBoolean called = new AtomicBoolean(false);
ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {
@Override
public Resolution deleteChangedProperty(NodeBuilder parent, PropertyState theirs, PropertyState base) {
called.set(true);
assertEquals("theirs", theirs.getValue(STRING));
assertEquals("base", base.getValue(STRING));
return Resolution.IGNORED;
}
};
ContentRepository repo = newRepo(handler);
Root root = login(repo);
setup(root);
Root ourRoot = login(repo);
Root theirRoot = login(repo);
theirRoot.getTree("/c").setProperty("p", "theirs");
ourRoot.getTree("/c").removeProperty("p");
theirRoot.commit();
ourRoot.commit();
assertTrue(called.get());
}
use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class OakTest method checkExecutorShutdown.
@Test
public void checkExecutorShutdown() throws Exception {
Runnable runnable = new Runnable() {
@Override
public void run() {
}
};
Oak oak = new Oak().with(new OpenSecurityProvider());
ContentRepository repo = oak.createContentRepository();
WhiteboardUtils.scheduleWithFixedDelay(oak.getWhiteboard(), runnable, 1);
((Closeable) repo).close();
try {
WhiteboardUtils.scheduleWithFixedDelay(oak.getWhiteboard(), runnable, 1);
fail("Executor should have rejected the task");
} catch (RejectedExecutionException ignore) {
}
// Externally passed executor should not be shutdown upon repository close
ScheduledExecutorService externalExecutor = Executors.newSingleThreadScheduledExecutor();
Oak oak2 = new Oak().with(new OpenSecurityProvider()).with(externalExecutor);
ContentRepository repo2 = oak2.createContentRepository();
WhiteboardUtils.scheduleWithFixedDelay(oak2.getWhiteboard(), runnable, 1);
((Closeable) repo2).close();
WhiteboardUtils.scheduleWithFixedDelay(oak2.getWhiteboard(), runnable, 1);
externalExecutor.shutdown();
}
use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class HttpServer method addServlets.
private void addServlets(Oak oak, String path) {
Jcr jcr = new Jcr(oak);
// 1 - OakServer
ContentRepository repository = jcr.createContentRepository();
ServletHolder holder = new ServletHolder(new OakServlet(repository));
context.addServlet(holder, path + "/*");
// 2 - Webdav Server on JCR repository
final Repository jcrRepository = jcr.createRepository();
@SuppressWarnings("serial") ServletHolder webdav = new ServletHolder(new SimpleWebdavServlet() {
@Override
public Repository getRepository() {
return jcrRepository;
}
});
webdav.setInitParameter(SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path + "/webdav");
webdav.setInitParameter(AbstractWebdavServlet.INIT_PARAM_AUTHENTICATE_HEADER, "Basic realm=\"Oak\"");
context.addServlet(webdav, path + "/webdav/*");
// 3 - JCR Remoting Server
@SuppressWarnings("serial") ServletHolder jcrremote = new ServletHolder(new JcrRemotingServlet() {
@Override
protected Repository getRepository() {
return jcrRepository;
}
});
jcrremote.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path + "/jcrremote");
jcrremote.setInitParameter(AbstractWebdavServlet.INIT_PARAM_AUTHENTICATE_HEADER, "Basic realm=\"Oak\"");
context.addServlet(jcrremote, path + "/jcrremote/*");
}
Aggregations