コード例 #1
0
 @Override
 protected void createTables() throws Exception {
   // Execute SQL to setup the database for the test
   ScriptRunner scriptRunner = new ScriptRunner(cdb.getDatabase("dbid-1"), false);
   scriptRunner.setResourceName("/scripts/oracle-createtables.sql");
   scriptRunner.executeScript();
 }
コード例 #2
0
 @Test
 public void shouldRunScriptsUsingConnection() throws Exception {
   DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
   Connection conn = ds.getConnection();
   ScriptRunner runner = new ScriptRunner(conn);
   runner.setAutoCommit(true);
   runner.setStopOnError(false);
   runner.setErrorLogWriter(null);
   runner.setLogWriter(null);
   runJPetStoreScripts(runner);
   assertProductsTableExistsAndLoaded();
 }
コード例 #3
0
 @Test
 public void shouldRunScriptsUsingProperties() throws Exception {
   Properties props = Resources.getResourceAsProperties(JPETSTORE_PROPERTIES);
   DataSource dataSource =
       new UnpooledDataSource(
           props.getProperty("driver"),
           props.getProperty("url"),
           props.getProperty("username"),
           props.getProperty("password"));
   ScriptRunner runner = new ScriptRunner(dataSource.getConnection());
   runner.setAutoCommit(true);
   runner.setStopOnError(false);
   runner.setErrorLogWriter(null);
   runner.setLogWriter(null);
   runJPetStoreScripts(runner);
   assertProductsTableExistsAndLoaded();
 }
コード例 #4
0
 @Test
 @Ignore("This fails with HSQLDB 2.0 due to the create index statements in the schema script")
 public void shouldRunScriptsBySendingFullScriptAtOnce() throws Exception {
   DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
   Connection conn = ds.getConnection();
   ScriptRunner runner = new ScriptRunner(conn);
   runner.setSendFullScript(true);
   runner.setAutoCommit(true);
   runner.setStopOnError(false);
   runner.setErrorLogWriter(null);
   runner.setLogWriter(null);
   runJPetStoreScripts(runner);
   assertProductsTableExistsAndLoaded();
 }
コード例 #5
0
  @Test
  public void shouldReturnWarningIfEndOfLineTerminatorNotFound() throws Exception {
    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
    Connection conn = ds.getConnection();
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setAutoCommit(true);
    runner.setStopOnError(false);
    runner.setErrorLogWriter(null);
    runner.setLogWriter(null);

    String resource = "org/apache/ibatis/jdbc/ScriptMissingEOLTerminator.sql";
    Reader reader = Resources.getResourceAsReader(resource);

    try {
      runner.runScript(reader);
      fail("Expected script runner to fail due to missing end of line terminator.");
    } catch (Exception e) {
      assertTrue(e.getMessage().contains("end-of-line terminator"));
    }
  }