Search in sources :

Example 61 with PropertyState

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));
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 62 with PropertyState

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);
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 63 with PropertyState

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)));
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) InputStream(java.io.InputStream) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 64 with PropertyState

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));
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 65 with PropertyState

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));
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)404 Test (org.junit.Test)189 Tree (org.apache.jackrabbit.oak.api.Tree)138 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)49 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)45 Nonnull (javax.annotation.Nonnull)31 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)29 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)28 Blob (org.apache.jackrabbit.oak.api.Blob)21 ArrayList (java.util.ArrayList)20 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)17 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)16 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)13 CheckForNull (javax.annotation.CheckForNull)12 RepositoryException (javax.jcr.RepositoryException)10 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 Map (java.util.Map)9 Value (javax.jcr.Value)9