You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2024/02/27 11:13:19 UTC
(jackrabbit-oak) branch OAK-10673 created (now 8015608230)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch OAK-10673
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 8015608230 OAK-10673: DocumentStore: add test for checking of removal on non-existing map entries
This branch includes the following new commits:
new 8015608230 OAK-10673: DocumentStore: add test for checking of removal on non-existing map entries
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-10673: DocumentStore: add test for checking of removal on non-existing map entries
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-10673
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 8015608230e725eac87db3b01bb7b952e61fbe80
Author: Julian Reschke <re...@apache.org>
AuthorDate: Tue Feb 27 12:13:03 2024 +0100
OAK-10673: DocumentStore: add test for checking of removal on non-existing map entries
---
.../plugins/document/BasicDocumentStoreTest.java | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
index b21504df57..c34ad7ff54 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
@@ -908,6 +908,66 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
}
}
+ // see OAK-10673
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDeleteNonExistingMapEntry() {
+ String id = this.getClass().getName() + ".testDeleteNonExistingMapEntry-" + UUID.randomUUID();
+ String propname = ":childOrder";
+
+ UpdateOp up = new UpdateOp(id, true);
+ assertTrue(super.ds.create(Collection.NODES, Collections.singletonList(up)));
+ removeMe.add(id);
+
+ long ts = System.currentTimeMillis();
+ Revision r1 = new Revision(ts, 0, 1);
+
+ // set initial value of :childOrder
+ UpdateOp op1 = new UpdateOp(id, false);
+ op1.setMapEntry(propname, r1, "foo");
+ Document d0 = super.ds.findAndUpdate(Collection.NODES, op1);
+ assertNotNull(d0);
+ assertNull(d0.get(propname));
+
+ // set new value, remove previous one
+ Revision r2 = new Revision(ts, 2, 1);
+ UpdateOp op2 = new UpdateOp(id, false);
+ op2.removeMapEntry(propname, r1);
+ op2.setMapEntry(propname, r2, "bar");
+ Document d1 = super.ds.findAndUpdate(Collection.NODES, op2);
+
+ // check previous state, map should only contain entry for r1 -> "foo"
+ assertNotNull(d1);
+ assertNotNull(d1.get(propname));
+ Map<Revision, String> mresulting1 = (Map<Revision, String>)d1.get(propname);
+ assertEquals(propname + " + map should contain one entry", 1, mresulting1.size());
+ assertEquals("foo", mresulting1.get(r1));
+
+ // set new value, remove all previous
+ Revision r3 = new Revision(ts, 3, 1);
+ UpdateOp op3 = new UpdateOp(id, false);
+ // attempts to remove non-existing revision (r1) should not fail
+ op3.removeMapEntry(propname, r1);
+ op3.removeMapEntry(propname, r2);
+ op3.setMapEntry(propname, r3, "qux");
+ Document d2 = super.ds.findAndUpdate(Collection.NODES, op3);
+
+ // check previous state, map should only contain entry for r2 -> "bar"
+ assertNotNull(d2);
+ assertNotNull(d2.get(propname));
+ Map<Revision, String> mresulting2 = (Map<Revision, String>)d2.get(propname);
+ assertEquals(propname + " + map should contain one entry", 1, mresulting2.size());
+ assertEquals("bar", mresulting2.get(r2));
+
+ // get final state, map should only contain entry for r3 -> "qux"
+ Document d3 = ds.find(Collection.NODES, id, -1);
+ assertNotNull(d3);
+ assertNotNull(d3.get(propname));
+ Map<Revision, String> mresulting3 = (Map<Revision, String>)d3.get(propname);
+ assertEquals(propname + " + map should contain one entry", 1, mresulting3.size());
+ assertEquals("on " + super.dsname + ", got: " + mresulting3, "qux", mresulting3.get(r3));
+ }
+
@Test
public void testDeleteNonExisting() {
String id = this.getClass().getName() + ".testDeleteNonExisting-" + UUID.randomUUID();