use of javax.jcr.ValueFactory in project camel by apache.
the class JcrGetNodeByIdTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Session session = openSession();
Node node = session.getRootNode().addNode("home").addNode("test");
node.setProperty("content.approved", APPROVED);
node.setProperty("my.contents.property", CONTENT);
ValueFactory valFact = session.getValueFactory();
Value[] vals = new Value[] { valFact.createValue("value-1"), valFact.createValue("value-2") };
node.setProperty("my.multi.valued", vals);
identifier = node.getIdentifier();
session.save();
session.logout();
}
use of javax.jcr.ValueFactory in project jackrabbit by apache.
the class TestContentLoader method addNodeTestData.
/**
* Creates three nodes under the given node: one of type nt:resource
* and the other nodes referencing it.
*/
private void addNodeTestData(Node node) throws RepositoryException, IOException {
if (node.hasNode("multiReference")) {
node.getNode("multiReference").remove();
}
if (node.hasNode("resReference")) {
node.getNode("resReference").remove();
}
if (node.hasNode("myResource")) {
node.getNode("myResource").remove();
}
Node resource = node.addNode("myResource", "nt:resource");
// nt:resource not longer referenceable since JCR 2.0
resource.addMixin("mix:referenceable");
resource.setProperty("jcr:encoding", ENCODING);
resource.setProperty("jcr:mimeType", "text/plain");
resource.setProperty("jcr:data", new ByteArrayInputStream("Hello wörld.".getBytes(ENCODING)));
resource.setProperty("jcr:lastModified", Calendar.getInstance());
Node resReference = getOrAddNode(node, "reference");
resReference.setProperty("ref", resource);
// make this node itself referenceable
resReference.addMixin("mix:referenceable");
Node multiReference = node.addNode("multiReference");
ValueFactory factory = node.getSession().getValueFactory();
multiReference.setProperty("ref", new Value[] { factory.createValue(resource), factory.createValue(resReference) });
// NodeDefTest requires a test node with a mandatory child node
JcrUtils.putFile(node, "testFile", "text/plain", new ByteArrayInputStream("Hello, World!".getBytes("UTF-8")));
}
use of javax.jcr.ValueFactory in project jackrabbit by apache.
the class PathTest method testResolvedIdentifierBasedPropertyValue.
public void testResolvedIdentifierBasedPropertyValue() throws RepositoryException {
ValueFactory vf = superuser.getValueFactory();
Value pathValue = vf.createValue("[" + identifier + "]", PropertyType.PATH);
Property p = testRootNode.setProperty(propertyName1, pathValue);
assertTrue("Identifier-based PATH value must resolve to the Node the identifier has been obtained from.", testRootNode.isSame(p.getNode()));
}
use of javax.jcr.ValueFactory in project jackrabbit by apache.
the class PathTest method testNotNormalizedPathValue.
public void testNotNormalizedPathValue() throws RepositoryException {
ValueFactory vf = superuser.getValueFactory();
Value pathValue = vf.createValue("/a/../b/./c/dd/..", PropertyType.PATH);
Property p = testRootNode.setProperty(propertyName1, pathValue);
assertEquals(PropertyType.PATH, p.getType());
assertEquals(pathValue.getString(), p.getValue().getString());
assertEquals(pathValue, p.getValue());
}
use of javax.jcr.ValueFactory in project jackrabbit-oak by apache.
the class LucenePropertyFullTextTest method performQuery.
private boolean performQuery(@Nonnull final TestContext ec) throws RepositoryException {
QueryManager qm = ec.session.getWorkspace().getQueryManager();
ValueFactory vf = ec.session.getValueFactory();
Query q = qm.createQuery("SELECT * FROM [nt:base] WHERE [title] = $title", Query.JCR_SQL2);
q.bindValue("title", vf.createValue(ec.title));
LOG.trace("statement: {} - title: {}", q.getStatement(), ec.title);
RowIterator rows = q.execute().getRows();
if (rows.hasNext()) {
rows.nextRow().getPath();
return true;
} else {
return false;
}
}
Aggregations