Index: src/test/java/org/apache/jackrabbit/oak/spi/commit/CommitHookTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/oak/spi/commit/CommitHookTest.java	(revision 0)
+++ src/test/java/org/apache/jackrabbit/oak/spi/commit/CommitHookTest.java	(revision 0)
@@ -0,0 +1,75 @@
+/*
+ * 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.spi.commit;
+
+import junit.framework.Assert;
+
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.AbstractOakTest;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
+import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.Test;
+
+public class CommitHookTest extends AbstractOakTest {
+
+    private boolean ranHook = false;
+
+    /**
+     * OAK-331: CommitHook changes aren't seen by session.getLatestRoot()
+     */
+    @Test
+    public void testCommitHookChanges() throws Exception {
+        Assert.assertFalse(ranHook);
+        ContentSession session = createAdminSession();
+        Root root = session.getLatestRoot();
+        root.getTree("/").addChild("test");
+        root.commit(DefaultConflictHandler.OURS);
+        Assert.assertTrue(ranHook);
+
+        // verify hook
+        Tree after = session.getLatestRoot().getTree("/test");
+        Assert.assertTrue(after.hasChild("hook-test"));
+    }
+
+    @Override
+    protected ContentRepository createRepository() {
+        return new ContentRepositoryImpl(new MicroKernelImpl(), null,
+                new TestCommitHook());
+    }
+
+    private final class TestCommitHook implements CommitHook {
+
+        @Override
+        public NodeState processCommit(NodeStore store, NodeState before,
+                NodeState after) throws CommitFailedException {
+            NodeBuilder builder = store.getBuilder(after);
+            if (builder.hasChildNode("test")) {
+                builder.getChildBuilder("test").getChildBuilder("hook-test");
+                ranHook = true;
+            }
+            return after;
+        }
+    }
+}
