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 mr...@apache.org on 2016/10/27 14:35:28 UTC
svn commit: r1766836 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java
Author: mreutegg
Date: Thu Oct 27 14:35:27 2016
New Revision: 1766836
URL: http://svn.apache.org/viewvc?rev=1766836&view=rev
Log:
OAK-5027: Test utils for commonly used functionality
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java (with props)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java?rev=1766836&r1=1766835&r2=1766836&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java Thu Oct 27 14:35:27 2016
@@ -1664,6 +1664,10 @@ public final class NodeDocument extends
return DELETED.equals(name);
}
+ public static boolean isLastRevEntry(String name) {
+ return LAST_REV.equals(name);
+ }
+
public static void removeRevision(@Nonnull UpdateOp op,
@Nonnull Revision revision) {
checkNotNull(op).removeMapEntry(REVISIONS, checkNotNull(revision));
Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java?rev=1766836&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java Thu Oct 27 14:35:27 2016
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.document;
+
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+import com.google.common.base.Predicate;
+
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
+import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+
+public class TestUtils {
+
+ public static final Predicate<UpdateOp> IS_LAST_REV_UPDATE = new Predicate<UpdateOp>() {
+ @Override
+ public boolean apply(@Nullable UpdateOp input) {
+ return input != null && isLastRevUpdate(input);
+ }
+ };
+
+ /**
+ * Returns {@code true} if the given {@code update} performs a
+ * {@code _lastRev} update.
+ *
+ * @param update the update to check.
+ * @return {@code true} if the operation performs an update on
+ * {@code _lastRev}, {@code false} otherwise.
+ */
+ public static boolean isLastRevUpdate(UpdateOp update) {
+ for (Map.Entry<UpdateOp.Key, UpdateOp.Operation> change : update.getChanges().entrySet()) {
+ if (!NodeDocument.isLastRevEntry(change.getKey().getName())
+ && !NodeDocument.MODIFIED_IN_SECS.equals(change.getKey().getName())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static NodeState merge(NodeStore store, NodeBuilder builder)
+ throws CommitFailedException {
+ return store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ }
+}
Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestUtils.java
------------------------------------------------------------------------------
svn:eol-style = native