public class NodeTest extends AbstractJCRTest
NodeTest contains all test cases for the
javax.jcr.Node that are related to writing, modifying or deleting
nodes (level 2 of the specification).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, ntBase, ntFrozenNode, ntQuery, ntUnstructured, ntVersion, ntVersionHistory, ntVersionLabels, propertyName1, propertyName2, superuser, testNodeType, testNodeTypeNoChildren, testNodeTypeTestRoot, testPath, testRoot, testRootNode, vf, workspaceName| Constructor and Description |
|---|
NodeTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
setUp()
to be able to test the update(String) and getCorrespondingNodePath(String)
methods we need an additional workspace
|
void |
tearDown()
remove all nodes in second workspace and log out
|
void |
testAddNodeConstraintViolationExceptionProperty()
Tries to add a node using
Node.addNode(String) as a
child of a property. |
void |
testAddNodeConstraintViolationExceptionUndefinedNodeType()
Tries to add a node using
Node.addNode(String) where
node type can not be determined by parent (nt:base is used
as parent nodetype). |
void |
testAddNodeItemExistsException()
Tries to create a node using
Node.addNode(String,
String) at a location where there is already a node with same name and
the parent does not allow same name siblings. |
void |
testAddNodeParentSave()
Creates a new node using
Node.addNode(String) , saves using
Item.save() on parent node. |
void |
testAddNodePathNotFoundException()
Tries to add a node using
Node.addNode(String) to a non
existing destination node. |
void |
testAddNodeRepositoryExceptionRelPathIndex()
Adds a new node using
Node.addNode(String) with an
index for the new name. |
void |
testAddNodeRepositoryExceptionSaveOnNewNode()
Creates a new node using
Node.addNode(String), then tries to call
Item.save() on the newly node. |
void |
testAddNodeSessionSave()
Creates a new node using
Node.addNode(String) , saves using
Session.save(). |
void |
testGetCorrespondingNodePath()
Creates a node with same path in both workspaces to check if
Node.getCorrespondingNodePath(String) works properly. |
void |
testGetCorrespondingNodePathItemNotFoundException()
Calls
Node.getCorrespondingNodePath(String) on a node
that has no corresponding node in second workspace |
void |
testGetCorrespondingNodePathNoSuchWorkspaceException()
Calls
Node.getCorrespondingNodePath(String ) with a non
existing workspace. |
void |
testIsModified()
Checks if
Item.isModified() works correctly for unmodified and
modified nodes. |
void |
testIsNew()
Checks if
Item.isNew() works correctly for new and existing,
unmodified nodes. |
void |
testIsSameMustNotCompareStates()
Tests if
Item.isSame(Item otherItem) will return true when
two Node objects representing the same actual repository
item have been retrieved through two different sessions and one has been
modified. |
void |
testMixinTypesProtected()
Tests if jcr:mixinTypes is protected
|
void |
testNodeIdentity()
Tests object identity, meaning two nodes objects acquired through the
same session must have the same properties and states.
|
void |
testNodeSave()
Creates a new node, saves it uses second session to verify if node has
been added.
|
void |
testPrimaryType()
Tests if the primary node type is properly stored in jcr:primaryType
|
void |
testPrimaryTypeProtected()
Tests if jcr:primaryType is protected
|
void |
testRefreshBooleanFalse()
Checks if
Item.refresh(boolean refresh) works properly
with refresh set to false. |
void |
testRefreshBooleanTrue()
Checks if
Item.refresh(boolean refresh) works properly
with refresh set to true. |
void |
testRefreshInvalidItemStateException()
Tries to call
Item.refresh(boolean) on a deleted node. |
void |
testRemoveInvalidItemStateException()
Removes a node using
Item.remove() with session 1,
afterwards it tries the same with session 2. |
void |
testRemoveMandatoryNode()
Creates a node with a mandatory child node using
Node.addNode(String, String), saves on parent node then tries to delete
the mandatory child node. |
void |
testRemoveNodeLockedItself()
Tests if
Node.remove() does not throw a
LockException if Node is locked. |
void |
testRemoveNodeParentLocked()
Tests if
Node.remove() throws a LockException
if the parent node of Node is locked. |
void |
testRemoveNodeParentSave()
Removes a node using
Item.remove(), then saves with
parent's nodes Item.save() method. |
void |
testRemoveNodeSessionSave()
Removes a node using
Item.remove(), then saves using
Session.save() method. |
void |
testSaveConstraintViolationException()
Tries to create and save a node using
Item.save() with
an mandatory property that is not set on saving time. |
void |
testSaveInvalidStateException()
Tries to save a node using
Item.save() that was already
deleted by an other session. |
void |
testSaveOnNewNodeRepositoryException()
Tests if a
RepositoryException is thrown when calling
Node.save() on a newly added node |
void |
testUpdate()
Checks if
Node.update(String) works properly by
creating the same node in two workspaces one with a child node the other
with a property set. |
void |
testUpdateInvalidItemStateException()
Tries calling
Node.update(String) after node has
changed in first workspace but not been saved yet. |
void |
testUpdateNoClone()
Calls
Node.update(String) for a node that only exists
in current workspace. |
void |
testUpdateNoSuchWorkspaceException()
Tries to use
Node.update(String) with an invalid
workspace. |
checkSupportedOption, cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureKnowsNodeType, ensureLockingSupported, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getPrefix, getProperty, getProperty, getQualifiedName, getSize, isSupported, needsMixin, runassertEquals, 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, toStringpublic void setUp()
throws Exception
setUp in class AbstractJCRTestExceptionpublic void tearDown()
throws Exception
tearDown in class AbstractJCRTestExceptionpublic void testGetCorrespondingNodePathNoSuchWorkspaceException()
throws javax.jcr.RepositoryException
Node.getCorrespondingNodePath(String ) with a non
existing workspace.
This should throw an NoSuchWorkspaceException.
javax.jcr.RepositoryExceptionpublic void testGetCorrespondingNodePathItemNotFoundException()
throws javax.jcr.RepositoryException,
NotExecutableException
Node.getCorrespondingNodePath(String) on a node
that has no corresponding node in second workspacejavax.jcr.RepositoryExceptionNotExecutableExceptionpublic void testGetCorrespondingNodePath()
throws javax.jcr.RepositoryException,
NotExecutableException
Node.getCorrespondingNodePath(String) works properly.javax.jcr.RepositoryExceptionNotExecutableExceptionpublic void testUpdateInvalidItemStateException()
throws javax.jcr.RepositoryException,
NotExecutableException
Node.update(String) after node has
changed in first workspace but not been saved yet.
This should throw an InvalidItemStateException.
Prerequisites:
javax.jcr.tck.propertyname1 name of
a String property that can be modified in javax.jcr.tck.nodetype
for testingjavax.jcr.RepositoryExceptionNotExecutableExceptionpublic void testUpdateNoSuchWorkspaceException()
throws javax.jcr.RepositoryException
Node.update(String) with an invalid
workspace.
This should throw an NoSuchWorkspaceException.
javax.jcr.RepositoryExceptionpublic void testUpdateNoClone()
throws javax.jcr.RepositoryException
Node.update(String) for a node that only exists
in current workspace. Prerequisites:
javax.jcr.tck.propertyname1
name of a String property that can be modified in
javax.jcr.tck.nodetype for testingjavax.jcr.RepositoryExceptionpublic void testUpdate()
throws javax.jcr.RepositoryException,
NotExecutableException
Node.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.nodetype
must allow children of same nodetype. javax.jcr.tck.propertyname1
name of a String property that can be modified in
javax.jcr.tck.nodetype for testingjavax.jcr.RepositoryExceptionNotExecutableExceptionpublic void testAddNodeConstraintViolationExceptionUndefinedNodeType()
throws javax.jcr.RepositoryException
Node.addNode(String) where
node type can not be determined by parent (nt:base is used
as parent nodetype).
This should throw a ConstraintViolationException.
javax.jcr.RepositoryExceptionpublic void testAddNodeConstraintViolationExceptionProperty()
throws javax.jcr.RepositoryException
Node.addNode(String) as a
child of a property.
This should throw an ConstraintViolationException.
Prerequisites:
javax.jcr.tck.propertyname1
name of a String property that can be set in javax.jcr.tck.nodetype
for testingjavax.jcr.RepositoryExceptionpublic void testAddNodeItemExistsException()
throws javax.jcr.RepositoryException
Node.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.nodetype
node type that does not allow same name siblings and allows to add child
nodes of the same type.javax.jcr.RepositoryExceptionpublic void testAddNodePathNotFoundException()
throws javax.jcr.RepositoryException
Node.addNode(String) to a non
existing destination node.
This should throw an PathNotFoundException.
javax.jcr.RepositoryExceptionpublic void testAddNodeRepositoryExceptionRelPathIndex()
throws javax.jcr.RepositoryException
Node.addNode(String) with an
index for the new name.
This should throw an RepositoryException.
javax.jcr.RepositoryExceptionpublic void testAddNodeRepositoryExceptionSaveOnNewNode()
throws javax.jcr.RepositoryException
Node.addNode(String), then tries to call
Item.save() on the newly node.
This should throw an RepositoryException.
javax.jcr.RepositoryExceptionpublic void testAddNodeParentSave()
throws javax.jcr.RepositoryException
Node.addNode(String) , saves using
Item.save() on parent node. Uses a second session to
verify if the node has been saved.javax.jcr.RepositoryExceptionpublic void testAddNodeSessionSave()
throws javax.jcr.RepositoryException
Node.addNode(String) , saves using
Session.save(). Uses a second session to verify if the
node has been saved.javax.jcr.RepositoryExceptionpublic void testRemoveMandatoryNode()
throws javax.jcr.RepositoryException
Node.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.nodetype2
a node type that has a mandatory child nodejavax.jcr.tck.NodeTest.testRemoveMandatoryNode.nodetype3
nodetype of the mandatory child nodejavax.jcr.tck.NodeTest.testRemoveMandatoryNode.nodename3
name of the mandatory child nodejavax.jcr.RepositoryExceptionpublic void testRemoveInvalidItemStateException()
throws javax.jcr.RepositoryException
Item.remove() with session 1,
afterwards it tries the same with session 2.
This should throw an InvalidItemStateException.
javax.jcr.RepositoryExceptionpublic void testRemoveNodeParentSave()
throws javax.jcr.RepositoryException
Item.remove(), then saves with
parent's nodes Item.save() method.javax.jcr.RepositoryExceptionpublic void testRemoveNodeSessionSave()
throws javax.jcr.RepositoryException
Item.remove(), then saves using
Session.save() method.javax.jcr.RepositoryExceptionpublic void testRemoveNodeLockedItself()
throws javax.jcr.lock.LockException,
NotExecutableException,
javax.jcr.RepositoryException
Node.remove() does not throw a
LockException if Node is locked.
The test creates a node nodeName1 of type
testNodeType under testRoot and locks the node
with the superuser session. Then the test removes
nodeName1.
javax.jcr.lock.LockExceptionNotExecutableExceptionjavax.jcr.RepositoryExceptionpublic void testRemoveNodeParentLocked()
throws javax.jcr.lock.LockException,
NotExecutableException,
javax.jcr.RepositoryException
Node.remove() throws a LockException
if the parent node of Node is locked.
The test creates a node nodeName1 of type
testNodeType under testRoot, adds a child node
nodeName2 and locks it with the superuser session. Then the
test tries to remove the nodeName2.
javax.jcr.lock.LockExceptionNotExecutableExceptionjavax.jcr.RepositoryExceptionpublic void testNodeIdentity()
throws javax.jcr.RepositoryException
Prerequisites:
javax.jcr.tck.nodetype must allow
children of same node typejavax.jcr.tck.propertyname1
name of a String property that can be set in javax.jcr.tck.nodetype
for testingjavax.jcr.RepositoryExceptionpublic void testIsSameMustNotCompareStates()
throws javax.jcr.RepositoryException
Item.isSame(Item otherItem) will return true when
two Node objects representing the same actual repository
item have been retrieved through two different sessions and one has been
modified.javax.jcr.RepositoryExceptionpublic void testIsModified()
throws javax.jcr.RepositoryException
Item.isModified() works correctly for unmodified and
modified nodes.javax.jcr.RepositoryExceptionpublic void testIsNew()
throws javax.jcr.RepositoryException
Item.isNew() works correctly for new and existing,
unmodified nodes.javax.jcr.RepositoryExceptionpublic void testRefreshInvalidItemStateException()
throws javax.jcr.RepositoryException
Item.refresh(boolean) on a deleted node.
This should throw an InvalidItemStateException.
javax.jcr.RepositoryExceptionpublic void testRefreshBooleanFalse()
throws javax.jcr.RepositoryException
Item.refresh(boolean refresh) works properly
with refresh set to false.
Procedure:
Item.save()Node.refresh(false)
on root node in session 1Prerequisites:
javax.jcr.tck.nodetype
must accept children of same nodetypejavax.jcr.RepositoryExceptionpublic void testRefreshBooleanTrue()
throws javax.jcr.RepositoryException
Item.refresh(boolean refresh) works properly
with refresh set to true.
Procedure:
Item.save()Node.refresh(true) on
root node in session 1Prerequisites:
javax.jcr.tck.nodetype must accept children of same
nodetypejavax.jcr.RepositoryExceptionpublic void testSaveInvalidStateException()
throws javax.jcr.RepositoryException
Item.save() that was already
deleted by an other session.
Procedure:
Node.save() on root node .InvalidItemStateException.
Prerequisites:
javax.jcr.tck.nodetype
must accept children of same nodetypejavax.jcr.RepositoryExceptionpublic void testSaveConstraintViolationException()
throws javax.jcr.RepositoryException
Item.save() with
an mandatory property that is not set on saving time.
Prerequisites:
javax.jcr.tck.Node.testSaveConstraintViolationException.nodetype2
must reference a nodetype that has at least one property that is
mandatory but not autocreatedjavax.jcr.RepositoryExceptionpublic void testNodeSave()
throws javax.jcr.RepositoryException
javax.jcr.RepositoryExceptionpublic void testSaveOnNewNodeRepositoryException()
throws Exception
RepositoryException is thrown when calling
Node.save() on a newly added nodeExceptionpublic void testPrimaryType()
throws Exception
Exceptionpublic void testPrimaryTypeProtected()
throws Exception
ExceptionCopyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.