Search in sources :

Example 1 with SimpleDriverDataSource

use of cn.taketoday.jdbc.datasource.SimpleDriverDataSource in project today-framework by TAKETODAY.

the class H2SequenceMaxValueIncrementerTests method incrementsSequenceWithExplicitH2CompatibilityMode.

/**
 * Tests that the incrementer works when using all supported H2 <em>compatibility modes</em>.
 */
@ParameterizedTest
@EnumSource(Mode.ModeEnum.class)
void incrementsSequenceWithExplicitH2CompatibilityMode(Mode.ModeEnum mode) {
    String connectionUrl = String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;MODE=%s", UUID.randomUUID().toString(), mode);
    DataSource dataSource = new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", "");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.execute("CREATE SEQUENCE SEQ");
    assertIncrements(dataSource);
    jdbcTemplate.execute("SHUTDOWN");
}
Also used : SimpleDriverDataSource(cn.taketoday.jdbc.datasource.SimpleDriverDataSource) JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) SimpleDriverDataSource(cn.taketoday.jdbc.datasource.SimpleDriverDataSource) DataSource(javax.sql.DataSource) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with SimpleDriverDataSource

use of cn.taketoday.jdbc.datasource.SimpleDriverDataSource in project today-infrastructure by TAKETODAY.

the class H2SequenceMaxValueIncrementerTests method incrementsSequenceWithExplicitH2CompatibilityMode.

/**
 * Tests that the incrementer works when using all supported H2 <em>compatibility modes</em>.
 */
@ParameterizedTest
@EnumSource(Mode.ModeEnum.class)
void incrementsSequenceWithExplicitH2CompatibilityMode(Mode.ModeEnum mode) {
    String connectionUrl = String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;MODE=%s", UUID.randomUUID().toString(), mode);
    DataSource dataSource = new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", "");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.execute("CREATE SEQUENCE SEQ");
    assertIncrements(dataSource);
    jdbcTemplate.execute("SHUTDOWN");
}
Also used : SimpleDriverDataSource(cn.taketoday.jdbc.datasource.SimpleDriverDataSource) JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) SimpleDriverDataSource(cn.taketoday.jdbc.datasource.SimpleDriverDataSource) DataSource(javax.sql.DataSource) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

JdbcTemplate (cn.taketoday.jdbc.core.JdbcTemplate)2 SimpleDriverDataSource (cn.taketoday.jdbc.datasource.SimpleDriverDataSource)2 DataSource (javax.sql.DataSource)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2