/** * {@inheritDoc} * * @see org.modeshape.graph.property.NamespaceRegistry#register(java.lang.Iterable) */ public void register( Iterable<Namespace> namespaces ) { // Let the delegate registry handle this, including cases where an aliased namespace is changed ... delegate.register(namespaces); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.NamespaceRegistry#register(java.lang.String, java.lang.String) */ public String register( String prefix, String namespaceUri ) { // Let the delegate registry handle this, including cases where an aliased namespace is changed ... return delegate.register(prefix, namespaceUri); }
/** * {@inheritDoc} */ public String register( String prefix, String namespaceUri ) { CheckArg.isNotNull(namespaceUri, "namespaceUri"); Lock lock = this.registryLock.writeLock(); try { lock.lock(); return delegate.register(prefix, namespaceUri); } finally { lock.unlock(); } }
@Test public void shouldReturnPrefixForNamespaceUriThatIsRegistered() { namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.getPrefixForNamespaceUri(validNamespaceUri1, false), is(validPrefix1)); assertThat(namespaceRegistry.getPrefixForNamespaceUri(validNamespaceUri2, false), is(validPrefix2)); }
@Test public void shouldFindRegisteredNamespace() { namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri1), is(true)); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri2), is(true)); }
@Test public void shouldReturnNamespaceUriForPrefixThatIsRegistered() { namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.getNamespaceForPrefix(validPrefix1), is(validNamespaceUri1)); assertThat(namespaceRegistry.getNamespaceForPrefix(validPrefix2), is(validNamespaceUri2)); }
@Before public void beforeEach() throws Exception { sequencer = new ClassFileSequencer(); context = new MockSequencerContext(); context.getNamespaceRegistry().register("class", "http://www.modeshape.org/sequencer/classfile/1.0"); context.getNamespaceRegistry().register("nt", "http://www.jcp.org/jcr/nt/1.0"); output = new MockSequencerOutput(context); input = this.getClass().getResourceAsStream("/NodeEntity.clazz"); }
@Test public void shouldReturnNullForPrefixIfNamespaceUriIsNotRegistered() { assertThat(namespaceRegistry.getPrefixForNamespaceUri(validNamespaceUri3, false), is(nullValue())); // now register some namespaces ... namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.getPrefixForNamespaceUri(validNamespaceUri3, false), is(nullValue())); }
@Test public void shouldReturnNullForNamespaceUriIfPrefixIsNotRegistered() { assertThat(namespaceRegistry.getNamespaceForPrefix("notfound"), is(nullValue())); // now register some namespaces ... namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.getNamespaceForPrefix("notfound"), is(nullValue())); }
@Test public void shouldAlwaysHaveDefaultNamespaceRegistered() { assertThat(namespaceRegistry.getDefaultNamespaceUri(), is(notNullValue())); namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.getDefaultNamespaceUri(), is(notNullValue())); }
@Test public void shouldAllowLocalRegistryToChangeDefaultNamespace() { local.register("", uri); assertNamespaces(delegate, ""); assertNamespaces(local, "=" + uri); }
public MockSequencerContext( ExecutionContext context, String inputPath ) { super(context, context.getValueFactories().getPathFactory().create(inputPath), null, null, new SimpleProblems()); getNamespaceRegistry().register("modedtd", "http://www.modeshape.org/dtd/1.0"); getNamespaceRegistry().register("modexml", "http://www.modeshape.org/xml/1.0"); } }
@Test public void shouldNotFindRegisteredNamespaceIfNamespaceNotRegistered() { assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri1), is(false)); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri2), is(false)); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri3), is(false)); namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register(validPrefix2, validNamespaceUri2); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri1), is(true)); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri2), is(true)); assertThat(namespaceRegistry.isRegisteredNamespaceUri(validNamespaceUri3), is(false)); }
@Test public void shouldReturnNonNullDefaultNamespaceUriWhenThereAreNamespacesRegisteredIncludineOneWithZeroLengthPrefix() { namespaceRegistry.register(validPrefix1, validNamespaceUri1); namespaceRegistry.register("", validNamespaceUri2); assertThat(namespaceRegistry.getDefaultNamespaceUri(), is(validNamespaceUri2)); assertThat(namespaceRegistry.getNamespaceForPrefix(""), is(validNamespaceUri2)); assertThat(namespaceRegistry.getRegisteredNamespaceUris(), hasItem(validNamespaceUri2)); assertThat(namespaceRegistry.getPrefixForNamespaceUri(validNamespaceUri2, false), is("")); }
@Test public void shouldGetStringWithNamespacePrefixesForAllNamesIfNamespaceRegistryIsProvided() { path = pathFactory.create("/mode:a/b/mode:c/../d/./mode:e/../.."); assertThat(path.getString(namespaceRegistry, NO_OP_ENCODER), is("/mode:a/b/mode:c/../d/./mode:e/../..")); namespaceRegistry.register("dna2", validNamespaceUri); assertThat(path.getString(namespaceRegistry, NO_OP_ENCODER), is("/dna2:a/b/dna2:c/../d/./dna2:e/../..")); }
@Test public void shouldGetStringWithNamespacePrefixesForAllNamesIfNamespaceRegistryIsProvided() { path = pathFactory.create("/mode:a/b/mode:c/../d/./mode:e/../.."); assertThat(path.getString(namespaceRegistry, NO_OP_ENCODER), is("/mode:a/b/mode:c/../d/./mode:e/../..")); namespaceRegistry.register("dna2", validNamespaceUri); assertThat(path.getString(namespaceRegistry, NO_OP_ENCODER), is("/dna2:a/b/dna2:c/../d/./dna2:e/../..")); }
@Before public void beforeEach() { this.registry = new SimpleNamespaceRegistry(); this.registry.register("dna", "http://www.modeshape.org/namespace"); this.encoder = Path.DEFAULT_ENCODER; this.decoder = Path.DEFAULT_DECODER; this.stringValueFactory = new StringValueFactory(registry, decoder, encoder); this.factory = new NameValueFactory(registry, decoder, stringValueFactory); }
@Before public void beforeEach() { context = new ExecutionContext(); context.getNamespaceRegistry().register("ex", "http://www.example.com"); paths = context.getValueFactories().getPathFactory(); }
@Before public void beforeEach() { this.registry = new SimpleNamespaceRegistry(); this.registry.register(ModeShapeLexicon.Namespace.PREFIX, ModeShapeLexicon.Namespace.URI); this.stringValueFactory = new StringValueFactory(registry, Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER); this.nameFactory = new NameValueFactory(registry, Path.DEFAULT_DECODER, stringValueFactory); this.validName = nameFactory.create("mode:something"); this.factory = new PathValueFactory(Path.DEFAULT_DECODER, stringValueFactory, nameFactory); }