public class NamespaceRemappingTest extends AbstractJCRTest
Session
.isReadOnly, jcrBaseVersion, jcrCopiedFrom, jcrCreated, jcrFrozenNode, jcrFrozenUuid, jcrIsCheckedOut, jcrlockIsDeep, jcrLockOwner, jcrMergeFailed, jcrMixinTypes, jcrPredecessors, jcrPrimaryType, jcrRootVersion, jcrSuccessors, jcrSystem, jcrUUID, jcrVersionHistory, mixLockable, mixReferenceable, mixShareable, mixSimpleVersionable, mixTitle, mixVersionable, nodeName1, nodeName2, nodeName3, nodeName4, NS_JCR_URI, NS_MIX_URI, NS_NT_URI, NS_SV_URI, ntActivity, ntBase, ntFrozenNode, ntQuery, ntUnstructured, ntVersion, ntVersionHistory, ntVersionLabels, propertyName1, propertyName2, superuser, testNodeType, testNodeTypeNoChildren, testNodeTypeTestRoot, testPath, testRoot, testRootNode, vf, workspaceName
Constructor and Description |
---|
NamespaceRemappingTest() |
Modifier and Type | Method and Description |
---|---|
protected void |
setUp()
Sets up the fixture for the tests.
|
protected void |
tearDown() |
void |
testAutomaticNewLocalPrefix()
Test case for the automatic generation of a new local prefix for a
registered namespace URI that doesn't have a local mapping, as specified
in section 3.5.2 Session-Local Mappings:
If a JCR method returns a name from the repository with a namespace URI
for which no local mapping exists, a prefix is created automatically
and a mapping between that prefix and the namespace URI in question is
added to the set of local mappings.
|
void |
testExceptionOnUnknownPrefix()
Test case for the unknown prefix behaviour specified in
section 3.5.2 Session-Local Mappings:
If a JCR method is passed a name or path containing a prefix which
does not exist in the local mapping an exception is thrown.
|
void |
testExceptionsFromRemapping()
Test case for the exception clauses of section 5.11 Namespace Mapping:
However, the method will throw an exception if
the specified prefix begins with the characters "xml"
(in any combination of case) or,
the specified prefix is the empty string or,
the specified namespace URI is the empty string.
|
void |
testGetNamespacePrefix()
Tests that Session.getNamespacePrefix returns the session scoped
mapping.
|
void |
testGetNamespacePrefixes()
Tests if
Session.getNamespacePrefixes() returns
all prefixes currently set for this session, including all those
registered in the NamespaceRegistry but not over-ridden by a
Session.setNamespacePrefix, plus those currently set locally by
Session.setNamespacePrefix. |
void |
testGetNamespaceURI()
Tests that Session.getNamespaceURI() returns according the session scoped
mapping
|
void |
testInitialLocalNamespaceMappings()
Test case for the initial set of local namespace mappings as specified
in section 3.5.2 Session-Local Mappings:
When a new session is acquired, the mappings present in the persistent
namespace registry are copied to the local namespace mappings of that
session.
|
void |
testNamespaceRemapping()
Tests if the remapping of jcr:primaryType to a different prefix works and
returns the property with the correct primaryType value.
|
void |
testPrefixRemapping()
Tests that, after locally re-assigning a prefix, a previously created
node continues to work with respect to sameness and consistent naming
behavior.
|
void |
testScopeOfLocalNamepaceMappings()
Test case for the scope of the local namespace mappings as specified
in section 3.5.2 Session-Local Mappings:
The resulting mapping table applies only within the scope of that session
|
checkSupportedOption, cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureKnowsNodeType, ensureLockingSupported, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getPrefix, getProperty, getProperty, getQualifiedName, getSize, isSupported, needsMixin, run
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, runBare, runTest, setName, toString
protected void setUp() throws Exception
setUp
in class AbstractJCRTest
Exception
protected void tearDown() throws Exception
tearDown
in class AbstractJCRTest
Exception
public void testNamespaceRemapping() throws RepositoryException
RepositoryException
public void testAutomaticNewLocalPrefix() throws RepositoryException
If a JCR method returns a name from the repository with a namespace URI for which no local mapping exists, a prefix is created automatically and a mapping between that prefix and the namespace URI in question is added to the set of local mappings. The new prefix must differ from those already present among the set of local mappings.
RepositoryException
public void testExceptionOnUnknownPrefix() throws RepositoryException
If a JCR method is passed a name or path containing a prefix which does not exist in the local mapping an exception is thrown.
RepositoryException
public void testInitialLocalNamespaceMappings() throws RepositoryException
When a new session is acquired, the mappings present in the persistent namespace registry are copied to the local namespace mappings of that session.
RepositoryException
public void testScopeOfLocalNamepaceMappings() throws RepositoryException
The resulting mapping table applies only within the scope of that session
Also specified in the javadoc of
Session.setNamespacePrefix(String, String)
:
The remapping only affects operations done through thisSession
. To clear all remappings, the client must acquire a newSession
.
RepositoryException
public void testExceptionsFromRemapping() throws RepositoryException
However, the method will throw an exception if
- the specified prefix begins with the characters "xml" (in any combination of case) or,
- the specified prefix is the empty string or,
- the specified namespace URI is the empty string.
Also specified in the javadoc for throwing a NamespaceException
from Session.setNamespacePrefix(String, String)
:
if an attempt is made to map a namespace URI to a prefix beginning with the characters "xml
" (in any combination of case) or if an attempt is made to map either the empty prefix or the empty namespace (i.e., if eitherprefix
oruri
are the empty string).
Section 3.2 Names also contains extra constraints on the prefix and namespace URI syntax:
Namespace ::= EmptyString | Uri EmptyString ::= The empty string Uri ::= A URI, as defined in Section 3 in http://tools.ietf.org/html/rfc3986#section-3 Prefix ::= Any string that matches the NCName production in http://www.w3.org/TR/REC-xml-names
It is unspecified whether an implementation should actually enforce these constraints, so for now this test case does not check this behaviour.
RepositoryException
public void testGetNamespaceURI() throws RepositoryException
RepositoryException
public void testGetNamespacePrefix() throws RepositoryException
RepositoryException
public void testGetNamespacePrefixes() throws RepositoryException
Session.getNamespacePrefixes()
returns
all prefixes currently set for this session, including all those
registered in the NamespaceRegistry but not over-ridden by a
Session.setNamespacePrefix, plus those currently set locally by
Session.setNamespacePrefix.RepositoryException
public void testPrefixRemapping() throws NamespaceException, RepositoryException
Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.