Class NodeTest
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- org.apache.jackrabbit.test.JUnitTest
-
- org.apache.jackrabbit.test.AbstractJCRTest
-
- org.apache.jackrabbit.test.api.NodeTest
-
- All Implemented Interfaces:
junit.framework.Test
public class NodeTest extends AbstractJCRTest
NodeTestcontains all test cases for thejavax.jcr.Nodethat are related to writing, modifying or deleting nodes (level 2 of the specification).
-
-
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 NodeTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetUp()to be able to test the update(String) and getCorrespondingNodePath(String) methods we need an additional workspacevoidtearDown()remove all nodes in second workspace and log outvoidtestAddNodeConstraintViolationExceptionProperty()Tries to add a node usingNode.addNode(String)as a child of a property.voidtestAddNodeConstraintViolationExceptionUndefinedNodeType()Tries to add a node usingNode.addNode(String)where node type can not be determined by parent (nt:baseis used as parent nodetype).voidtestAddNodeItemExistsException()Tries to create a node usingNode.addNode(String, String)at a location where there is already a node with same name and the parent does not allow same name siblings.voidtestAddNodeLackingMandatoryChildNode()Creates a node without its mandatory child node usingNode.addNode(String, String)and then saves.voidtestAddNodeParentSave()Creates a new node usingNode.addNode(String), saves usingItem.save()on parent node.voidtestAddNodePathNotFoundException()Tries to add a node usingNode.addNode(String)to a non existing destination node.voidtestAddNodeRepositoryExceptionRelPathIndex()Adds a new node usingNode.addNode(String)with an index for the new name.voidtestAddNodeRepositoryExceptionSaveOnNewNode()Creates a new node usingNode.addNode(String), then tries to callItem.save()on the newly node.voidtestAddNodeSessionSave()Creates a new node usingNode.addNode(String), saves usingSession.save().voidtestGetCorrespondingNodePath()Creates a node with same path in both workspaces to check ifNode.getCorrespondingNodePath(String)works properly.voidtestGetCorrespondingNodePathItemNotFoundException()CallsNode.getCorrespondingNodePath(String)on a node that has no corresponding node in second workspacevoidtestGetCorrespondingNodePathNoSuchWorkspaceException()CallsNode.getCorrespondingNodePath(String )with a non existing workspace.voidtestIsModified()Checks ifItem.isModified()works correctly for unmodified and modified nodes.voidtestIsNew()Checks ifItem.isNew()works correctly for new and existing, unmodified nodes.voidtestIsSameMustNotCompareStates()Tests ifItem.isSame(Item otherItem)will return true when twoNodeobjects representing the same actual repository item have been retrieved through two different sessions and one has been modified.voidtestMixinTypesProtected()Tests if jcr:mixinTypes is protectedvoidtestNodeIdentity()Tests object identity, meaning two nodes objects acquired through the same session must have the same properties and states.voidtestNodeSave()Creates a new node, saves it uses second session to verify if node has been added.voidtestPrimaryType()Tests if the primary node type is properly stored in jcr:primaryTypevoidtestPrimaryTypeProtected()Tests if jcr:primaryType is protectedvoidtestRefreshBooleanFalse()voidtestRefreshBooleanTrue()voidtestRefreshInvalidItemStateException()Tries to callItem.refresh(boolean)on a deleted node.voidtestRemoveInvalidItemStateException()Removes a node usingItem.remove()with session 1, afterwards it tries the same with session 2.voidtestRemoveMandatoryNode()Creates a node with a mandatory child node usingNode.addNode(String, String), saves on parent node then tries to delete the mandatory child node.voidtestRemoveNodeLockedItself()Tests ifNode.remove()does not throw aLockExceptionifNodeis locked.voidtestRemoveNodeParentLocked()Tests ifNode.remove()throws aLockExceptionif the parent node ofNodeis locked.voidtestRemoveNodeParentSave()Removes a node usingItem.remove(), then saves with parent's nodesItem.save()method.voidtestRemoveNodeSessionSave()Removes a node usingItem.remove(), then saves usingSession.save()method.voidtestSaveConstraintViolationException()Tries to create and save a node usingItem.save()with an mandatory property that is not set on saving time.voidtestSaveInvalidStateException()Tries to save a node usingItem.save()that was already deleted by an other session.voidtestSaveOnNewNodeRepositoryException()Tests if aRepositoryExceptionis thrown when callingNode.save()on a newly added nodevoidtestUpdate()Checks ifNode.update(String)works properly by creating the same node in two workspaces one with a child node the other with a property set.voidtestUpdateInvalidItemStateException()Tries callingNode.update(String)after node has changed in first workspace but not been saved yet.voidtestUpdateNoClone()CallsNode.update(String)for a node that only exists in current workspace.voidtestUpdateNoSuchWorkspaceException()Tries to useNode.update(String)with an invalid workspace.-
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
public void setUp() throws Exceptionto be able to test the update(String) and getCorrespondingNodePath(String) methods we need an additional workspace- Overrides:
setUpin classAbstractJCRTest- Throws:
Exception
-
tearDown
public void tearDown() throws Exceptionremove all nodes in second workspace and log out- Overrides:
tearDownin classAbstractJCRTest- Throws:
Exception
-
testGetCorrespondingNodePathNoSuchWorkspaceException
public void testGetCorrespondingNodePathNoSuchWorkspaceException() throws RepositoryExceptionCallsNode.getCorrespondingNodePath(String )with a non existing workspace.This should throw an
NoSuchWorkspaceException.- Throws:
RepositoryException
-
testGetCorrespondingNodePathItemNotFoundException
public void testGetCorrespondingNodePathItemNotFoundException() throws RepositoryException, NotExecutableExceptionCallsNode.getCorrespondingNodePath(String)on a node that has no corresponding node in second workspace
-
testGetCorrespondingNodePath
public void testGetCorrespondingNodePath() throws RepositoryException, NotExecutableExceptionCreates a node with same path in both workspaces to check ifNode.getCorrespondingNodePath(String)works properly.
-
testUpdateInvalidItemStateException
public void testUpdateInvalidItemStateException() throws RepositoryException, NotExecutableExceptionTries callingNode.update(String)after node has changed in first workspace but not been saved yet.This should throw an
InvalidItemStateException.Prerequisites:
javax.jcr.tck.propertyname1name of a String property that can be modified injavax.jcr.tck.nodetypefor testing
-
testUpdateNoSuchWorkspaceException
public void testUpdateNoSuchWorkspaceException() throws RepositoryExceptionTries to useNode.update(String)with an invalid workspace.This should throw an
NoSuchWorkspaceException.- Throws:
RepositoryException
-
testUpdateNoClone
public void testUpdateNoClone() throws RepositoryExceptionCallsNode.update(String)for a node that only exists in current workspace.
In that case nothing should happen.Prerequisites:
javax.jcr.tck.propertyname1name of a String property that can be modified injavax.jcr.tck.nodetypefor testing
- Throws:
RepositoryException
-
testUpdate
public void testUpdate() throws RepositoryException, NotExecutableExceptionChecks ifNode.update(String)works properly by creating the same node in two workspaces one with a child node the other with a property set.Calling
update()on the node with properties, should remove the properties and add the child node.Prerequisites:
javax.jcr.tck.nodetypemust allow children of same nodetype.javax.jcr.tck.propertyname1name of a String property that can be modified injavax.jcr.tck.nodetypefor testing
-
testAddNodeConstraintViolationExceptionUndefinedNodeType
public void testAddNodeConstraintViolationExceptionUndefinedNodeType() throws RepositoryExceptionTries to add a node usingNode.addNode(String)where node type can not be determined by parent (nt:baseis used as parent nodetype).This should throw a
ConstraintViolationException.- Throws:
RepositoryException
-
testAddNodeConstraintViolationExceptionProperty
public void testAddNodeConstraintViolationExceptionProperty() throws RepositoryExceptionTries to add a node usingNode.addNode(String)as a child of a property.This should throw an
ConstraintViolationException.Prerequisites:
javax.jcr.tck.propertyname1name of a String property that can be set injavax.jcr.tck.nodetypefor testing
- Throws:
RepositoryException
-
testAddNodeItemExistsException
public void testAddNodeItemExistsException() throws RepositoryExceptionTries to create a node usingNode.addNode(String, String)at a location where there is already a node with same name and the parent does not allow same name siblings.This should throw an
ItemExistsException.Prerequisites:
javax.jcr.tck.NodeTest.testAddNodeItemExistsException.nodetypenode type that does not allow same name siblings and allows to add child nodes of the same type.
- Throws:
RepositoryException
-
testAddNodePathNotFoundException
public void testAddNodePathNotFoundException() throws RepositoryExceptionTries to add a node usingNode.addNode(String)to a non existing destination node.This should throw an
PathNotFoundException.- Throws:
RepositoryException
-
testAddNodeRepositoryExceptionRelPathIndex
public void testAddNodeRepositoryExceptionRelPathIndex() throws RepositoryExceptionAdds a new node usingNode.addNode(String)with an index for the new name.This should throw an
RepositoryException.- Throws:
RepositoryException
-
testAddNodeRepositoryExceptionSaveOnNewNode
public void testAddNodeRepositoryExceptionSaveOnNewNode() throws RepositoryExceptionCreates a new node usingNode.addNode(String), then tries to callItem.save()on the newly node.This should throw an
RepositoryException.- Throws:
RepositoryException
-
testAddNodeParentSave
public void testAddNodeParentSave() throws RepositoryExceptionCreates a new node usingNode.addNode(String), saves usingItem.save()on parent node. Uses a second session to verify if the node has been saved.- Throws:
RepositoryException
-
testAddNodeSessionSave
public void testAddNodeSessionSave() throws RepositoryExceptionCreates a new node usingNode.addNode(String), saves usingSession.save(). Uses a second session to verify if the node has been saved.- Throws:
RepositoryException
-
testAddNodeLackingMandatoryChildNode
public void testAddNodeLackingMandatoryChildNode() throws RepositoryExceptionCreates a node without its mandatory child node usingNode.addNode(String, String)and then saves.This should throw a
ConstraintViolationException.Prerequisites:
javax.jcr.tck.NodeTest.testAddNodeLackingMandatoryChildNode.nodetype2a node type that has a mandatory child node
- Throws:
RepositoryException
-
testRemoveMandatoryNode
public void testRemoveMandatoryNode() throws RepositoryExceptionCreates a node with a mandatory child node usingNode.addNode(String, String), saves on parent node then tries to delete the mandatory child node.This should throw a
ConstraintViolationException.Prerequisites:
javax.jcr.tck.NodeTest.testRemoveMandatoryNode.nodetype2a node type that has a mandatory child nodejavax.jcr.tck.NodeTest.testRemoveMandatoryNode.nodetype3nodetype of the mandatory child nodejavax.jcr.tck.NodeTest.testRemoveMandatoryNode.nodename3name of the mandatory child node
- Throws:
RepositoryException
-
testRemoveInvalidItemStateException
public void testRemoveInvalidItemStateException() throws RepositoryExceptionRemoves a node usingItem.remove()with session 1, afterwards it tries the same with session 2.This should throw an
InvalidItemStateException.- Throws:
RepositoryException
-
testRemoveNodeParentSave
public void testRemoveNodeParentSave() throws RepositoryExceptionRemoves a node usingItem.remove(), then saves with parent's nodesItem.save()method.- Throws:
RepositoryException
-
testRemoveNodeSessionSave
public void testRemoveNodeSessionSave() throws RepositoryExceptionRemoves a node usingItem.remove(), then saves usingSession.save()method.- Throws:
RepositoryException
-
testRemoveNodeLockedItself
public void testRemoveNodeLockedItself() throws LockException, NotExecutableException, RepositoryExceptionTests ifNode.remove()does not throw aLockExceptionifNodeis locked.The test creates a node
nodeName1of typetestNodeTypeundertestRootand locks the node with the superuser session. Then the test removesnodeName1.
-
testRemoveNodeParentLocked
public void testRemoveNodeParentLocked() throws LockException, NotExecutableException, RepositoryExceptionTests ifNode.remove()throws aLockExceptionif the parent node ofNodeis locked.The test creates a node
nodeName1of typetestNodeTypeundertestRoot, adds a child nodenodeName2and locks it with the superuser session. Then the test tries to remove thenodeName2.
-
testNodeIdentity
public void testNodeIdentity() throws RepositoryExceptionTests object identity, meaning two nodes objects acquired through the same session must have the same properties and states.Prerequisites:
javax.jcr.tck.nodetypemust allow children of same node typejavax.jcr.tck.propertyname1name of a String property that can be set injavax.jcr.tck.nodetypefor testing
- Throws:
RepositoryException
-
testIsSameMustNotCompareStates
public void testIsSameMustNotCompareStates() throws RepositoryExceptionTests ifItem.isSame(Item otherItem)will return true when twoNodeobjects representing the same actual repository item have been retrieved through two different sessions and one has been modified.- Throws:
RepositoryException
-
testIsModified
public void testIsModified() throws RepositoryExceptionChecks ifItem.isModified()works correctly for unmodified and modified nodes.- Throws:
RepositoryException
-
testIsNew
public void testIsNew() throws RepositoryExceptionChecks ifItem.isNew()works correctly for new and existing, unmodified nodes.- Throws:
RepositoryException
-
testRefreshInvalidItemStateException
public void testRefreshInvalidItemStateException() throws RepositoryExceptionTries to callItem.refresh(boolean)on a deleted node.This should throw an
InvalidItemStateException.- Throws:
RepositoryException
-
testRefreshBooleanFalse
public void testRefreshBooleanFalse() throws RepositoryExceptionChecks ifItem.refresh(boolean refresh)works properly withrefreshset tofalse.Procedure:
- Creates two nodes with session 1
- Modifies node 1 with session 1 by adding a child node
- Get node 2 with session 2
- Modifies node 2 with session 2 by adding a child node
- saves session 2 changes using
Item.save() - calls
Node.refresh(false)on root node in session 1
Prerequisites:
javax.jcr.tck.nodetypemust accept children of same nodetype
- Throws:
RepositoryException
-
testRefreshBooleanTrue
public void testRefreshBooleanTrue() throws RepositoryExceptionChecks ifItem.refresh(boolean refresh)works properly withrefreshset totrue.Procedure:
- Creates two nodes with session 1
- Modifies node 1 with session 1 by adding a child node
- Get node 2 with session 2
- Modifies node 2 with session 2 by adding a child node
- saves session 2 changes using
Item.save() - calls
Node.refresh(true)on root node in session 1
Prerequisites:
javax.jcr.tck.nodetypemust accept children of same nodetype
- Throws:
RepositoryException
-
testSaveInvalidStateException
public void testSaveInvalidStateException() throws RepositoryExceptionTries to save a node usingItem.save()that was already deleted by an other session.Procedure:
- Creates a new node with session 1, saves it, adds a child node.
- Access new node with session 2,deletes the node, saves it.
- Session 1 tries
to save modifications using
Node.save()on root node .
InvalidItemStateException.Prerequisites:
javax.jcr.tck.nodetypemust accept children of same nodetype
- Throws:
RepositoryException
-
testSaveConstraintViolationException
public void testSaveConstraintViolationException() throws RepositoryExceptionTries to create and save a node usingItem.save()with an mandatory property that is not set on saving time.Prerequisites:
javax.jcr.tck.Node.testSaveConstraintViolationException.nodetype2must reference a nodetype that has at least one property that is mandatory but not autocreated
- Throws:
RepositoryException
-
testNodeSave
public void testNodeSave() throws RepositoryExceptionCreates a new node, saves it uses second session to verify if node has been added.- Throws:
RepositoryException
-
testSaveOnNewNodeRepositoryException
public void testSaveOnNewNodeRepositoryException() throws ExceptionTests if aRepositoryExceptionis thrown when callingNode.save()on a newly added node- Throws:
Exception
-
testPrimaryType
public void testPrimaryType() throws ExceptionTests if the primary node type is properly stored in jcr:primaryType- Throws:
Exception
-
testPrimaryTypeProtected
public void testPrimaryTypeProtected() throws ExceptionTests if jcr:primaryType is protected- Throws:
Exception
-
-