Looly 6 years ago
parent
commit
3acf9c4e70
1 changed files with 7 additions and 5 deletions
  1. 7 5
      hutool-db/src/test/java/cn/hutool/db/DbTest.java

+ 7 - 5
hutool-db/src/test/java/cn/hutool/db/DbTest.java

@@ -17,20 +17,22 @@ import cn.hutool.log.StaticLog;
  *
  *
  */
  */
 public class DbTest {
 public class DbTest {
+
+	@Test
+	public void queryTest() throws SQLException {
+		List<Entity> find = Db.use().query("select * from user where age = ?", 18);
+		Assert.assertEquals("王五", find.get(0).get("name"));
+	}
 	
 	
 	@Test
 	@Test
 	public void findTest() throws SQLException {
 	public void findTest() throws SQLException {
-		Db.use();
-		
 		List<Entity> find = Db.use().find(Entity.create("user").set("age", 18));
 		List<Entity> find = Db.use().find(Entity.create("user").set("age", 18));
 		Assert.assertEquals("王五", find.get(0).get("name"));
 		Assert.assertEquals("王五", find.get(0).get("name"));
 	}
 	}
 	
 	
 	@Test
 	@Test
 	public void findByTest() throws SQLException {
 	public void findByTest() throws SQLException {
-		Db.use();
-		
-		List<Entity> find = Db.use().findBy("user", 
+		List<Entity> find = Db.use().findBy("user",
 				Condition.parse("age", "> 18"), 
 				Condition.parse("age", "> 18"), 
 				Condition.parse("age", "< 100")
 				Condition.parse("age", "< 100")
 		);
 		);