use of javax.jcr.query.QueryManager in project jackrabbit by apache.
the class ThreeWayJoinTest method runTest.
public void runTest() throws Exception {
int x = random.nextInt(NODE_COUNT);
String query = "SELECT a.foo AS a, b.bar AS b, c.baz AS c" + " FROM [nt:unstructured] AS a" + " INNER JOIN [nt:unstructured] AS b ON a.foo = b.bar" + " INNER JOIN [nt:unstructured] AS c ON b.bar = c.baz" + " WHERE a.foo = " + x;
QueryManager manager = session.getWorkspace().getQueryManager();
RowIterator iterator = manager.createQuery(query, "JCR-SQL2").execute().getRows();
int count = 0;
while (iterator.hasNext()) {
Row row = iterator.nextRow();
long a = row.getValue("a").getLong();
long b = row.getValue("b").getLong();
long c = row.getValue("c").getLong();
if (a != x || b != x || c != x) {
throw new Exception("Invalid test result: " + x + " -> " + a + ", " + b + ", " + c);
}
count++;
}
if (count != NODE_COUNT * NODE_COUNT * NODE_COUNT) {
throw new Exception("Invalid test result count: " + count);
}
}
use of javax.jcr.query.QueryManager in project jackrabbit by apache.
the class TwoWayJoinTest method runTest.
public void runTest() throws Exception {
int x = random.nextInt(NODE_COUNT);
String query = "SELECT a.foo AS a, b.bar AS b" + " FROM [nt:unstructured] AS a" + " INNER JOIN [nt:unstructured] AS b ON a.foo = b.bar" + " WHERE a.foo = " + x;
QueryManager manager = session.getWorkspace().getQueryManager();
RowIterator iterator = manager.createQuery(query, "JCR-SQL2").execute().getRows();
int count = 0;
while (iterator.hasNext()) {
Row row = iterator.nextRow();
long a = row.getValue("a").getLong();
long b = row.getValue("b").getLong();
if (a != x || a != b) {
throw new Exception("Invalid test result: " + x + " -> " + a + ", " + b);
}
count++;
}
if (count != NODE_COUNT) {
throw new Exception("Invalid test result count: " + count + " !=" + NODE_COUNT);
}
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class AggregateNodeSearcher method execute.
@Override
public void execute(Repository repository, Credentials credentials, ExecutionContext context) throws Exception {
Session session = repository.login(credentials);
QueryManager qm;
try {
List<Authorizable> users = (List<Authorizable>) context.getMap().get(ScalabilityNodeRelationshipSuite.CTX_USER);
Random rand = new Random(99);
Authorizable user = users.get(rand.nextInt(users.size()));
List<String> targets = getRelatedUsers(session, user);
context.getMap().put(RELATIONSHIPS, targets);
qm = session.getWorkspace().getQueryManager();
search(qm, context);
context.getMap().remove(RELATIONSHIPS);
} catch (RepositoryException e) {
e.printStackTrace();
}
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class SimpleSearchTest method runTest.
@Override
public void runTest() throws Exception {
QueryManager manager = session.getWorkspace().getQueryManager();
for (int i = 0; i < NODE_COUNT; i++) {
Query query = createQuery(manager, i);
NodeIterator iterator = query.execute().getNodes();
while (iterator.hasNext()) {
Node node = iterator.nextNode();
if (node.getProperty("testcount").getLong() != i) {
throw new Exception("Invalid test result: " + node.getPath());
}
}
}
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class UUIDLookupTest method runTest.
@Override
public void runTest() throws Exception {
if (lookupByQuery) {
QueryManager manager = session.getWorkspace().getQueryManager();
for (int i = 0; i < NODE_COUNT; i++) {
Query query = createQuery(manager, i);
NodeIterator iterator = query.execute().getNodes();
while (iterator.hasNext()) {
Node node = iterator.nextNode();
if (node.getProperty("jcr:uuid").getLong() != i) {
throw new Exception("Invalid test result: " + node.getPath());
}
}
}
} else {
for (int i = 0; i < NODE_COUNT; i++) {
session.getNodeByIdentifier(createUUID(i));
}
}
}
Aggregations