// 测试关闭数据库 public static void shutdown() { sqldb.shutdow(); try { assertEquals(true, sqldb.getConnection().isClosed()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
// 测试数据库链接状态 public static void connetion() { try { assertEquals(false, sqldb.getConnection().isClosed()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
// 测试单一条件查询的结果 public static void result(String condition, double min, double max) throws SQLException { String query = "(" + condition + ">" + min + " and " + condition + "<" + max + ")"; ResultSet rs = sqldb.query(query); while (rs.next()) { double d = rs.getDouble(condition); // assertThat(d, anyOf(lessThan(max), greaterThan(min))); assertThat(d, greaterThan(min)); assertThat(d, lessThan(max)); } }
public static void BeforeClass(CrawStocks crawStocks) throws Exception { sqldb = new SQLdb(new CrawStockTongHuaShun()); sqldb.execute(); // sqldb.createdbTable(); // System.out.println(sqldb.getCount()); // if(sqldb.getCount() == 0){ // System.out.println("sssssssssssss"); // sqldb.update(); // } }
// 测试最大值最小值查询 public static void extenValue(String condition) { ResultSet rs = sqldb.queryExtre(condition); try { double min = rs.getDouble(1); double max = rs.getDouble(2); assertThat(min, lessThan(max)); rs.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
// 测试数据库中记录的总数应该大于2000 public static void count() { int count = sqldb.getCount(); assertThat(count, greaterThan(2000)); }
public static void AfterClass() throws Exception { sqldb.shutdow(); }