예제 #1
0
 @Override
 protected void verifyRows(AmbitRows<Object> rows) throws Exception {
   IDatabaseConnection c = getConnection();
   Assert.assertNotNull(rows);
   Assert.assertEquals(1, rows.size());
   while (rows.next()) {
     ITable table =
         c.createQueryTable(
             "EXPECTED",
             "select name,idreference,idproperty,idstructure,ifnull(text,value) as value_string,value_num,title,url,-1,id,units,comments from property_values \n"
                 + "left join property_string using(idvalue_string) \n"
                 + "join properties using(idproperty) join catalog_references using(idreference) \n"
                 + "where idstructure=100215 and name='Property 1' "
             /*
             "select name,idreference,idproperty,idstructure,value_string,value_num,idtype from properties join\n"+
             "(\n"+
             "select idstructure,idproperty,null as value_string,value as value_num,1 as idtype from values_number where idstructure=100215\n"+
             "union\n"+
             "select idstructure,idproperty,value as value_string,null,0 as idtype from values_string where idstructure=100215\n"+
             ") as L using (idproperty)\nwhere name='Property 1'"
             */
             );
     Assert.assertEquals(1, table.getRowCount());
     for (int i = 1; i <= rows.getMetaData().getColumnCount(); i++) {
       Object expected = table.getValue(0, rows.getMetaData().getColumnName(i));
       Object actual = rows.getObject(i);
       if ((expected == null) && (actual == null)) continue;
       else Assert.assertEquals(expected.toString(), actual.toString());
     }
   }
 }
예제 #2
0
 protected void assertExpTable() throws Exception {
   String table = expected.getTableMetaData().getTableName();
   actual = databaseConnection.createQueryTable(table, query);
   try {
     assertEquals(expected, actual);
   } finally {
     databaseConnection.close();
   }
 }
예제 #3
0
  @Test
  public void testGetObject() throws Exception {
    setUpDatabase(getTestDatabase());

    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(4, names.getRowCount());

    QueryExecutor<RetrieveField> qe = new QueryExecutor<RetrieveField>();
    qe.setConnection(c.getConnection());

    ResultSet rs = qe.process((RetrieveField) query);

    int count = 0;
    while (rs.next()) {

      count++;
    }
    Assert.assertTrue(count > 0);
    rs.close();
    qe.close();
    c.close();
  }