forked from rbmonster/learning-note
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataJdbcTests.java
More file actions
45 lines (39 loc) · 1.33 KB
/
Copy pathDataJdbcTests.java
File metadata and controls
45 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import com.four.unittest.UnitTestApplication;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Arrays;
import java.util.List;
@Slf4j
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = UnitTestApplication.class)
@DataJdbcTest
public class DataJdbcTests {
//
// @Autowired
// UnitTestService unitTestService;
//
// @Test
// public void setUnitTestService(){
// String s = unitTestService.testJdbcTemplate();
// Assert.notNull("", s);
// }
@Autowired
JdbcTemplate jdbcTemplate;
@Test
public void testJdbc() {
List<String> query = jdbcTemplate.query("select * from demo limit 2",
(resultSet, i) -> resultSet.getString(2));
log.info(Arrays.toString(query.toArray()));
Assert.assertEquals("", 2, CollectionUtils.size(query));
}
}