NamespacePrefixNodestoreChecker implements MountedNodeStoreChecker<NamespacePrefixNodestoreChecker.Context> { @Override public boolean check(MountedNodeStore mountedStore, Tree tree, ErrorHolder errorHolder, Context context) { String name = tree.getName(); String path = tree.getPath(); validate(mountedStore, errorHolder, context, name, path); for ( PropertyState prop : tree.getProperties() ) { String propName = prop.getName(); validate(mountedStore, errorHolder, context, propName, PathUtils.concat(tree.getPath(), propName)); } return true; }  @Override Context createContext(NodeStore globalStore, MountInfoProvider mip); @Override boolean check(MountedNodeStore mountedStore, Tree tree, ErrorHolder errorHolder, Context context);  }
@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 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"); }