Esempio n. 1
0
 public void init() {
   SimpleJdbcTestUtils.executeSqlScript(
       jdbcTemplate,
       new EncodedResource(
           new ClassPathResource("net/tomastrnka/lab/citrus/ws/schema.ddl"), "UTF-8"),
       false);
 }
  @Before
  public void onSetUp() throws Exception {
    // 외부에 sql file 로부터 DB 초기화 (기존 테이블 삭제/생성 및
    // 초기데이터 구축)
    // Spring 의 SimpleJdbcTestUtils 사용,
    // continueOnError 플래그는 true로 설정 - cf.) DDL 이
    // 포함된 경우 rollback 에 유의
    SimpleJdbcTestUtils.executeSqlScript(
        new SimpleJdbcTemplate(dataSource),
        new ClassPathResource("META-INF/testdata/sample_schema_ddl_" + usingDBMS + ".sql"),
        true);

    // init data
    SimpleJdbcTestUtils.executeSqlScript(
        new SimpleJdbcTemplate(dataSource),
        new ClassPathResource("META-INF/testdata/sample_schema_initdata_" + usingDBMS + ".sql"),
        true);
  }
 private static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
   return SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "person");
 }
 private static int countRowsInPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
   return SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "person");
 }