@Test
public void shouldAllowSessionToCreateChildrenWithSameNameWithMultipleSaves() throws Exception {

    // Make sure the property does not exist ...
    check(cache).noNode("/childB/newChild");
    print(false);
    // Set property on existing node ...
    MutableCachedNode nodeB = check(session1).mutableNode("/childB");
    NodeKey key = nodeB.getKey();
    Stopwatch create = new Stopwatch();
    Stopwatch total = new Stopwatch();
    Stopwatch save = new Stopwatch();
    Stopwatch opt = new Stopwatch();
    runInTransaction(() -> optimizer.optimizeChildrenBlocks(key, null, 1000, 500)); // will merge two into a single block ...
    print(true);
    print("Creating nodes ...");
    total.start();
    for (int i = 0; i != 10000; ++i) {
        create.start();
        NodeKey newKey = key.withId("child" + i);
        // NodeKey newKey = session1.createNodeKey();
        nodeB.createChild(session1, newKey, name("newChild"), property("p1a", 344), property("p2", false));
        create.stop();
        if (i != 0 && i % 1000 == 0) {
            print(false);
            print("Saving...");
            // print(false);
            save.start();
            session1.save();
            save.stop();
            print(false);
            print("Optimizing...");
            print(false);
            opt.start();
            runInTransaction(() ->optimizer.optimizeChildrenBlocks(key, null, 1000, 500));
            opt.stop();
            // Find node B again after the save ...
            nodeB = check(session1).mutableNode("/childB");
        }
    }
    total.stop();
    print(true);
    print("Time (create): " + create.getSimpleStatistics());
    print("Time (save): " + save.getSimpleStatistics());
    print("Time (optimize): " + opt.getTotalDuration());
    print("Time (total): " + total.getTotalDuration());
    session1.clear();
    total.reset();
    total.start();
    nodeB.getChildReferences(session1).getChild(name("newChild"), 9450);
    total.stop();
    print("Time (getchild#9450): " + total.getTotalDuration());
    session1.clear();
    total.reset();
    total.start();
    nodeB.getChildReferences(session1).getChild(name("newChild"), 10);
    total.stop();
    print("Time (getchild#10): " + total.getTotalDuration());
}