assertThat(iter.hasNext(), is(false));
}
@Test
public void shouldNavigateFromRootToSystemNode() {
CachedNode node = cache.getNode(cache.getRootKey());
ChildReference systemRef = node.getChildReferences(cache).getChild(JcrLexicon.SYSTEM);
// print = true;
long nanos = System.nanoTime();
CachedNode system = cache.getNode(systemRef);
print("Time (load): " + millis(Math.abs(System.nanoTime() - nanos)) + " ms");
for (int i = 0; i != 10; ++i) {
cache.clear();
nanos = System.nanoTime();
system.getKey();
system.getPath(cache);
system.getName(cache);
system.getProperty(JcrLexicon.UUID, cache);
system.getProperty(JcrLexicon.PRIMARY_TYPE, cache);
print("Time (read): " + millis(Math.abs(System.nanoTime() - nanos)) + " ms");
}
nanos = System.nanoTime();
system.getKey();
system.getPath(cache);
system.getName(cache);
system.getProperty(JcrLexicon.UUID, cache);
system.getProperty(JcrLexicon.PRIMARY_TYPE, cache);
print("Time (read): " + millis(Math.abs(System.nanoTime() - nanos)) + " ms");
assertThat(system, is(notNullValue()));
assertThat(system.getKey(), is(systemRef.getKey()));
assertThat(system.getPath(cache).isRoot(), is(false));
assertThat(system.getName(cache), is(JcrLexicon.SYSTEM));
assertThat(system.getProperty(JcrLexicon.UUID, cache).getFirstValue().toString(),
is("56b3feae-3def-44f7-a433-586413f312e4"));
assertThat(system.getProperty(JcrLexicon.PRIMARY_TYPE, cache).getFirstValue(), is((Object)ModeShapeLexicon.SYSTEM));
// Check the child references ...
ChildReferences refs = system.getChildReferences(cache);
assertThat(refs, is(notNullValue()));
assertThat(refs.size(), is(1L));
Iterator<ChildReference> iter = refs.iterator();
ChildReference namespaces = refs.getChild(ModeShapeLexicon.NAMESPACES);
assertThat(namespaces.getKey().toString(), is("source1system-jcrnamespaces"));
assertThat(namespaces.getName(), is(ModeShapeLexicon.NAMESPACES));
assertThat(iter.next(), is(namespaces));
assertThat(iter.hasNext(), is(false));
nanos = System.nanoTime();
CachedNode namespacesNode = cache.getNode(namespaces);
print("Time (load): " + millis(Math.abs(System.nanoTime() - nanos)) + " ms");
nanos = System.nanoTime();
assertThat(namespacesNode.getPath(cache), is(path("/jcr:system/mode:namespaces")));
assertThat(namespacesNode.getChildReferences(cache).isEmpty(), is(true));
print("Time (read): " + millis(Math.abs(System.nanoTime() - nanos)) + " ms");
}