public void test_SelectOrderBy() throws SQLException {
  String selectQuery="SELECT onum FROM " + DatabaseCreator.ORDERS_TABLE + " ORDER BY onum";
  ResultSet result=statement.executeQuery(selectQuery);
  ArrayList<Integer> values=new ArrayList<Integer>();
  values.add(Integer.valueOf(3001));
  values.add(Integer.valueOf(3002));
  values.add(Integer.valueOf(3003));
  values.add(Integer.valueOf(3005));
  values.add(Integer.valueOf(3006));
  values.add(Integer.valueOf(3007));
  values.add(Integer.valueOf(3008));
  values.add(Integer.valueOf(3009));
  values.add(Integer.valueOf(3010));
  values.add(Integer.valueOf(3011));
  int index=0;
  while (result.next()) {
    Integer onum=result.getInt("onum");
    assertTrue("result set doesn't contain value",values.contains(onum));
    assertEquals("result set is not sorted",index,values.indexOf(onum));
    index++;
  }
  result.close();
}

public void test_SelectOrderBy ( ) throws SQLException { String selectQuery = "SELECT onum FROM " + DatabaseCreator . ORDERS_TABLE + " ORDER BY onum" ; ResultSet result = statement . executeQuery ( selectQuery ) ; ArrayList < Integer > values = new ArrayList < Integer > ( ) ; values . add ( Integer . valueOf ( 3001 ) ) ; values . add ( Integer . valueOf ( 3002 ) ) ; values . add ( Integer . valueOf ( 3003 ) ) ; values . add ( Integer . valueOf ( 3005 ) ) ; values . add ( Integer . valueOf ( 3006 ) ) ; values . add ( Integer . valueOf ( 3007 ) ) ; values . add ( Integer . valueOf ( 3008 ) ) ; values . add ( Integer . valueOf ( 3009 ) ) ; values . add ( Integer . valueOf ( 3010 ) ) ; values . add ( Integer . valueOf ( 3011 ) ) ; int index = 0 ; while ( result . next ( ) ) { Integer onum = result . getInt ( "onum" ) ; assertTrue ( "result set doesn't contain value" , values . contains ( onum ) ) ; assertEquals ( "result set is not sorted" , index , values . indexOf ( onum ) ) ; index ++ ; } result . close ( ) ; }
selectfunctionalitytest # test_selectorderby ( ) . selects records from a table using order by
