public void testNamespace() {
   SQLQuery query =
       SQLQueryParser.parse("SELECT dc:title FROM Document WHERE dc:description = 'test'");
   SelectClause select = query.getSelectClause();
   String v = select.getVariable(0).name;
   assertEquals("dc:title", v);
 }
  public void testAlias() {
    SQLQuery query = SQLQueryParser.parse("SELECT p AS pp, q AS qq, r FROM t AS t1");

    SelectClause select = query.getSelectClause();

    assertEquals("pp", select.getAlias(0));
    assertEquals("p", select.getVariable(0).name);
    assertEquals("qq", select.getAlias(1));
    assertEquals("q", select.getVariable(1).name);
    assertEquals("r", select.getAlias(2));
    assertEquals("r", select.getVariable(2).name);

    FromClause from = query.getFromClause();

    assertEquals("t1", from.getAlias(0));
    assertEquals("t", from.get(0));
  }
  public void testVariables() {
    SQLQuery query =
        SQLQueryParser.parse("SELECT p1, $id, p3 FROM t1, t2 WHERE state=1 AND title = 'test'");

    SelectClause select = query.getSelectClause();
    assertEquals("p1", select.getAlias(0));
    assertEquals("p1", select.getVariable(0).name);
    assertEquals("$id", select.getAlias(1));
    assertEquals("$id", select.getVariable(1).name);
    assertEquals("p3", select.getAlias(2));
    assertEquals("p3", select.getVariable(2).name);

    FromClause from = query.getFromClause();
    assertEquals("t1", from.getAlias(0));
    assertEquals("t1", from.get(0));

    Expression e1 = (Expression) query.getWhereClause().predicate.lvalue;
    Expression e2 = (Expression) query.getWhereClause().predicate.rvalue;
    assertEquals("state", ((Reference) e1.lvalue).name);
    assertEquals("title", ((Reference) e2.lvalue).name);
  }