@Test
public void shouldRegisterRemoveExistingMappingWhenUsingNewPrefixWithPreviouslyUsedUri() throws Exception {

    String prefix1 = "foo1";
    String prefix2 = "foo2";
    String uri = "http://example.com";
    assertThatNamespacePrefixIsNotRegistered(prefix1);
    assertThatNamespacePrefixIsNotRegistered(prefix2);
    assertThatNamespaceUriIsNotRegistered(uri);
    // Register the URI with the first prefix.
    registry.registerNamespace(prefix1, uri);
    assertThatNamespaceIsRegistered(prefix1, uri);
    // Register the same URI with a different prefix. This should remove the mapping with 'prefix1'
    registry.registerNamespace(prefix2, uri);
    assertThatNamespaceIsRegistered(prefix2, uri);
    assertThatNamespacePrefixIsNotRegistered(prefix1);
}