Search in sources :

Example 16 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project ff4j by ff4j.

the class SpringJdbcFeatureStorePrefixTest method initStore.

/**
 * {@inheritDoc}
 */
@Override
protected FeatureStore initStore() {
    builder = new EmbeddedDatabaseBuilder();
    db = builder.setType(// 
    EmbeddedDatabaseType.HSQL).addScript(// 
    "classpath:ddl-prefix-schema.sql").addScript("classpath:ddl-prefix-data.sql").build();
    FeatureStoreSpringJdbc jdbcStore = new FeatureStoreSpringJdbc();
    jdbcStore.setQueryBuilder(new JdbcQueryBuilder("T_FF4J_", "_01"));
    jdbcStore.setDataSource(db);
    return jdbcStore;
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) FeatureStoreSpringJdbc(org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)

Example 17 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project tutorials by eugenp.

the class PersistenceConfig method dataSource.

@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("schema-expressions.sql").addScript("data-expressions.sql").build();
    return db;
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Bean(org.springframework.context.annotation.Bean)

Example 18 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project spring-integration by spring-projects.

the class JdbcPollingChannelAdapterIntegrationTests method setUp.

@BeforeClass
public static void setUp() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    builder.setType(EmbeddedDatabaseType.DERBY).addScript("classpath:org/springframework/integration/jdbc/pollingChannelAdapterIntegrationTest.sql");
    embeddedDatabase = builder.build();
    jdbcTemplate = new JdbcTemplate(embeddedDatabase);
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) BeforeClass(org.junit.BeforeClass)

Example 19 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project spring-boot by spring-projects.

the class DataSourceBuilderTests method buildWhenDerivedFromEmbeddedDatabase.

@Test
void buildWhenDerivedFromEmbeddedDatabase() {
    EmbeddedDatabase database = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).build();
    SimpleDriverDataSource built = (SimpleDriverDataSource) DataSourceBuilder.derivedFrom(database).username("test").password("secret").build();
    assertThat(built.getUsername()).isEqualTo("test");
    assertThat(built.getPassword()).isEqualTo("secret");
    assertThat(built.getUrl()).startsWith("jdbc:hsqldb:mem");
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Test(org.junit.jupiter.api.Test)

Example 20 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project spring-framework by spring-projects.

the class H2SequenceMaxValueIncrementerTests method incrementsSequenceUsingH2EmbeddedDatabaseConfigurer.

/**
 * Tests that the incrementer works when using the JDBC connection URL used
 * in the {@code H2EmbeddedDatabaseConfigurer} which is used transparently
 * when using Spring's {@link EmbeddedDatabaseBuilder}.
 *
 * <p>In other words, this tests compatibility with the default H2
 * <em>compatibility mode</em>.
 */
@Test
void incrementsSequenceUsingH2EmbeddedDatabaseConfigurer() {
    EmbeddedDatabase database = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).generateUniqueName(true).addScript("classpath:/org/springframework/jdbc/support/incrementer/schema.sql").build();
    assertIncrements(database);
    database.shutdown();
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)67 Before (org.junit.Before)17 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)15 EmbeddedDatabase (org.springframework.jdbc.datasource.embedded.EmbeddedDatabase)15 JndiRegistry (org.apache.camel.impl.JndiRegistry)11 Bean (org.springframework.context.annotation.Bean)9 JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)5 FeatureStoreSpringJdbc (org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)5 JdbcFeatureStore (org.ff4j.store.JdbcFeatureStore)5 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)4 Test (org.junit.Test)4 PropertyStoreSpringJdbc (org.ff4j.springjdbc.store.PropertyStoreSpringJdbc)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.jupiter.api.Test)3 PreparedStatement (java.sql.PreparedStatement)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 JdbcEventRepository (org.ff4j.audit.repository.JdbcEventRepository)2 Connection (java.sql.Connection)1 Map (java.util.Map)1 Properties (java.util.Properties)1