Search in sources :

Example 66 with EmbeddedDatabaseBuilder

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

the class QuartzSupportTests method schedulerFactoryBeanWithCustomJobStore.

@Test
@SuppressWarnings("resource")
void schedulerFactoryBeanWithCustomJobStore() throws Exception {
    StaticApplicationContext context = new StaticApplicationContext();
    String dbName = "mydb";
    EmbeddedDatabase database = new EmbeddedDatabaseBuilder().setName(dbName).build();
    Properties properties = new Properties();
    properties.setProperty("org.quartz.jobStore.class", JobStoreTX.class.getName());
    properties.setProperty("org.quartz.jobStore.dataSource", dbName);
    BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class).addPropertyValue("autoStartup", false).addPropertyValue("dataSource", database).addPropertyValue("quartzProperties", properties).getBeanDefinition();
    context.registerBeanDefinition("scheduler", beanDefinition);
    Scheduler scheduler = context.getBean(Scheduler.class);
    assertThat(scheduler.getMetaData().getJobStoreClass()).isEqualTo(JobStoreTX.class);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Scheduler(org.quartz.Scheduler) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) JobStoreTX(org.quartz.impl.jdbcjobstore.JobStoreTX) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Test(org.junit.jupiter.api.Test)

Example 67 with EmbeddedDatabaseBuilder

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

the class AbstractDatabaseInitializationTests method setUp.

@BeforeEach
void setUp() {
    db = new EmbeddedDatabaseBuilder().setType(getEmbeddedDatabaseType()).build();
    jdbcTemplate = new JdbcTemplate(db);
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

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