use of javax.jcr.Property in project jackrabbit by apache.
the class NameTest method testExpandedNameItem.
/**
* Test if the name of property created with an expanded name is properly
* return as standard JCR name.
*
* @throws RepositoryException
*/
public void testExpandedNameItem() throws RepositoryException {
String propName = getExpandedName(propertyName1);
Property p = testRootNode.setProperty(propName, getJcrValue(superuser, RepositoryStub.PROP_PROP_VALUE1, RepositoryStub.PROP_PROP_TYPE1, "test"));
assertEquals(propertyName1, p.getName());
}
use of javax.jcr.Property in project jackrabbit-oak by apache.
the class ConcurrentEveryoneACLTest method beforeSuite.
@Override
public void beforeSuite() throws Exception {
Session session = loginWriter();
AccessControlManager acMgr = session.getAccessControlManager();
Privilege[] privileges = new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_READ), acMgr.privilegeFromName(Privilege.JCR_READ_ACCESS_CONTROL) };
final Node root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
for (int i = 0; i < NODE_COUNT; i++) {
Node node = root.addNode("node" + i, "nt:unstructured");
for (int j = 0; j < NODE_COUNT; j++) {
Node newNode = node.addNode("node" + j, "nt:unstructured");
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(session, newNode.getPath());
acl.addEntry(EveryonePrincipal.getInstance(), privileges, true);
acMgr.setPolicy(newNode.getPath(), acl);
}
session.save();
}
// deny everyone on root node
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(session, root.getPath());
acl.addEntry(EveryonePrincipal.getInstance(), privileges, false);
acMgr.setPolicy(root.getPath(), acl);
session.save();
final int[] numACEs = new int[1];
ItemVisitor v = new TraversingItemVisitor.Default() {
@Override
protected void entering(Node node, int i) throws RepositoryException {
if (node.isNodeType(AccessControlConstants.NT_REP_ACE)) {
numACEs[0]++;
}
super.entering(node, i);
}
@Override
protected void entering(Property prop, int i) throws RepositoryException {
super.entering(prop, i);
}
};
v.visit(root);
System.out.println("Num ACEs: " + numACEs[0]);
session.logout();
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GCConcurrentTest method testGC.
public void testGC() throws Exception {
Node root = testRootNode;
Session session = root.getSession();
GCThread gc = new GCThread(session);
Thread gcThread = new Thread(gc, "Datastore Garbage Collector");
int len = 10 * getTestScale();
boolean started = false;
for (int i = 0; i < len; i++) {
if (!started && i > 5 + len / 100) {
started = true;
gcThread.start();
}
Node n = node(root, "test" + i);
ValueFactory vf = session.getValueFactory();
n.setProperty("data", vf.createBinary(randomInputStream(i)));
session.save();
LOG.debug("saved: " + i);
}
Thread.sleep(10);
for (int i = 0; i < len; i++) {
Node n = root.getNode("test" + i);
Property p = n.getProperty("data");
InputStream in = p.getBinary().getStream();
InputStream expected = randomInputStream(i);
checkStreams(expected, in);
n.remove();
LOG.debug("removed: " + i);
session.save();
}
Thread.sleep(10);
gc.setStop(true);
Thread.sleep(10);
gcThread.join();
gc.throwException();
}
use of javax.jcr.Property in project jackrabbit by apache.
the class CopyValueTest method doTestCopy.
private void doTestCopy(int length) throws Exception {
Node root = superuser.getRootNode();
if (root.hasNode("testCopy")) {
root.getNode("testCopy").remove();
superuser.save();
}
Node testRoot = root.addNode("testCopy");
Node n = testRoot.addNode("a");
superuser.save();
byte[] data = new byte[length + 1];
ValueFactory vf = superuser.getValueFactory();
n.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
superuser.save();
data = new byte[length];
n.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
Property p = testRoot.getNode("a").getProperty("data");
assertEquals(length, p.getLength());
superuser.getWorkspace().copy("/testCopy/a", "/testCopy/b");
assertEquals(length, p.getLength());
p = testRoot.getNode("b").getProperty("data");
assertEquals(length + 1, p.getLength());
testRoot.remove();
superuser.save();
}
use of javax.jcr.Property in project jackrabbit by apache.
the class AcReadWriteTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// create some nodes below the test root in order to apply ac-stuff
Node node = testRootNode.addNode(nodeName1, testNodeType);
Node cn1 = node.addNode(nodeName2, testNodeType);
Property cp1 = node.setProperty(propertyName1, "anyValue");
Node cn2 = node.addNode(nodeName3, testNodeType);
Property ccp1 = cn1.setProperty(propertyName1, "childNodeProperty");
Node n2 = testRootNode.addNode(nodeName2, testNodeType);
superuser.save();
path = node.getPath();
childNPath = cn1.getPath();
childNPath2 = cn2.getPath();
childPPath = cp1.getPath();
childchildPPath = ccp1.getPath();
siblingPath = n2.getPath();
}
Aggregations