Package org.apache.jackrabbit.test
Class AbstractJCRTest
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- org.apache.jackrabbit.test.JUnitTest
-
- org.apache.jackrabbit.test.AbstractJCRTest
-
- All Implemented Interfaces:
junit.framework.Test
- Direct Known Subclasses:
AbstractAccessControlTest,AbstractLockTest,AbstractMergeTest,AbstractObservationTest,AbstractQueryTest,AbstractRetentionTest,AbstractVersionTest,AbstractVersionTest,AddNodeTest,BinaryPropertyTest,BooleanPropertyTest,CanAddChildNodeCallWithNodeTypeTest,CanAddChildNodeCallWithoutNodeTypeTest,CanRemoveItemTest,CanSetPropertyBinaryTest,CanSetPropertyBooleanTest,CanSetPropertyDateTest,CanSetPropertyDoubleTest,CanSetPropertyLongTest,CanSetPropertyMultipleTest,CanSetPropertyNameTest,CanSetPropertyPathTest,CanSetPropertyStringTest,CanSetPropertyTest,CheckPermissionTest,DatePropertyTest,DocumentViewImportTest,DoublePropertyTest,ExportDocViewTest,ExportSysViewTest,GetReferencesNodeTest,GetWeakReferencesTest,HasPermissionTest,ImpersonateTest,LifecycleTest,LockManagerTest,LockTest,LongPropertyTest,NamePropertyTest,NamespaceRegistryReadMethodsTest,NamespaceRegistryTest,NamespaceRemappingTest,NameTest,NodeAddMixinTest,NodeCanAddMixinTest,NodeDefTest,NodeDiscoveringNodeTypesTest,NodeItemIsModifiedTest,NodeItemIsNewTest,NodeIteratorTest,NodeOrderableChildNodesTest,NodeReadMethodsTest,NodeRemoveMixinTest,NodeSetPrimaryTypeTest,NodeTest,NodeTypeCreationTest,NodeTypeManagerTest,NodeTypeTest,NodeUUIDTest,PathPropertyTest,PathTest,PredefinedNodeTypeTest,PropertyDefTest,PropertyItemIsModifiedTest,PropertyItemIsNewTest,PropertyReadMethodsTest,PropertyTest,PropertyTypeTest,ReferenceableRootNodesTest,ReferencePropertyTest,ReferencesTest,RepositoryDescriptorTest,RepositoryFactoryTest,RepositoryLoginTest,RootNodeTest,SaveTest,SerializationTest,SessionReadMethodsTest,SessionRemoveItemTest,SessionTest,SessionUUIDTest,SetPropertyAssumeTypeTest,SetPropertyBooleanTest,SetPropertyCalendarTest,SetPropertyConstraintViolationExceptionTest,SetPropertyDecimalTest,SetPropertyDoubleTest,SetPropertyInputStreamTest,SetPropertyLongTest,SetPropertyNodeTest,SetPropertyStringTest,SetPropertyValueTest,SetValueBinaryTest,SetValueBooleanTest,SetValueConstraintViolationExceptionTest,SetValueDateTest,SetValueDecimalTest,SetValueDoubleTest,SetValueInputStreamTest,SetValueLockExceptionTest,SetValueLongTest,SetValueReferenceTest,SetValueStringTest,SetValueValueFormatExceptionTest,SetValueVersionExceptionTest,ShareableNodeTest,StringPropertyTest,UndefinedPropertyTest,ValueFactoryTest,WorkspaceCloneReferenceableTest,WorkspaceCloneSameNameSibsTest,WorkspaceCloneTest,WorkspaceCloneVersionableTest,WorkspaceCopyBetweenWorkspacesReferenceableTest,WorkspaceCopyBetweenWorkspacesSameNameSibsTest,WorkspaceCopyBetweenWorkspacesTest,WorkspaceCopyBetweenWorkspacesVersionableTest,WorkspaceCopyReferenceableTest,WorkspaceCopySameNameSibsTest,WorkspaceCopyTest,WorkspaceCopyVersionableTest,WorkspaceManagementTest,WorkspaceMoveReferenceableTest,WorkspaceMoveSameNameSibsTest,WorkspaceMoveTest,WorkspaceMoveVersionableTest,WorkspaceReadMethodsTest,WorkspaceTest
public abstract class AbstractJCRTest extends JUnitTest
Abstract base class for all JCR test classes.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisReadOnlyFlag that indicates if the current test is a read-only test, that is no content is written to the workspace by the test.protected StringjcrBaseVersionJCR Name jcr:baseVersion using the namespace resolver of the current session.protected StringjcrCopiedFromJCR Name jcr:copiedFrom using the namespace resolver of the current session.protected StringjcrCreatedJCR Name jcr:created using the namespace resolver of the current session.protected StringjcrFrozenNodeJCR Name jcr:frozenNode using the namespace resolver of the current session.protected StringjcrFrozenUuidJCR Name jcr:frozenUuid using the namespace resolver of the current session.protected StringjcrIsCheckedOutJCR Name jcr:isCheckedOut using the namespace resolver of the current session.protected StringjcrlockIsDeepJCR Name jcr:lockIsDeep using the namespace resolver of the current session.protected StringjcrLockOwnerJCR Name jcr:lockOwner using the namespace resolver of the current session.protected StringjcrMergeFailedJCR Name jcr:mergeFailed using the namespace resolver of the current session.protected StringjcrMixinTypesJCR Name jcr:mixinTypes using the namespace resolver of the current session.protected StringjcrPredecessorsJCR Name jcr:predecessors using the namespace resolver of the current session.protected StringjcrPrimaryTypeJCR Name jcr:primaryType using the namespace resolver of the current session.protected StringjcrRootVersionJCR Name jcr:rootVersion using the namespace resolver of the current session.protected StringjcrSuccessorsJCR Name jcr:successors using the namespace resolver of the current session.protected StringjcrSystemJCR Name jcr:system using the namespace resolver of the current session.protected StringjcrUUIDJCR Name jcr:uuid using the namespace resolver of the current session.protected StringjcrVersionHistoryJCR Name jcr:created using the namespace resolver of the current session.protected StringmixLockableJCR Name mix:lockable using the namespace resolver of the current session.protected StringmixReferenceableJCR Name mix:referenceable using the namespace resolver of the current session.protected StringmixShareableJCR Name mix:shareable using the namespace resolver of the current session.protected StringmixSimpleVersionableJCR Name mix:simpleVersionable using the namespace resolver of the current session.protected StringmixTitleJCR Name mix:title using the namespace resolver of the current session.protected StringmixVersionableJCR Name mix:versionable using the namespace resolver of the current session.protected StringnodeName1Name of a node that will be created during a test case.protected StringnodeName2Name of a node that will be created during a test case.protected StringnodeName3Name of a node that will be created during a test case.protected StringnodeName4Name of a node that will be created during a test case.static StringNS_JCR_URINamespace URI for jcr prefix.static StringNS_MIX_URINamespace URI for mix prefix.static StringNS_NT_URINamespace URI for nt prefix.static StringNS_SV_URINamespace URI for sv prefixprotected StringntActivityJCR Name nt:activity using the namespace resolver of the current session.protected StringntBaseJCR Name nt:base using the namespace resolver of the current session.protected StringntFrozenNodeJCR Name nt:frozenNode using the namespace resolver of the current session.protected StringntQueryJCR Name nt:query using the namespace resolver of the current session.protected StringntUnstructuredJCR Name nt:unstructured using the namespace resolver of the current session.protected StringntVersionJCR Name nt:version using the namespace resolver of the current session.protected StringntVersionHistoryJCR Name nt:versionHistory using the namespace resolver of the current session.protected StringntVersionLabelsJCR Name nt:versionHistory using the namespace resolver of the current session.protected StringpropertyName1Name of a property that will be used during a test case.protected StringpropertyName2Name of a property that will be used during a test case.protected SessionsuperuserThe superuser session for the default workspaceprotected StringtestNodeTypeThe node type name for newly created nodes.protected StringtestNodeTypeNoChildrenA node type that does not allow any child nodes, such as nt:base.protected StringtestNodeTypeTestRootThe node type name for the test root node.protected StringtestPathRelative path to the test root node.protected StringtestRootAbsolute path to the test root node.protected NodetestRootNodeThe rootNodefor testingprotected ValueFactoryvfThe value factory forsuperuser.protected StringworkspaceNameName of a workspace to use instead of the default workspace.
-
Constructor Summary
Constructors Constructor Description AbstractJCRTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckSupportedOption(String descriptorKey)Throws aNotExecutableExceptionif the repository does not support the feature identified by the givendiscriptorKey.protected voidcleanUp()protected NodecleanUpTestRoot(Session s)Reverts any pending changes made bysand deletes any nodes undertestRoot.protected StringcreateRandomString(int numChars)Creates aStringwith a random sequence of characters using 'a' - 'z'.protected voidensureCanSetProperty(Node node, String propertyName, int propertyType, boolean isMultiple)Checks that the repository can set the property to the required type, otherwise aborts withNotExecutableException.protected voidensureCanSetProperty(Node node, String propertyName, Value value)Checks that the repository can set the property to the required type, otherwise aborts withNotExecutableException.protected voidensureCanSetProperty(Node node, String propertyName, Value[] values)Checks that the repository can set the property to the required type, otherwise aborts withNotExecutableException.protected voidensureKnowsNodeType(Session session, String nodetype)Checks that the repository supports the specified node type, otherwise aborts withNotExecutableExceptionprotected voidensureLockingSupported()Checks that the repository supports locking, otherwise aborts withNotExecutableException.protected voidensureMixinType(Node node, String mixin)Ensures that the givennodeis of the given mixin type.protected voidensureMultipleWorkspacesSupported()Checks that the repository supports multiple workspace, otherwise aborts withNotExecutableException.protected RepositoryHelpergetHelper()ValuegetJcrValue(Session s, String valueProp, String typeProp, String defaultValue)Create a JCR value based on the configuration.protected static StringgetLocalName(String jcrName)Returns the local name for the givenjcrName.protected StringgetNonExistingWorkspaceName(Session session)Returns the name of a workspace that is not accessible fromsession.protected static StringgetPrefix(String jcrName)Returns the prefix for the givenjcrName.StringgetProperty(String propName)Returns the value of the configuration property withpropName.StringgetProperty(String name, String defaultValue)Returns the value of the configuration property with specifiedname.protected static StringgetQualifiedName(Session session, String jcrName)Returns the expanded name for the givenjcrName.protected longgetSize(RangeIterator it)Returns the size of theRangeIteratorit.protected booleanisSupported(String descriptorKey)Returnstrueif this repository support a certain optional feature; otherwisefalseis returned.protected booleanneedsMixin(Node node, String mixin)Checks whether the node already has the specified mixin node typevoidrun(junit.framework.TestResult testResult)Runs the test cases of this test class and reports the results totestResult.protected voidsetUp()protected voidtearDown()-
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
-
-
-
-
Field Detail
-
NS_JCR_URI
public static final String NS_JCR_URI
Namespace URI for jcr prefix.- See Also:
- Constant Field Values
-
NS_NT_URI
public static final String NS_NT_URI
Namespace URI for nt prefix.- See Also:
- Constant Field Values
-
NS_MIX_URI
public static final String NS_MIX_URI
Namespace URI for mix prefix.- See Also:
- Constant Field Values
-
NS_SV_URI
public static final String NS_SV_URI
Namespace URI for sv prefix- See Also:
- Constant Field Values
-
jcrPrimaryType
protected String jcrPrimaryType
JCR Name jcr:primaryType using the namespace resolver of the current session.
-
jcrMixinTypes
protected String jcrMixinTypes
JCR Name jcr:mixinTypes using the namespace resolver of the current session.
-
jcrPredecessors
protected String jcrPredecessors
JCR Name jcr:predecessors using the namespace resolver of the current session.
-
jcrSuccessors
protected String jcrSuccessors
JCR Name jcr:successors using the namespace resolver of the current session.
-
jcrCreated
protected String jcrCreated
JCR Name jcr:created using the namespace resolver of the current session.
-
jcrVersionHistory
protected String jcrVersionHistory
JCR Name jcr:created using the namespace resolver of the current session.
-
jcrCopiedFrom
protected String jcrCopiedFrom
JCR Name jcr:copiedFrom using the namespace resolver of the current session.
-
jcrFrozenNode
protected String jcrFrozenNode
JCR Name jcr:frozenNode using the namespace resolver of the current session.
-
jcrFrozenUuid
protected String jcrFrozenUuid
JCR Name jcr:frozenUuid using the namespace resolver of the current session.
-
jcrRootVersion
protected String jcrRootVersion
JCR Name jcr:rootVersion using the namespace resolver of the current session.
-
jcrIsCheckedOut
protected String jcrIsCheckedOut
JCR Name jcr:isCheckedOut using the namespace resolver of the current session.
-
jcrBaseVersion
protected String jcrBaseVersion
JCR Name jcr:baseVersion using the namespace resolver of the current session.
-
jcrUUID
protected String jcrUUID
JCR Name jcr:uuid using the namespace resolver of the current session.
-
jcrLockOwner
protected String jcrLockOwner
JCR Name jcr:lockOwner using the namespace resolver of the current session.
-
jcrlockIsDeep
protected String jcrlockIsDeep
JCR Name jcr:lockIsDeep using the namespace resolver of the current session.
-
jcrMergeFailed
protected String jcrMergeFailed
JCR Name jcr:mergeFailed using the namespace resolver of the current session.
-
jcrSystem
protected String jcrSystem
JCR Name jcr:system using the namespace resolver of the current session.
-
ntBase
protected String ntBase
JCR Name nt:base using the namespace resolver of the current session.
-
ntUnstructured
protected String ntUnstructured
JCR Name nt:unstructured using the namespace resolver of the current session.
-
ntVersion
protected String ntVersion
JCR Name nt:version using the namespace resolver of the current session.
-
ntVersionHistory
protected String ntVersionHistory
JCR Name nt:versionHistory using the namespace resolver of the current session.
-
ntVersionLabels
protected String ntVersionLabels
JCR Name nt:versionHistory using the namespace resolver of the current session.
-
ntFrozenNode
protected String ntFrozenNode
JCR Name nt:frozenNode using the namespace resolver of the current session.
-
mixReferenceable
protected String mixReferenceable
JCR Name mix:referenceable using the namespace resolver of the current session.
-
mixVersionable
protected String mixVersionable
JCR Name mix:versionable using the namespace resolver of the current session.
-
mixSimpleVersionable
protected String mixSimpleVersionable
JCR Name mix:simpleVersionable using the namespace resolver of the current session.
-
mixLockable
protected String mixLockable
JCR Name mix:lockable using the namespace resolver of the current session.
-
mixTitle
protected String mixTitle
JCR Name mix:title using the namespace resolver of the current session.
-
mixShareable
protected String mixShareable
JCR Name mix:shareable using the namespace resolver of the current session.
-
ntQuery
protected String ntQuery
JCR Name nt:query using the namespace resolver of the current session.
-
ntActivity
protected String ntActivity
JCR Name nt:activity using the namespace resolver of the current session.
-
testPath
protected String testPath
Relative path to the test root node.
-
testRoot
protected String testRoot
Absolute path to the test root node.
-
testNodeType
protected String testNodeType
The node type name for newly created nodes.
-
testNodeTypeTestRoot
protected String testNodeTypeTestRoot
The node type name for the test root node.
-
testNodeTypeNoChildren
protected String testNodeTypeNoChildren
A node type that does not allow any child nodes, such as nt:base.
-
nodeName1
protected String nodeName1
Name of a node that will be created during a test case.
-
nodeName2
protected String nodeName2
Name of a node that will be created during a test case.
-
nodeName3
protected String nodeName3
Name of a node that will be created during a test case.
-
nodeName4
protected String nodeName4
Name of a node that will be created during a test case.
-
propertyName1
protected String propertyName1
Name of a property that will be used during a test case.
-
propertyName2
protected String propertyName2
Name of a property that will be used during a test case.
-
workspaceName
protected String workspaceName
Name of a workspace to use instead of the default workspace.
-
superuser
protected Session superuser
The superuser session for the default workspace
-
isReadOnly
protected boolean isReadOnly
Flag that indicates if the current test is a read-only test, that is no content is written to the workspace by the test.
-
testRootNode
protected Node testRootNode
The rootNodefor testing
-
vf
protected ValueFactory vf
The value factory forsuperuser.
-
-
Method Detail
-
tearDown
protected void tearDown() throws Exception
-
run
public void run(junit.framework.TestResult testResult)
Runs the test cases of this test class and reports the results totestResult. In contrast to the default implementation ofTestCase.run()this method will suppress tests errors with aNotExecutableException. That is, test cases that throw this exception will still result as successful.- Specified by:
runin interfacejunit.framework.Test- Overrides:
runin classjunit.framework.TestCase- Parameters:
testResult- the test result.
-
getHelper
protected RepositoryHelper getHelper()
- Returns:
- the repository helper instance that is associated with this test.
-
getProperty
public String getProperty(String propName) throws RepositoryException
Returns the value of the configuration property withpropName. The sequence how configuration properties are read is the follwoing:javax.jcr.tck.<testClassName>.<testCaseName>.<propName>javax.jcr.tck.<testClassName>.<propName>javax.jcr.tck.<packageName>.<propName>javax.jcr.tck.<propName>
<testClassName>is the name of the test class without package prefix.<testMethodName>is the name of the test method<packageName>is the name of the package of the test class. Example: packageName fororg.apache.jackrabbit.test.api.BooleanPropertyTest:api
- Parameters:
propName- the propName of the configration property.- Returns:
- the value of the property or
nullif the property does not exist. - Throws:
RepositoryException- if an error occurs while reading from the configuration.
-
getProperty
public String getProperty(String name, String defaultValue) throws RepositoryException
Returns the value of the configuration property with specifiedname. If the property does not existdefaultValueis returned.Configuration properties are defined in the file:
repositoryStubImpl.properties.- Parameters:
name- the name of the property to retrieve.defaultValue- the default value if the property does not exist.- Returns:
- the value of the property or
defaultValueif non existent. - Throws:
RepositoryException- if the configuration file cannot be found.
-
getJcrValue
public Value getJcrValue(Session s, String valueProp, String typeProp, String defaultValue) throws RepositoryException
Create a JCR value based on the configuration.- Parameters:
s-valueProp- Name of the config property that contains the property value.typeProp- Name of the config property that contains the property type. If the config parameter is missing,PropertyType.STRINGis used to create the JCR value.defaultValue- Default value to be used if the config does not define the value property.- Returns:
- JCR value to be used for a test.
- Throws:
RepositoryException
-
getSize
protected long getSize(RangeIterator it)
Returns the size of theRangeIteratorit. Note, that theRangeIteratormight get consumed, becauseRangeIterator.getSize()might return -1 (information unavailable).- Parameters:
it- aRangeIterator.- Returns:
- the size of the iterator (number of elements).
-
getLocalName
protected static String getLocalName(String jcrName)
Returns the local name for the givenjcrName.- Parameters:
jcrName- the name.- Returns:
- the local name part.
-
getPrefix
protected static String getPrefix(String jcrName)
Returns the prefix for the givenjcrName.- Parameters:
jcrName- the name.- Returns:
- the prefix part (empty string when not prefixed)
-
getQualifiedName
protected static String getQualifiedName(Session session, String jcrName) throws RepositoryException
Returns the expanded name for the givenjcrName.- Parameters:
jcrName- the name.- Returns:
- the expanded name representation
- Throws:
RepositoryExceptionNamespaceException
-
getNonExistingWorkspaceName
protected String getNonExistingWorkspaceName(Session session) throws RepositoryException
Returns the name of a workspace that is not accessible fromsession.- Parameters:
session- the session.- Returns:
- name of a non existing workspace.
- Throws:
RepositoryException- if an error occurs.
-
createRandomString
protected String createRandomString(int numChars)
Creates aStringwith a random sequence of characters using 'a' - 'z'.- Parameters:
numChars- number of characters.- Returns:
- the generated String.
-
isSupported
protected boolean isSupported(String descriptorKey) throws RepositoryException
Returnstrueif this repository support a certain optional feature; otherwisefalseis returned. If there is no suchdescriptorKeypresent in the repository, this method also returns false.- Parameters:
descriptorKey- the descriptor key.- Returns:
trueif the option is supported.- Throws:
RepositoryException- if an error occurs.
-
checkSupportedOption
protected void checkSupportedOption(String descriptorKey) throws RepositoryException, NotExecutableException
Throws aNotExecutableExceptionif the repository does not support the feature identified by the givendiscriptorKey.- Parameters:
descriptorKey- the descriptor key.- Throws:
RepositoryException- if an error occurs.NotExecutableException- If the feature is not supported.
-
ensureMultipleWorkspacesSupported
protected void ensureMultipleWorkspacesSupported() throws RepositoryException, NotExecutableExceptionChecks that the repository supports multiple workspace, otherwise aborts withNotExecutableException.- Throws:
NotExecutableException- when the repository only supports a single workspaceRepositoryException
-
ensureLockingSupported
protected void ensureLockingSupported() throws RepositoryException, NotExecutableExceptionChecks that the repository supports locking, otherwise aborts withNotExecutableException.- Throws:
NotExecutableException- when the repository does not support lockingRepositoryException
-
ensureCanSetProperty
protected void ensureCanSetProperty(Node node, String propertyName, int propertyType, boolean isMultiple) throws NotExecutableException, RepositoryException
Checks that the repository can set the property to the required type, otherwise aborts withNotExecutableException.- Throws:
NotExecutableException- when setting the property to the required type is not supportedRepositoryException
-
ensureCanSetProperty
protected void ensureCanSetProperty(Node node, String propertyName, Value value) throws NotExecutableException, RepositoryException
Checks that the repository can set the property to the required type, otherwise aborts withNotExecutableException.- Throws:
NotExecutableException- when setting the property to the required type is not supportedRepositoryException
-
ensureCanSetProperty
protected void ensureCanSetProperty(Node node, String propertyName, Value[] values) throws NotExecutableException, RepositoryException
Checks that the repository can set the property to the required type, otherwise aborts withNotExecutableException.- Throws:
NotExecutableException- when setting the property to the required type is not supportedRepositoryException
-
ensureKnowsNodeType
protected void ensureKnowsNodeType(Session session, String nodetype) throws NotExecutableException, RepositoryException
Checks that the repository supports the specified node type, otherwise aborts withNotExecutableException- Throws:
NotExecutableException- when the specified node type is unknownRepositoryException
-
ensureMixinType
protected void ensureMixinType(Node node, String mixin) throws NotExecutableException, RepositoryException
Ensures that the givennodeis of the given mixin type.- Parameters:
node- a node.mixin- the name of a mixin type.- Throws:
NotExecutableException- if the node is not of type mixin and the mixin cannot be added.RepositoryException- if an error occurs.
-
needsMixin
protected boolean needsMixin(Node node, String mixin) throws RepositoryException
Checks whether the node already has the specified mixin node type- Throws:
RepositoryException
-
cleanUpTestRoot
protected Node cleanUpTestRoot(Session s) throws RepositoryException
Reverts any pending changes made bysand deletes any nodes undertestRoot. If there is no node attestRootthen the necessary nodes are created.- Parameters:
s- the session to clean up.- Returns:
- the
Nodethat represents the test root. - Throws:
RepositoryException- if an error occurs.
-
-