【问题标题】:Jackrabbit Oak merge not saving changesJackrabbit Oak 合并不保存更改
【发布时间】:2018-01-17 10:30:56
【问题描述】:

我刚开始研究 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)));
}
}

【问题讨论】:

  • 所以...将最后一行更改为:assertThat(ns.getRoot().getChildNode(imagesFolder).exists(), is(equalTo(true))); 使其工作,但我仍然想了解其原因。

标签: jackrabbit jackrabbit-oak


【解决方案1】:

NodeState(测试中的 rootState)是存储库的快照。合并更改后,您需要再次获取存储库的负责人(即在断言之前再次执行rootState = ns.getRoot())。

【讨论】:

    猜你喜欢
    • 2018-09-08
    • 2022-10-31
    • 2017-03-04
    • 2017-03-11
    • 2015-12-08
    • 2019-01-15
    • 2011-10-04
    • 2018-02-18
    • 1970-01-01
    相关资源
    最近更新 更多