/** * Returns a string representation the head state of this node store. */ public String toString() { return getRoot().toString(); }
@NotNull @Override public NodeState getRoot() { return memoryNodeStore.getRoot(); }
@Nonnull @Override public NodeState getRoot() { return memoryNodeStore.getRoot(); }
@NotNull @Override public NodeState getRoot() { return memoryNodeStore.getRoot(); }
/** * Returns a string representation the head state of this node store. */ public String toString() { return getRoot().toString(); }
@Nonnull @Override public String checkpoint(long lifetime, @Nonnull Map<String, String> properties) { checkArgument(lifetime > 0); checkNotNull(properties); String checkpoint = "checkpoint" + checkpointCounter.incrementAndGet(); checkpoints.put(checkpoint, new Checkpoint(getRoot(), properties)); return checkpoint; }
@NotNull @Override public String checkpoint(long lifetime, @NotNull Map<String, String> properties) { checkArgument(lifetime > 0); checkNotNull(properties); String checkpoint = "checkpoint" + checkpointCounter.incrementAndGet(); checkpoints.put(checkpoint, new Checkpoint(getRoot(), properties)); return checkpoint; }
@Override public NodeState getRoot() { //Keep returning stale view untill initlease is not invoked if (!intiLeaseCalled.get()) { return oldRootState.get(); } return super.getRoot(); } };
@Test public void asyncStateChanged() throws Exception{ AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider); async.run(); AsyncIndexUpdate async2 = new AsyncIndexUpdate("foo-async", store, provider); async2.run(); NodeState root = store.getRoot(); assertFalse(service.hasIndexerUpdatedForAnyLane(root, root)); NodeBuilder builder = store.getRoot().builder(); builder.child(":async").setProperty(AsyncIndexUpdate.lastIndexedTo("async"), 42L); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertTrue(service.hasIndexerUpdatedForAnyLane(root, store.getRoot())); }
private void addBundlorConfigForAsset() throws CommitFailedException { NodeBuilder builder = nodeStore.getRoot().builder(); NodeBuilder bundlor = builder.child("jcr:system").child(DOCUMENT_NODE_STORE).child(BUNDLOR); bundlor.child("app:Asset").setProperty(DocumentBundlor.PROP_PATTERN, singletonList("metadata"), Type.STRINGS); nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Test public void testStarName() { NodeState root = new MemoryNodeStore().getRoot(); NodeBuilder builder = root.builder(); NodeBuilder file = builder.child("file"); file.setProperty(JCR_PRIMARYTYPE, NT_FILE); file.child(JCR_CONTENT); SimpleNodeAggregator agg = new SimpleNodeAggregator().newRuleWithName( NT_FILE, newArrayList(INCLUDE_ALL)); String path = "/file/jcr:content"; List<String> actual = newArrayList(agg.getParents( builder.getNodeState(), path)); assertEquals(newArrayList("/file"), actual); }
@Test public void validNamespacePrefix() throws Exception { NodeBuilder builder = mount.getRoot().builder(); builder.child("libs").setProperty("jcr:prop", "value"); mount.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); check("/libs/jcr:prop"); }
@Test public void noNamespacePrefix() throws Exception { NodeBuilder builder = mount.getRoot().builder(); builder.child("libs").setProperty("prop", "value"); mount.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); check("/libs"); } }
private void check(String path) { Tree tree = TreeUtil.getTree(TreeFactory.createReadOnlyTree(mount.getRoot()), path); ErrorHolder errorHolder = new ErrorHolder(); checker.check(new MountedNodeStore(mip.getMountByName("first"), mount), tree, errorHolder, context); errorHolder.end(); }
@Test public void invalidNamespacePrefix_node() throws Exception { NodeBuilder builder = mount.getRoot().builder(); builder.child("libs").child("foo:first"); mount.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); exception.expect(IllegalRepositoryStateException.class); exception.expectMessage("1 errors were found"); exception.expectMessage("invalid namespace prefix foo"); check("/libs/foo:first"); }
@Test public void invalidNamespacePrefix_property() throws Exception { NodeBuilder builder = mount.getRoot().builder(); builder.child("libs").setProperty("foo:prop", "value"); mount.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); exception.expect(IllegalRepositoryStateException.class); exception.expectMessage("1 errors were found"); exception.expectMessage("invalid namespace prefix foo"); check("/libs"); }
@Test public void diffWithSecondary() throws Exception{ configureSecondary(); NodeBuilder builder = createContentStructure(); NodeState r1 = merge(store, builder); NodeState rs1 = DelegatingDocumentNodeState.wrap(secondary.getRoot(), store); builder = store.getRoot().builder(); childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("foo", "bar"); NodeState r2 = merge(store, builder); JsopWriter w = new JsopBuilder(); String path = "/test/book.jpg"; assertFalse(differ.diff(adns(rs1, path), adns(r2, path), w)); assertEquals("^\"jcr:content\":{}", w.toString()); }
@Before public void prepareRepository() throws Exception { MemoryNodeStore root = new MemoryNodeStore(); mount = new MemoryNodeStore(); NodeBuilder rootBuilder = root.getRoot().builder(); new InitialContent().initialize(rootBuilder); root.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY); mip = Mounts.newBuilder() .readOnlyMount("first", "/first") .build(); checker = new NamespacePrefixNodestoreChecker(); context = checker.createContext(root, mip); }
@Before public void createFixture() throws CommitFailedException { globalStore = new MemoryNodeStore(); mountedStore = new MemoryNodeStore(); NodeBuilder rootBuilder = mountedStore.getRoot().builder(); rootBuilder.setChildNode("first").setChildNode("second").setChildNode("third"); rootBuilder.setChildNode("not-covered"); mountedStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY); mip = Mounts.newBuilder() .readOnlyMount("first", "/first") .build(); mount = mip.getMountByName("first"); }
@Test public void noConflict() throws Exception { MemoryNodeStore globalStore = new MemoryNodeStore(); MemoryNodeStore mountedStore = new MemoryNodeStore(); populateStore(globalStore, b -> b.child("first").setProperty("foo", "baz")); populateStore(mountedStore, b -> b.child("libs").child("first").setProperty("foo", "bar")); UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker(); Context ctx = checker.createContext(globalStore, mip); ErrorHolder error = new ErrorHolder(); checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx); error.end(); }