예제 #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 testGetWidthSelect() 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("result had wrong width", result.getWidth() == 2);
  }
예제 #3
0
  public void testGetIndexSelect() 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("variable M had bad index", result.getIndex("M") == 0);
    assertTrue("variable F had bad index", result.getIndex("F") == 1);
    assertTrue("non-existent variable Q was found", result.getIndex("Q") == -1);
  }
예제 #4
0
  public void testColumnNamesSelect() throws InvalidQueryException, IOException {
    load("family.ltm");

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

    assertTrue("wrong length of column name array", cols.length == 2);
    assertTrue("M not first column", cols[0].equals("M"));
    assertTrue("F not second column", cols[1].equals("F"));
  }
예제 #5
0
  public void testColumnNamesNoSelect() throws InvalidQueryException, IOException {
    load("family.ltm");

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

    assertTrue("wrong length of column name array", cols.length == 3);

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

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

    assertTrue("not all variables found", vars.isEmpty());
  }
예제 #6
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) {
    }
  }