use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodesTest method testRemoveShare.
public void testRemoveShare() throws RepositoryException {
Node n1 = testRootNode.addNode(nodeName1);
Node n2 = testRootNode.addNode(nodeName2);
Node s = n1.addNode(nodeName3);
s.addMixin(mixShareable);
testRootNode.save();
Workspace wsp = superuser.getWorkspace();
wsp.clone(wsp.getName(), s.getPath(), n2.getPath() + "/" + s.getName(), false);
EventResult result = new EventResult(log);
addEventListener(result);
removeFromSharedSet(n2.getNode(nodeName3));
testRootNode.save();
checkNodeRemoved(result.getEvents(DEFAULT_WAIT_TIMEOUT), new String[] { nodeName2 + "/" + nodeName3 }, new String[0]);
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodesTest method testAddShare.
public void testAddShare() throws RepositoryException {
Node n1 = testRootNode.addNode(nodeName1);
Node n2 = testRootNode.addNode(nodeName2);
Node s = n1.addNode(nodeName3);
s.addMixin(mixShareable);
testRootNode.save();
EventResult result = new EventResult(log);
addEventListener(result);
Workspace wsp = superuser.getWorkspace();
wsp.clone(wsp.getName(), s.getPath(), n2.getPath() + "/" + s.getName(), false);
checkNodeAdded(result.getEvents(DEFAULT_WAIT_TIMEOUT), new String[] { nodeName2 + "/" + nodeName3 }, new String[0]);
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testImportExportNtShare.
/**
* Verify export and import of a tree containing multiple nodes in the
* same shared set (6.13.14). The first serialized node in that shared
* set is serialized in the normal fashion (with all of its properties
* and children), but any subsequent shared node in that shared set is
* serialized as a special node of type <code>nt:share</code>, which
* contains only the <code>jcr:uuid</code> property of the shared node
* and the <code>jcr:primaryType</code> property indicating the type
* <code>nt:share</code>.
*/
public void testImportExportNtShare() throws Exception {
// setup parent nodes and first child
Node p = testRootNode.addNode("p");
Node a1 = p.addNode("a1");
Node a2 = p.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Session session = b1.getSession();
Workspace workspace = session.getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false);
// create temp file
File tmpFile = File.createTempFile("test", null);
tmpFile.deleteOnExit();
// export system view of /p
OutputStream out = new FileOutputStream(tmpFile);
try {
session.exportSystemView(p.getPath(), out, false, false);
} finally {
out.close();
}
// delete p and save
p.remove();
testRootNode.getSession().save();
// and import again underneath test root
InputStream in = new FileInputStream(tmpFile);
try {
workspace.importXML(testRootNode.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
} finally {
try {
in.close();
} catch (IOException ignore) {
}
}
// verify shared set consists of two nodes
Node[] shared = getSharedSet(testRootNode.getNode("p/a1/b1"));
assertEquals(2, shared.length);
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testSearch.
/**
* Verify that a descendant of a shareable node appears once in the
* result set (6.13.23)
*/
public void testSearch() throws Exception {
// setup parent nodes and first child
Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false);
// add new referenceable child
Node c = b1.addNode("c");
ensureMixinType(c, mixReferenceable);
b1.save();
String sql = "SELECT * FROM nt:unstructured WHERE jcr:uuid = '" + c.getUUID() + "'";
QueryResult res = workspace.getQueryManager().createQuery(sql, Query.SQL).execute();
List<Node> list = new ArrayList<Node>();
NodeIterator iter = res.getNodes();
while (iter.hasNext()) {
list.add(iter.nextNode());
}
assertEquals(1, list.size());
assertTrue(list.get(0).isSame(c));
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testRemoveSharedSet.
/**
* Check new API Node.removeSharedSet() (6.13.4).
*/
public void testRemoveSharedSet() throws Exception {
// setup parent nodes and first child
Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false);
// remove shared set
b1.removeSharedSet();
testRootNode.getSession().save();
// verify neither a1 nor a2 contain any more children
assertFalse(a1.hasNodes());
assertFalse(a2.hasNodes());
}
Aggregations