Package org.apache.jackrabbit.test.api
Class NamespaceRemappingTest
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- org.apache.jackrabbit.test.JUnitTest
-
- org.apache.jackrabbit.test.AbstractJCRTest
-
- org.apache.jackrabbit.test.api.NamespaceRemappingTest
-
- All Implemented Interfaces:
junit.framework.Test
public class NamespaceRemappingTest extends AbstractJCRTest
Test cases for JSR 283 sections 3.5.2 Session-Local Mappings and 5.11 Namespace Mapping and the related namespace mapping methods inSession
.
-
-
Field Summary
-
Fields inherited from class org.apache.jackrabbit.test.AbstractJCRTest
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 Summary
Constructors Constructor Description NamespaceRemappingTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 ifSession.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 mappingvoid
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-
Methods inherited from class org.apache.jackrabbit.test.AbstractJCRTest
checkSupportedOption, cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureKnowsNodeType, ensureLockingSupported, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getPrefix, getProperty, getProperty, getQualifiedName, getSize, isSupported, needsMixin, run
-
Methods inherited from class junit.framework.TestCase
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
-
-
-
-
Method Detail
-
setUp
protected void setUp() throws Exception
Sets up the fixture for the tests.- Overrides:
setUp
in classAbstractJCRTest
- Throws:
Exception
-
tearDown
protected void tearDown() throws Exception
- Overrides:
tearDown
in classAbstractJCRTest
- Throws:
Exception
-
testNamespaceRemapping
public void testNamespaceRemapping() throws RepositoryException
Tests if the remapping of jcr:primaryType to a different prefix works and returns the property with the correct primaryType value.- Throws:
RepositoryException
-
testAutomaticNewLocalPrefix
public void testAutomaticNewLocalPrefix() throws RepositoryException
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. The new prefix must differ from those already present among the set of local mappings.
- Throws:
RepositoryException
-
testExceptionOnUnknownPrefix
public void testExceptionOnUnknownPrefix() throws RepositoryException
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.
- Throws:
RepositoryException
-
testInitialLocalNamespaceMappings
public void testInitialLocalNamespaceMappings() throws RepositoryException
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.
- Throws:
RepositoryException
-
testScopeOfLocalNamepaceMappings
public void testScopeOfLocalNamepaceMappings() throws RepositoryException
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
Also specified in the javadoc of
Session.setNamespacePrefix(String, String)
:The remapping only affects operations done through this
Session
. To clear all remappings, the client must acquire a newSession
.- Throws:
RepositoryException
-
testExceptionsFromRemapping
public void testExceptionsFromRemapping() throws RepositoryException
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.
Also specified in the javadoc for throwing a
NamespaceException
fromSession.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.
- Throws:
RepositoryException
-
testGetNamespaceURI
public void testGetNamespaceURI() throws RepositoryException
Tests that Session.getNamespaceURI() returns according the session scoped mapping- Throws:
RepositoryException
-
testGetNamespacePrefix
public void testGetNamespacePrefix() throws RepositoryException
Tests that Session.getNamespacePrefix returns the session scoped mapping.- Throws:
RepositoryException
-
testGetNamespacePrefixes
public void testGetNamespacePrefixes() throws RepositoryException
Tests ifSession.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.- Throws:
RepositoryException
-
testPrefixRemapping
public void testPrefixRemapping() throws NamespaceException, RepositoryException
Tests that, after locally re-assigning a prefix, a previously created node continues to work with respect to sameness and consistent naming behavior.
-
-