Beispiel #1
0
  @Test
  public void testQTable() {
    final QTable t = getTestTable();

    try {
      t.getColumnIndex("unknown");
      fail("NullPointerException was expected");
    } catch (NullPointerException e) {
      assertTrue(true);
    } catch (Exception e) {
      fail("NullPointerException was expected");
    }

    assertEquals(0, t.getColumnIndex("f"));

    assertTrue(t.hasColumn("f"));
    assertFalse(t.hasColumn("unknown"));

    assertEquals(t, t);
    assertEquals(t, getTestTable());

    int i = 0;
    final Iterator<Row> it = t.iterator();

    while (it.hasNext()) {
      final Row row = it.next();
      final Iterator<Object> cit = row.iterator();
      int j = 0;

      while (cit.hasNext()) {
        final Object v = cit.next();
        assertEquals(t.get(i).get(j), v);
        j++;
      }

      assertEquals(t.getColumnsCount(), j);
      i++;
    }

    assertEquals(t.getRowsCount(), i);
  }