Refine search
public void testChildNodes() throws RepositoryException { Node n1 = testRootNode.addNode(nodeName1, testNodeType); Node n2 = testRootNode.addNode(nodeName2, testNodeType); Node n3 = testRootNode.addNode(nodeName3, testNodeType); superuser.save(); QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot), null, null); checkQOM(qom, new Node[]{n1, n2, n3}); }
public void testDescendantNodes() throws RepositoryException { Node n1 = testRootNode.addNode(nodeName1, testNodeType); Node n2 = testRootNode.addNode(nodeName2, testNodeType); Node n21 = n2.addNode(nodeName1, testNodeType); superuser.save(); QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot), null, null); checkQOM(qom, new Node[]{n1, n2, n21}); }
public void testChildNode() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); superuser.save(); QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot), null, null); checkQOM(qom, new Node[]{n}); }
public void testSameNode() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); superuser.save(); QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null); checkQOM(qom, new Node[]{n}); }
public void testDescendantNode() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); superuser.save(); QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot), null, null); checkQOM(qom, new Node[]{n}); }
public void testPathDoesNotExist() throws RepositoryException { QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot + "/" + nodeName1), null, null); checkQOM(qom, new Node[]{}); }
public void testPathDoesNotExist() throws RepositoryException { QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot + "/" + nodeName1), null, null); checkQOM(qom, new Node[]{}); }
public void testPathDoesNotExist() throws RepositoryException { QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null); checkQOM(qom, new Node[]{}); }
/** * Tests if a query object model returns {@link Query#JCR_JQOM} when calling * {@link Query#getLanguage()}. */ public void testJCRQOM() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.selector(testNodeType, "s"), null, null, null ); assertEquals("Query returns wrong language.", Query.JCR_JQOM, qom.getLanguage()); } }
public void testLeftOuterJoin() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(testNodeType, LEFT), qf.selector(mixReferenceable, RIGHT), QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, qf.sameNodeJoinCondition(LEFT, RIGHT, ".")), qf.descendantNode(LEFT, testRoot), null, null); checkQOM(qom, new Node[][]{{n1, null}, {n2, n2}}); }
public void testRightOuterJoin() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(mixReferenceable, LEFT), qf.selector(testNodeType, RIGHT), QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, qf.sameNodeJoinCondition(LEFT, RIGHT, ".")), qf.descendantNode(RIGHT, testRoot), null, null); checkQOM(qom, new Node[][]{{null, n1}, {n2, n2}}); }
public void testRightOuterJoinWithPath() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(mixReferenceable, LEFT), qf.selector(testNodeType, RIGHT), QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, qf.sameNodeJoinCondition(LEFT, RIGHT, nodeName2)), qf.descendantNode(RIGHT, testRoot), null, null); checkQOM(qom, new Node[][]{{n2, n1}, {null, n2}}); }
public void testSetOffset() throws RepositoryException { testRootNode.addNode(nodeName1, testNodeType); testRootNode.addNode(nodeName2, testNodeType); testRootNode.addNode(nodeName3, testNodeType); superuser.save(); for (int i = 0; i < 5; i++) { Query query = qf.createQuery( qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot), null, null ); query.setOffset(i); long expected = Math.max(3 - i, 0); assertEquals("Wrong numer of results", expected, getSize(query.execute().getNodes())); } } }
public void testSetLimit() throws RepositoryException { testRootNode.addNode(nodeName1, testNodeType); testRootNode.addNode(nodeName2, testNodeType); testRootNode.addNode(nodeName3, testNodeType); superuser.save(); for (int i = 0; i < 5; i++) { Query query = qf.createQuery( qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot), null, null ); query.setLimit(i); long expected = Math.min(i, 3); assertEquals("Wrong numer of results", expected, getSize(query.execute().getNodes())); } } }
private QueryObjectModel createQuery(String operator, Value literal) throws RepositoryException { return qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.nodeLocalName("s"), operator, qf.literal(literal) ) ), null, null); } }
private QueryObjectModel createQuery(String operator, Value literal) throws RepositoryException { return qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.nodeName("s"), operator, qf.literal(literal) ) ), null, null); } }
public void testSyntacticallyInvalidName() throws RepositoryException { String invalidNodeType = testNodeType + "["; try { Query q = qf.createQuery(qf.selector(invalidNodeType, "s"), null, null, null); q.execute(); fail("Selector with syntactically invalid name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + invalidNodeType + "]"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("selectorName with syntactically invalid name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } }
public void testNotASelectorName() throws RepositoryException { try { Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("x", testRoot), null, null); q.execute(); fail("DescendantNode with an unknown selector name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISDESCENDANTNODE(x, [" + testRoot + "])"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("ISDESCENDANTNODE() with an unknown selector name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } }
public void testSyntacticallyInvalidPath() throws RepositoryException { String invalidPath = testRoot + "/" + nodeName1 + "["; try { Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", invalidPath), null, null); q.execute(); fail("DescendantNode with syntactically invalid path argument must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISDESCENDANTNODE(s, [" + invalidPath + "])"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("ISDESCENDANTNODE() with syntactically invalid path argument must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } }
public void testNotASelectorName() throws RepositoryException { try { Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("x", testRoot), null, null); q.execute(); fail("ChildNode with an unknown selector name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISCHILDNODE(x, [" + testRoot + "])"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("ISCHILDNODE() with an unknown selector name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } } }