use of javax.jcr.Node in project jackrabbit by apache.
the class AddMixinTest method testAddMultipleSeparately.
/**
* Implementation specific test adding a new Node with a nodeType, that has
* a mixin-supertype. The mixin must only take effect upon save.
*
* @throws NotExecutableException
* @throws RepositoryException
*/
public void testAddMultipleSeparately() throws NotExecutableException, RepositoryException {
Node node;
try {
node = testRootNode.addNode(nodeName1, testNodeType);
node.addMixin(mixReferenceable);
testRootNode.save();
node.addMixin(mixLockable);
testRootNode.save();
} catch (RepositoryException e) {
throw new NotExecutableException();
}
assertTrue("Adding 2 mixins at once -> both must be present.", node.isNodeType(mixReferenceable) && node.isNodeType(mixLockable));
List<NodeType> mixins = Arrays.asList(node.getMixinNodeTypes());
assertTrue("Adding 2 mixins at once -> both must be present.", mixins.contains(ntMgr.getNodeType(mixReferenceable)) && mixins.contains(ntMgr.getNodeType(mixLockable)));
}
use of javax.jcr.Node in project jackrabbit by apache.
the class AddMixinTest method testAddMultipleAtOnce.
/**
* Implementation specific test adding a new Node with a nodeType, that has
* a mixin-supertype. The mixin must only take effect upon save.
*
* @throws NotExecutableException
* @throws RepositoryException
*/
public void testAddMultipleAtOnce() throws NotExecutableException, RepositoryException {
Node node;
try {
node = testRootNode.addNode(nodeName1, testNodeType);
node.addMixin(mixReferenceable);
node.addMixin(mixLockable);
testRootNode.save();
} catch (RepositoryException e) {
throw new NotExecutableException();
}
assertTrue("Adding 2 mixins at once -> both must be present.", node.isNodeType(mixReferenceable) && node.isNodeType(mixLockable));
}
use of javax.jcr.Node in project jackrabbit by apache.
the class AddMixinTest method testAddItemsDefinedByMixin3.
public void testAddItemsDefinedByMixin3() throws NotExecutableException, RepositoryException {
// register mixin
NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager();
NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
ntd.setName("testMixin");
ntd.setMixin(true);
NodeDefinitionTemplate nodeDef = ntm.createNodeDefinitionTemplate();
nodeDef.setName("child");
nodeDef.setRequiredPrimaryTypeNames(new String[] { "nt:folder" });
nodeDef.setDefaultPrimaryTypeName("nt:folder");
ntd.getNodeDefinitionTemplates().add(nodeDef);
ntm.registerNodeType(ntd, true);
// create node and add mixin
Node node = testRootNode.addNode(nodeName1, "nt:resource");
node.setProperty("jcr:data", "abc");
node.addMixin("testMixin");
superuser.save();
// create a child node defined by the mixin without specifying the
// node type -> must succeed since default primary type is specified
// in the child node def
Node c = node.addNode("child");
assertEquals("nt:folder", c.getPrimaryNodeType().getName());
superuser.save();
}
use of javax.jcr.Node in project jackrabbit by apache.
the class OpenScopedLockTest method testRefreshAfterTokenTransfer2.
public void testRefreshAfterTokenTransfer2() throws Exception {
String lockToken = lock.getLockToken();
Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
try {
superuser.removeLockToken(lockToken);
otherSession.addLockToken(lockToken);
n2.getLock().refresh();
} finally {
// move lock token back in order to have lock removed properly
otherSession.removeLockToken(lockToken);
superuser.addLockToken(lockToken);
}
}
use of javax.jcr.Node in project jackrabbit by apache.
the class OpenScopedLockTest method testLogoutHasNoEffect.
public void testLogoutHasNoEffect() throws Exception {
// create a second session session. since logout of the 'superuser'
// will cause all inherited tear-down to fail
Node testRoot2 = (Node) otherSession.getItem(testRootNode.getPath());
Node lockedNode2 = testRoot2.addNode(nodeName2, testNodeType);
lockedNode2.addMixin(mixLockable);
testRoot2.save();
Lock lock2 = lockedNode2.lock(false, isSessionScoped());
// force reloading of the testroot in order to be aware of the
// locked node added by another session
testRootNode.refresh(false);
Node n2 = (Node) superuser.getItem(lockedNode2.getPath());
try {
String lockToken = lock2.getLockToken();
otherSession.removeLockToken(lockToken);
superuser.addLockToken(lockToken);
otherSession.logout();
assertTrue("After logout a open-scoped node must still be locked.", lock2.isLive());
assertTrue("After logout a open-scoped node must still be locked.", n2.isLocked());
} finally {
n2.unlock();
}
}
Aggregations