Пример #1
0
  public void testColumnNameNoSelect() throws InvalidQueryException, IOException {
    load("family.ltm");

    List vars = new ArrayList();
    vars.add("M");
    vars.add("F");
    vars.add("C");

    String query = "parenthood($M : mother, $F : father, $C : child)?";
    QueryResultIF result = processor.execute(query);

    for (int ix = 0; ix < 3; ix++)
      assertTrue(
          "unknown variable " + result.getColumnName(ix) + " found",
          vars.remove(result.getColumnName(ix)));

    assertTrue("not all variables found", vars.isEmpty());

    try {
      result.getColumnName(3);
      fail("accepted non-existent column");
    } catch (IndexOutOfBoundsException e) {
    }

    try {
      result.getColumnName(-1);
      fail("accepted non-existent column");
    } catch (IndexOutOfBoundsException e) {
    }
  }
Пример #2
0
  public void testColumnNameSelect() throws InvalidQueryException, IOException {
    load("family.ltm");

    String query = "select $M, $F from parenthood($M : mother, $F : father, $C : child)?";
    QueryResultIF result = processor.execute(query);

    assertTrue("M not first column", result.getColumnName(0).equals("M"));
    assertTrue("F not second column", result.getColumnName(1).equals("F"));

    try {
      result.getColumnName(2);
      fail("accepted non-existent column");
    } catch (IndexOutOfBoundsException e) {
    }

    try {
      result.getColumnName(-1);
      fail("accepted non-existent column");
    } catch (IndexOutOfBoundsException e) {
    }
  }