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, ntActivity, 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 |
testAddNodeLackingMandatoryChildNode()
Creates a node without its mandatory child node using
Node.addNode(String, String) and then saves. |
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()
|
void |
testRefreshBooleanTrue()
|
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, run
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
public void setUp() throws Exception
setUp
in class AbstractJCRTest
Exception
public void tearDown() throws Exception
tearDown
in class AbstractJCRTest
Exception
public void testGetCorrespondingNodePathNoSuchWorkspaceException() throws RepositoryException
Node.getCorrespondingNodePath(String )
with a non
existing workspace.
This should throw an NoSuchWorkspaceException
.
RepositoryException
public void testGetCorrespondingNodePathItemNotFoundException() throws RepositoryException, NotExecutableException
Node.getCorrespondingNodePath(String)
on a node
that has no corresponding node in second workspacepublic void testGetCorrespondingNodePath() throws RepositoryException, NotExecutableException
Node.getCorrespondingNodePath(String)
works properly.public void testUpdateInvalidItemStateException() throws 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 testingpublic void testUpdateNoSuchWorkspaceException() throws RepositoryException
Node.update(String)
with an invalid
workspace.
This should throw an NoSuchWorkspaceException
.
RepositoryException
public void testUpdateNoClone() throws 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 testingRepositoryException
public void testUpdate() throws 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 testingpublic void testAddNodeConstraintViolationExceptionUndefinedNodeType() throws 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
.
RepositoryException
public void testAddNodeConstraintViolationExceptionProperty() throws 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 testingRepositoryException
public void testAddNodeItemExistsException() throws 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.RepositoryException
public void testAddNodePathNotFoundException() throws RepositoryException
Node.addNode(String)
to a non
existing destination node.
This should throw an PathNotFoundException
.
RepositoryException
public void testAddNodeRepositoryExceptionRelPathIndex() throws RepositoryException
Node.addNode(String)
with an
index for the new name.
This should throw an RepositoryException
.
RepositoryException
public void testAddNodeRepositoryExceptionSaveOnNewNode() throws RepositoryException
Node.addNode(String)
, then tries to call
Item.save()
on the newly node.
This should throw an RepositoryException
.
RepositoryException
public void testAddNodeParentSave() throws RepositoryException
Node.addNode(String)
, saves using
Item.save()
on parent node. Uses a second session to
verify if the node has been saved.RepositoryException
public void testAddNodeSessionSave() throws RepositoryException
Node.addNode(String)
, saves using
Session.save()
. Uses a second session to verify if the
node has been saved.RepositoryException
public void testAddNodeLackingMandatoryChildNode() throws RepositoryException
Node.addNode(String, String)
and then saves.
This should throw a ConstraintViolationException
.
Prerequisites:
javax.jcr.tck.NodeTest.testAddNodeLackingMandatoryChildNode.nodetype2
a node type that has a mandatory child nodeRepositoryException
public void testRemoveMandatoryNode() throws 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 nodeRepositoryException
public void testRemoveInvalidItemStateException() throws RepositoryException
Item.remove()
with session 1,
afterwards it tries the same with session 2.
This should throw an InvalidItemStateException
.
RepositoryException
public void testRemoveNodeParentSave() throws RepositoryException
Item.remove()
, then saves with
parent's nodes Item.save()
method.RepositoryException
public void testRemoveNodeSessionSave() throws RepositoryException
Item.remove()
, then saves using
Session.save()
method.RepositoryException
public void testRemoveNodeLockedItself() throws LockException, NotExecutableException, 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
.
public void testRemoveNodeParentLocked() throws LockException, NotExecutableException, 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
.
public void testNodeIdentity() throws 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 testingRepositoryException
public void testIsSameMustNotCompareStates() throws 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.RepositoryException
public void testIsModified() throws RepositoryException
Item.isModified()
works correctly for unmodified and
modified nodes.RepositoryException
public void testIsNew() throws RepositoryException
Item.isNew()
works correctly for new and existing,
unmodified nodes.RepositoryException
public void testRefreshInvalidItemStateException() throws RepositoryException
Item.refresh(boolean)
on a deleted node.
This should throw an InvalidItemStateException
.
RepositoryException
public void testRefreshBooleanFalse() throws 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 nodetypeRepositoryException
public void testRefreshBooleanTrue() throws 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
nodetypeRepositoryException
public void testSaveInvalidStateException() throws 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 nodetypeRepositoryException
public void testSaveConstraintViolationException() throws 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 autocreatedRepositoryException
public void testNodeSave() throws RepositoryException
RepositoryException
public void testSaveOnNewNodeRepositoryException() throws Exception
RepositoryException
is thrown when calling
Node.save()
on a newly added nodeException
public void testPrimaryType() throws Exception
Exception
public void testPrimaryTypeProtected() throws Exception
Exception
Copyright © 2004–2023 The Apache Software Foundation. All rights reserved.