|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
public class NamespaceRemappingTest
Test cases for JSR 283 sections 3.5.2 Session-Local Mappings and
5.11 Namespace Mapping and the related namespace mapping methods
in Session
.
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, mixVersionable, nodeName1, nodeName2, nodeName3, nodeName4, NS_JCR_URI, NS_MIX_URI, NS_NT_URI, NS_SV_URI, ntBase, ntFrozenNode, ntQuery, ntUnstructured, ntVersion, ntVersionHistory, ntVersionLabels, propertyName1, propertyName2, superuser, testNodeType, testNodeTypeNoChildren, testPath, testRoot, testRootNode, vf, workspaceName |
Fields inherited from class org.apache.jackrabbit.test.JUnitTest |
---|
log |
Constructor Summary | |
---|---|
NamespaceRemappingTest()
|
Method Summary | |
---|---|
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 |
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, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getProperty, getProperty, getSize, isSupported, needsMixin, run |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, runBare, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
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, fail, fail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NamespaceRemappingTest()
Method Detail |
---|
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |