use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class WorkspaceRestoreTest method testWorkspaceRestoreWithUUIDConflict.
/**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
@SuppressWarnings("deprecation")
public void testWorkspaceRestoreWithUUIDConflict() throws RepositoryException, NotExecutableException {
try {
// Verify that nodes used for the test are indeed versionable
NodeDefinition nd = wVersionableNode.getDefinition();
if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
throw new NotExecutableException("Nodes must be versionable in order to run this test.");
}
Version v = wVersionableNode.checkin();
wVersionableNode.checkout();
wSuperuser.move(wVersionableChildNode.getPath(), wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName());
wSuperuser.save();
wSuperuser.getWorkspace().restore(new Version[] { v }, false);
fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
} catch (ItemExistsException e) {
// success
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class RestoreTest method testRestoreWithUUIDConflictJcr2_3.
/**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
public void testRestoreWithUUIDConflictJcr2_3() throws RepositoryException, NotExecutableException {
try {
Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
// Verify that nodes used for the test have proper opv behaviour
NodeDefinition nd = naa.getDefinition();
if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
}
Version v = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
superuser.save();
versionManager.restore(versionableNode.getPath(), v.getName(), false);
fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
} catch (ItemExistsException e) {
// success
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class SessionImportTest method testEmptyMixins2.
/**
* Test case for issue <a href="https://issues.apache.org/jira/browse/JCR-1857">JCR-1857</href>
*
* @throws IOException
* @throws RepositoryException
*/
public void testEmptyMixins2() throws IOException, RepositoryException, NotExecutableException {
/*
look for a a node type that includes mix:referenceable but isn't any
of the known internal nodetypes that ev. cannot be created through a
session-import
*/
String referenceableNt = null;
NodeTypeIterator it = superuser.getWorkspace().getNodeTypeManager().getPrimaryNodeTypes();
while (it.hasNext() && referenceableNt == null) {
NodeType nt = it.nextNodeType();
String ntName = nt.getName();
if (nt.isNodeType(mixReferenceable) && !nt.isAbstract() && // ignore are built-in nodetypes (mostly version related)
!ntName.startsWith("nt:") && // also skip all internal node types...
!ntName.startsWith("rep:")) {
referenceableNt = ntName;
}
}
if (referenceableNt == null) {
throw new NotExecutableException("No primary type found that extends from mix:referenceable.");
}
/*
TODO: retrieve valid jcr:uuid value from test-properties.
*/
String uuid = UUID.randomUUID().toString();
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sv:node xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" + " xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\"\n" + " xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\"\n" + " xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"\n" + " sv:name=\"testnode1\">\n" + " <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">\n" + " <sv:value>" + referenceableNt + "</sv:value>\n" + " </sv:property>\n" + " <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\">\n" + " <sv:value>" + uuid + "</sv:value>\n" + " </sv:property>\n" + "</sv:node>";
InputStream in = new ByteArrayInputStream(xml.getBytes());
superuser.importXML(testRootNode.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeCorruptionTest method testCopyMultiSingleValue.
public void testCopyMultiSingleValue() throws Exception {
Node root = superuser.getRootNode();
String nodeName = "testCopyMulti" + System.currentTimeMillis();
if (root.hasNode(nodeName)) {
root.getNode(nodeName).remove();
superuser.save();
}
Node test = root.addNode(nodeName);
test.setProperty("x", "Hi");
superuser.save();
String wsp = superuser.getWorkspace().getName();
String workspace2 = getAlternativeWorkspaceName();
if (workspace2 == null) {
throw new NotExecutableException();
}
Session s2 = getHelper().getSuperuserSession(workspace2);
s2.getWorkspace().clone(wsp, "/" + nodeName, "/" + nodeName, true);
Node test2 = s2.getRootNode().getNode(nodeName);
test2.setProperty("x", (Value) null);
test2.setProperty("x", new String[] {});
s2.save();
test.update(workspace2);
try {
Value[] values = test.getProperty("x").getValues();
assertEquals(0, values.length);
} catch (RepositoryException e) {
// if we get here, it's a bug, as it is a multi-valued property now
// anyway, let's see what happens if we try to read it as a single valued property
test.getProperty("x").getValue();
// even if that works: it's still a bug
throw e;
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class WriteTest method testEditor2.
public void testEditor2() throws NotExecutableException, RepositoryException {
UserManager uMgr = getUserManager(superuser);
User u = null;
User u2 = null;
try {
u = uMgr.createUser("t", "t");
u2 = uMgr.createUser("tt", "tt", new TestPrincipal("tt"), "t/tt");
if (!uMgr.isAutoSave()) {
superuser.save();
}
Principal p = u.getPrincipal();
Principal p2 = u2.getPrincipal();
if (p instanceof ItemBasedPrincipal && p2 instanceof ItemBasedPrincipal && Text.isDescendant(((ItemBasedPrincipal) p).getPath(), ((ItemBasedPrincipal) p2).getPath())) {
JackrabbitAccessControlManager acMgr = (JackrabbitAccessControlManager) getAccessControlManager(superuser);
JackrabbitAccessControlPolicy[] acls = acMgr.getApplicablePolicies(p2);
acMgr.setPolicy(acls[0].getPath(), acls[0]);
acls = acMgr.getApplicablePolicies(p);
String path = acls[0].getPath();
Node n = superuser.getNode(path);
assertEquals("rep:PrincipalAccessControl", n.getPrimaryNodeType().getName());
} else {
throw new NotExecutableException();
}
} finally {
superuser.refresh(false);
if (u2 != null)
u2.remove();
if (u != null)
u.remove();
if (!uMgr.isAutoSave()) {
superuser.save();
}
}
}
Aggregations