我刚刚开始研究Jackrabbit Oak 1.7.5并且我无法保存我的更改 - 此测试在最后一个断言中失败:
public class JCRTest {
@Test
public void testCommit() throws CommitFailedException {
final NodeStore ns = new MemoryNodeStore();
final String imagesFolder = "images";
NodeState rootState = ns.getRoot();
//newly created store does not have nodes
assertThat(rootState.getChildNode(imagesFolder).exists(), is(equalTo(false)));
NodeBuilder rootBuilder = rootState.builder();
//adding a node called 'images'
rootBuilder.child(imagesFolder);
//it is still not going to be shown since we are working in our own 'state'
assertThat(rootState.getChildNode(imagesFolder).exists(), is(equalTo(false)));
//merging the changes into root
ns.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
//expecting to see the 'images' folder
assertThat(rootState.getChildNode(imagesFolder).exists(), is(equalTo(true)));
}
}
答案 0 :(得分:1)
NodeState
(测试中的rootState)是存储库的快照。合并更改后,您需要再次获取存储库的头部(即在断言之前再次执行rootState = ns.getRoot()
。)