use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class DefaultConflictHandlerOursTest method testChangeDeletedProperty.
@Test
public void testChangeDeletedProperty() throws CommitFailedException {
theirRoot.getTree("/").removeProperty("a");
ourRoot.getTree("/").setProperty("a", OUR_VALUE);
theirRoot.commit();
ourRoot.commit();
PropertyState p = ourRoot.getTree("/").getProperty("a");
assertNotNull(p);
assertEquals(OUR_VALUE, p.getValue(STRING));
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class DefaultConflictHandlerOursTest method testDeleteChangedProperty.
@Test
public void testDeleteChangedProperty() throws CommitFailedException {
theirRoot.getTree("/").setProperty("a", THEIR_VALUE);
ourRoot.getTree("/").removeProperty("a");
theirRoot.commit();
ourRoot.commit();
PropertyState p = ourRoot.getTree("/").getProperty("a");
assertNull(p);
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class VersionGCQueryTest method queryDeepPreviousDocs.
@Test
public void queryDeepPreviousDocs() throws Exception {
// create garbage until we have intermediate previous docs
NodeBuilder builder = ns.getRoot().builder();
builder.child("test");
merge(builder);
String id = Utils.getIdFromPath("/test");
while (!Iterables.any(store.find(Collection.NODES, id).getPreviousRanges().values(), INTERMEDIATE)) {
InputStream s = new RandomStream(10 * 1024, 42);
PropertyState p = new BinaryPropertyState("p", ns.createBlob(s));
builder = ns.getRoot().builder();
builder.child("test").setProperty(p);
merge(builder);
builder = ns.getRoot().builder();
builder.child("test").remove();
merge(builder);
ns.runBackgroundOperations();
}
int numPrevDocs = Iterators.size(store.find(Collection.NODES, id).getAllPreviousDocs());
assertEquals(1, Iterators.size(Utils.getRootDocument(store).getAllPreviousDocs()));
clock.waitUntil(clock.getTime() + TimeUnit.HOURS.toMillis(1));
VersionGarbageCollector gc = new VersionGarbageCollector(ns, new VersionGCSupport(store));
prevDocIds.clear();
VersionGCStats stats = gc.gc(30, TimeUnit.MINUTES);
assertEquals(1, stats.deletedDocGCCount);
// GC also cleans up the previous doc on root
assertEquals(numPrevDocs + 1, stats.splitDocGCCount);
// but only does find calls for previous docs of /test
assertEquals(numPrevDocs, prevDocIds.size());
// at the end only the root document remains
assertEquals(1, Iterables.size(Utils.getAllDocuments(store)));
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class SimpleTest method addNodeGetNode.
@Test
public void addNodeGetNode() {
DocumentMK mk = builderProvider.newBuilder().open();
DocumentStore s = mk.getDocumentStore();
DocumentNodeStore ns = mk.getNodeStore();
RevisionVector rev = RevisionVector.fromString(mk.getHeadRevision());
DocumentNodeState n = new DocumentNodeState(ns, "/test", rev, Collections.singleton(ns.createPropertyState("name", "\"Hello\"")), false, null);
UpdateOp op = n.asOperation(rev.getRevision(ns.getClusterId()));
// mark as commit root
NodeDocument.setRevision(op, rev.getRevision(ns.getClusterId()), "c");
assertTrue(s.create(Collection.NODES, Lists.newArrayList(op)));
DocumentNodeState n2 = ns.getNode("/test", rev);
assertNotNull(n2);
PropertyState p = n2.getProperty("name");
assertNotNull(p);
assertEquals("Hello", p.getValue(Type.STRING));
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class TreeUtilTest method testJcrLastModifiedBy.
@Test
public void testJcrLastModifiedBy() throws Exception {
Tree ntRoot = root.getTree(NodeTypeConstants.NODE_TYPES_PATH);
Tree tree = TreeUtil.addChild(root.getTree("/"), "test", NodeTypeConstants.NT_OAK_UNSTRUCTURED, ntRoot, "userId");
TreeUtil.addMixin(tree, NodeTypeConstants.MIX_LASTMODIFIED, ntRoot, "userId");
PropertyState ps = tree.getProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY);
assertNotNull(ps);
assertEquals("userId", ps.getValue(Type.STRING));
}
Aggregations