/** * Test case for {@link QueryObjectModelFactory#bindVariable(String)} */ public void testBindVariableValue() throws RepositoryException { BindVariableValue bindVar = qf.bindVariable(propertyName1); assertEquals("Wrong variable name", propertyName1, bindVar.getBindVariableName()); }
/** * Test case for {@link QueryObjectModelFactory#comparison(DynamicOperand, String, StaticOperand)} */ public void testComparison() throws RepositoryException { PropertyValue op1 = qf.propertyValue(SELECTOR_NAME1, propertyName1); BindVariableValue op2 = qf.bindVariable(VARIABLE_NAME); for (Iterator<String> it = OPERATORS.iterator(); it.hasNext(); ) { String operator = it.next(); Comparison comp = qf.comparison(op1, operator, op2); assertTrue("Not a PropertyValue operand", comp.getOperand1() instanceof PropertyValue); assertTrue("Not a BindVariableValue operand", comp.getOperand2() instanceof BindVariableValue); assertEquals("Wrong operator", operator, comp.getOperator()); } }
@Test public void bindVariable() throws RepositoryException { BindVariableValue b = f.bindVariable("bindVariableName"); assertEquals("bindVariableName", b.getBindVariableName()); assertEquals("$bindVariableName", b.toString()); }
protected void setUp() throws Exception { super.setUp(); qomQuery = qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.propertyValue("s", propertyName1), QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, qf.bindVariable("v") ) ), null, null); sqlQuery = qm.createQuery(qomQuery.getStatement(), Query.JCR_SQL2); }
/** * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)} */ public void testFullTextSearchWithBindVariableValue() throws RepositoryException { FullTextSearch ftSearch = qf.fullTextSearch( SELECTOR_NAME1, propertyName1, qf.bindVariable(VARIABLE_NAME)); assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName()); assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName()); StaticOperand op = ftSearch.getFullTextSearchExpression(); assertNotNull(op); assertTrue("not a BindVariableValue", op instanceof BindVariableValue); BindVariableValue value = (BindVariableValue) op; assertEquals(VARIABLE_NAME, value.getBindVariableName()); }
var = factory.bindVariable(name); bindVariables.put(name, var);
var = factory.bindVariable(name); bindVariables.put(name, var);
var = factory.bindVariable(name); bindVariables.put(name, var);
@Test public void createQuery() throws RepositoryException { Selector s = f.selector("nt:file", "x"); BindVariableValue b = f.bindVariable("var"); Constraint c = f.propertyExistence("x", "c"); PropertyValue p = f.propertyValue("x", "propertyName"); c = f.and(f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, b), c); Ordering o = f.ascending(p); Column col = f.column("x", "propertyName", "columnName"); Ordering[] ords = new Ordering[]{o}; Column[] cols = new Column[]{col}; QueryObjectModel q = f.createQuery(s, c, ords, cols); assertEquals(Query.JCR_JQOM, q.getLanguage()); String[] bv = q.getBindVariableNames(); assertEquals(1, bv.length); assertEquals("var", bv[0]); assertEquals(s, q.getSource()); assertEquals(c, q.getConstraint()); assertEquals(o, q.getOrderings()[0]); assertEquals(col, q.getColumns()[0]); }