Java Code Examples for org.springframework.jdbc.datasource.embedded.EmbeddedDatabase

The following are top voted examples for showing how to use org.springframework.jdbc.datasource.embedded.EmbeddedDatabase. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: FHIR-CQL-ODM-service   File: FhirTerminologyProviderServiceIT.java   Source Code and License 7 votes vote down vote up
private static void setupEmbeddedDatabase() throws NamingException{
	SimpleNamingContextBuilder builder = SimpleNamingContextBuilder
			.emptyActivatedContextBuilder();
	
	EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = dbBuilder
			.setType(EmbeddedDatabaseType.DERBY)
			.setName("usciitg")            
			.setScriptEncoding("UTF-8")
			.ignoreFailedDrops(true)
			.addScript("org/partners/usciitg_prep/terminology/jpa/create-db.sql")
			.addScript("org/partners/usciitg_prep/terminology/jpa/insert-data.sql")
			.build();

	builder.bind(System.getProperty("usciitg.datasource"), db);	
}
 
Example 2
Project: FHIR-CQL-ODM-service   File: JpaFhirTerminologyProviderIT.java   Source Code and License 6 votes vote down vote up
private static void setupEmbeddedDatabase() throws NamingException{
	SimpleNamingContextBuilder builder = SimpleNamingContextBuilder
			.emptyActivatedContextBuilder();
	
	EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = dbBuilder
			.setType(EmbeddedDatabaseType.DERBY)
			.setName("usciitg")            
			.setScriptEncoding("UTF-8")
			.ignoreFailedDrops(true)
			.addScript("org/partners/usciitg_prep/terminology/jpa/create-db.sql")
			.addScript("org/partners/usciitg_prep/fhir/cql/insert-data.sql")
			.build();

	builder.bind(System.getProperty("usciitg.datasource"), db);	
}
 
Example 3
Project: FHIR-CQL-ODM-service   File: FhirServiceIT.java   Source Code and License 6 votes vote down vote up
private static void setupEmbeddedDatabase() throws NamingException{
	SimpleNamingContextBuilder builder = SimpleNamingContextBuilder
			.emptyActivatedContextBuilder();
	
	EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = dbBuilder
			.setType(EmbeddedDatabaseType.DERBY)
			.setName("usciitg")            
			.setScriptEncoding("UTF-8")
			.ignoreFailedDrops(true)
			.addScript("org/partners/usciitg_prep/terminology/jpa/create-db.sql")
			.addScript("org/partners/usciitg_prep/fhir/cql/insert-data.sql")
			.addScript("org/partners/usciitg_prep/fhir/create-db.sql")
			.addScript("org/partners/usciitg_prep/fhir/insert-data.sql")
			.build();

	builder.bind(System.getProperty("usciitg.datasource"), db);	
}
 
Example 4
Project: saluki   File: MybatisConfiguration.java   Source Code and License 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(EmbeddedDatabase.class)
public EmbeddedDatabase dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) //
                                 .setName("grpcmonitor")//
                                 .addScript("mapper/create-db.sql")//
                                 .build();
    return db;
}
 
Example 5
Project: spring-test-examples   File: Spring_2_IT_Configuration.java   Source Code and License 6 votes vote down vote up
@Bean
public DataSource dataSource() {

  EmbeddedDatabase db = new EmbeddedDatabaseBuilder()
      .generateUniqueName(true)
      .setType(EmbeddedDatabaseType.H2)
      .setScriptEncoding("UTF-8")
      .ignoreFailedDrops(true)
      .addScript("classpath:me/chanjar/domain/foo-ddl.sql")
      .build();
  return db;
}
 
Example 6
Project: odotCore   File: TestCategoryDaoConfiguration.java   Source Code and License 6 votes vote down vote up
@Override
@Bean(name = "dataSource")
public DataSource getDataSource() {
  EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  EmbeddedDatabase embeddedDb = builder
      .setType(EmbeddedDatabaseType.DERBY)
      .ignoreFailedDrops(true)
      .addScript("sql/create_tables.sql")
      .addScript("sql/insert_just_category_data.sql")
      .build();
  return embeddedDb;
}
 
Example 7
Project: java-samples   File: Application.java   Source Code and License 6 votes vote down vote up
public static void main(final String[] args) throws SQLException {
    LOGGER.info("===========================================================");
    // r�cup�ration du contexte via les annotations � partir d'un package
    ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
    LOGGER.info("===========================================================");
    // notre contexte est charg�
    LOGGER.info("context is loaded : {}", context);

    LOGGER.info("-----------------------------------------------------------");

    EmbeddedDatabase dataSource = context.getBean(EmbeddedDatabase.class);

    LOGGER.info("Datasource : {}, connection : {}", dataSource, dataSource.getConnection().isClosed());


    // fermeture de la base embarqu�e
    dataSource.shutdown();
}
 
Example 8
Project: celerio   File: MetaDataExtractorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void noTable() throws ClassNotFoundException, SQLException, JAXBException, IOException {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase embeddedDatabase = builder.setType(EmbeddedDatabaseType.H2).build();

    Metadata meta = extractor.extract(embeddedDatabase.getConnection());

    assertThat(countTables(meta)).isZero();
    assertThat(countColumns(meta)).isZero();
    assertThat(countPrimaryKeys(meta)).isZero();
    assertThat(countImportedKeys(meta)).isZero();
    assertThat(countIndexes(meta)).isZero();
    assertThat(countEnums(meta)).isZero();

    embeddedDatabase.shutdown();
}
 
Example 9
Project: celerio   File: MetaDataExtractorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void outputIsSameAsInput() throws ClassNotFoundException, SQLException, XmlMappingException, IOException {
    EmbeddedDatabase embeddedDatabase = createMinimalEmbeddedDatabase(ALL_RELATIONS_SCRIPT);

    Metadata meta = extractor.extract(embeddedDatabase.getConnection());


    assertThat(countTables(meta)).isEqualTo(18);
    assertThat(countColumns(meta)).isEqualTo(49);
    assertThat(countPrimaryKeys(meta)).isEqualTo(18);
    assertThat(countIndexes(meta)).isEqualTo(21);
    assertThat(countEnums(meta)).isEqualTo(3);

    File tempFile = File.createTempFile(getClass().getName(), ".xml");
    tempFile.deleteOnExit();
    loader.write(meta, tempFile);

    Metadata loadedMeta = loader.load(tempFile);
    assertThat(countTables(meta)).isEqualTo(countTables(loadedMeta));
    assertThat(countColumns(meta)).isEqualTo(countColumns(loadedMeta));
    assertThat(countPrimaryKeys(meta)).isEqualTo(countPrimaryKeys(loadedMeta));
    assertThat(countIndexes(meta)).isEqualTo(countIndexes(loadedMeta));
    assertThat(countEnums(meta)).isEqualTo(countEnums(loadedMeta));

    embeddedDatabase.shutdown();
}
 
Example 10
Project: easy-props   File: PropertiesInjectorImplTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testConfigurationHotReloading() throws Exception {
    //given
    EmbeddedDatabase database = new EmbeddedDatabaseBuilder().setName("test").addScript("database.sql").build();
    System.setProperty("sp", "foo");
    HotReloadableConfig config = new HotReloadableConfig();

    //when
    propertiesInjector.injectProperties(config);

    //then
    assertThat(config.getSystemProperty()).isEqualTo("foo");
    assertThat(config.getName()).isEqualTo("Foo");

    // Properties changes should be reloaded
    System.setProperty("sp","bar");
    new JdbcTemplate(database).update("update ApplicationProperties set value = ? where key = ?", "Bar", "name");
    sleep(2 * 1000);
    assertThat(config.getSystemProperty()).isEqualTo("bar");
    assertThat(config.getName()).isEqualTo("Bar");
    database.shutdown();
}
 
Example 11
Project: pndao   File: MyBatisConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    //TODO:just for test, replace by your own datasource
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder
            .setType(EmbeddedDatabaseType.H2) //.H2 or .DERBY
            .addScript("db/sql/create-db.sql")
            .addScript("db/sql/insert-data.sql")
            .build();
    return db;
}
 
Example 12
Project: real-time-risk   File: H2DataSource.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {

    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2)
            .addScript("db/create-db.sql")
            .addScript("db/insert-data.sql").build();
    return db;

}
 
Example 13
Project: Using-Spring-Oauth2-to-secure-REST   File: Oauth2Application.java   Source Code and License 5 votes vote down vote up
@Bean @Qualifier("mainDataSource")
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
			.setType(EmbeddedDatabaseType.H2)
			.build();
	return db;
}
 
Example 14
Project: Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token   File: DemoOauth2Application.java   Source Code and License 5 votes vote down vote up
@Bean @Qualifier("mainDataSource")
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
			.setType(EmbeddedDatabaseType.H2)
			.build();
	return db;
}
 
Example 15
Project: spring-i18n-support   File: WebappConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2)
	                             .addScript("/jdbc/schema.sql")
	                             .addScript("/jdbc/data.sql")
	                             .build();
	return db;
}
 
Example 16
Project: saluki   File: MybatisConfiguration.java   Source Code and License 5 votes vote down vote up
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean(EmbeddedDatabase dataSource) {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage("com.quancheng.saluki.domain");
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    try {
        bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
        return bean.getObject();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 17
Project: odotCore   File: TestConfiguration.java   Source Code and License 5 votes vote down vote up
@Override
@Bean(name = "dataSource")
public DataSource getDataSource() {
  EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  EmbeddedDatabase embeddedDb = builder
      .setType(EmbeddedDatabaseType.DERBY)
      .ignoreFailedDrops(true)
      // .addScript("sql/drop_tables.sql")
      .addScript("sql/create_tables.sql")
      .addScript("sql/insert_data.sql")
      .build();
  return embeddedDb;
}
 
Example 18
Project: odotCore   File: ItemDaoTest.java   Source Code and License 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
 
Example 19
Project: odotCore   File: ItemDaoTest.java   Source Code and License 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
 
Example 20
Project: odotCore   File: ItemDaoTest.java   Source Code and License 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
 
Example 21
Project: odotCore   File: CategoryDaoTest.java   Source Code and License 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
 
Example 22
Project: odotCore   File: CategoryDaoTest.java   Source Code and License 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
 
Example 23
Project: odotCore   File: CategoryDaoTest.java   Source Code and License 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
 
Example 24
Project: odotCore   File: TestConfigurationEmptyDb.java   Source Code and License 5 votes vote down vote up
@Override
@Bean(name = "dataSource")
public DataSource getDataSource() {
  EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  EmbeddedDatabase embeddedDb = builder
      .setType(EmbeddedDatabaseType.DERBY)
      .ignoreFailedDrops(true)
      .addScript("sql/create_tables.sql")
      // NO DATA
      .build();
  return embeddedDb;
}
 
Example 25
Project: siga   File: SpringDBConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource getDataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setName("testdb").setType(EmbeddedDatabaseType.HSQL)
			.addScript("db/sql/create-db.sql").addScript("db/sql/insert-data.sql").build();
	return db;
}
 
Example 26
Project: introducing-spring-framework   File: JDBCConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).
        addScript("META-INF/data/schema.sql").
        addScript("META-INF/data/data.sql").build();
    return db;
}
 
Example 27
Project: introducing-spring-framework   File: MyDocumentsApp.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).
        addScript("META-INF/data/schema.sql").
        addScript("META-INF/data/data.sql").build();
    return db;
}
 
Example 28
Project: introducing-spring-framework   File: MyDocumentsWebApp.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).
        addScript("META-INF/data/schema.sql").
        addScript("META-INF/data/data.sql").build();
    return db;
}
 
Example 29
Project: pndaox   File: MyBatisConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    //TODO:just for test, replace by your own datasource
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder
            .setType(EmbeddedDatabaseType.H2) //.H2 or .DERBY
            .addScript("db/sql/create-db.sql")
            .addScript("db/sql/insert-data.sql")
            .build();
    return db;
}
 
Example 30
Project: spring-data-mybatis   File: TestConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource routingDataSource() throws SQLException {
    EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("classpath:/test-init.sql").build();

    ReplicationRoutingDataSource proxy = new ReplicationRoutingDataSource(embeddedDatabase, null);
    proxy.addSlave(embeddedDatabase);
    proxy.addSlave(embeddedDatabase);
    proxy.addSlave(embeddedDatabase);
    return proxy;
}
 
Example 31
Project: unitils   File: ProfileModuleTest.java   Source Code and License 5 votes vote down vote up
private void dropTableDummyTable() {
    EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder()
    .setType(EmbeddedDatabaseType.HSQL)
    .build();
    
    executeUpdate("drop table DUMMYTABLE", dataSource);
}
 
Example 32
Project: spring-micro-service-jwt   File: DbConfig.java   Source Code and License 5 votes vote down vote up
@Bean
@Profile("test")
public DataSource getTestDataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) // .H2 or
			.addScript("userRole.sql").build();
	return db;

}
 
Example 33
Project: bglogin   File: TestModelConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
		.setType(EmbeddedDatabaseType.HSQL)
		.addScript("classpath:sql/test/user_role_init_datatables.sql")
		.addScript("classpath:sql/test/user_role_init_data.sql")
		.build();
	return db;
}
 
Example 34
Project: bglogin   File: TestWebConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
		.setType(EmbeddedDatabaseType.HSQL)
		.addScript("classpath:sql/test/web_init_datatables.sql")
		.addScript("classpath:sql/test/web_init_data.sql")
		.build();
	return db;
}
 
Example 35
Project: bglogin   File: TestServicesConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
		.setType(EmbeddedDatabaseType.HSQL)
		.addScript("classpath:sql/test/login_init_datatables.sql")
		.addScript("classpath:sql/test/login_init_data.sql")
		.build();
	return db;
}
 
Example 36
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: TestDatabaseAutoConfiguration.java   Source Code and License 5 votes vote down vote up
public EmbeddedDatabase getEmbeddedDatabase() {
	EmbeddedDatabaseConnection connection = this.environment.getProperty(
			"spring.test.database.connection", EmbeddedDatabaseConnection.class,
			EmbeddedDatabaseConnection.NONE);
	if (EmbeddedDatabaseConnection.NONE.equals(connection)) {
		connection = EmbeddedDatabaseConnection.get(getClass().getClassLoader());
	}
	return new EmbeddedDatabaseBuilder().setType(connection.getType()).build();
}
 
Example 37
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: EmbeddedDataSourceConfiguration.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseConnection.get(this.classLoader).getType());
	this.database = builder.setName(this.properties.getName()).build();
	return this.database;
}
 
Example 38
Project: gest-ecole   File: GestEcoleTestPersistenceConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
  final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  final EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).build();
  return db;

}
 
Example 39
Project: java-samples   File: ApplicationConfiguration.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
    return new EmbeddedDatabaseBuilder()
            .generateUniqueName(true)
            .setType(H2)
            .setScriptEncoding("UTF-8")
            .ignoreFailedDrops(true)
            .addScripts("schema.sql", "data.sql")
            .build();
}
 
Example 40
Project: java-samples   File: ApplicationTestConfiguration.java   Source Code and License 5 votes vote down vote up
/**
 * Création de la datasource de test
 * @return datasource pour les tests
 */
@Bean
public EmbeddedDatabase dataSource() {
    return new EmbeddedDatabaseBuilder()
            .setName("TESTDB")
            .setType(H2)
            .setScriptEncoding("UTF-8")
            .ignoreFailedDrops(true)
            .addScripts("schema.sql", "data.sql")
            .build();
}
 
Example 41
Project: spring-boot-concourse   File: TestDatabaseAutoConfiguration.java   Source Code and License 5 votes vote down vote up
public EmbeddedDatabase getEmbeddedDatabase() {
	EmbeddedDatabaseConnection connection = this.environment.getProperty(
			"spring.test.database.connection", EmbeddedDatabaseConnection.class,
			EmbeddedDatabaseConnection.NONE);
	if (EmbeddedDatabaseConnection.NONE.equals(connection)) {
		connection = EmbeddedDatabaseConnection.get(getClass().getClassLoader());
	}
	return new EmbeddedDatabaseBuilder().setType(connection.getType()).build();
}
 
Example 42
Project: spring-boot-concourse   File: EmbeddedDataSourceConfiguration.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseConnection.get(this.classLoader).getType());
	this.database = builder.setName(this.properties.getName()).build();
	return this.database;
}
 
Example 43
Project: JUnit-5-Quick-Start-Guide-with-AssertJ-Spring-TestFX-Mockito   File: Spring5Config.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {

    // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder
            .setType(EmbeddedDatabaseType.HSQL) //.H2 or .DERBY
            .addScript("schema.sql")
            .addScript("data.sql")
            .build();
    return db;
}
 
Example 44
Project: JUnit-5-Quick-Start-Guide-with-AssertJ-Spring-TestFX-Mockito   File: Spring4Config.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder
            .setType(EmbeddedDatabaseType.HSQL)
            .addScript("schema.sql")
            .addScript("data.sql")
            .build();
    return db;
}
 
Example 45
Project: spring-mvc-form-handling   File: SpringDBConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource getDataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setName("testdb").setType(EmbeddedDatabaseType.HSQL)
			.addScript("db/sql/create-db.sql").addScript("db/sql/insert-data.sql").build();
	return db;
}
 
Example 46
Project: demo-spring-security   File: DataConfiguration.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
	final String prefix = "com/iampfac/howto/spring/security/";
	EmbeddedDatabase bean = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setScriptEncoding("UTF-8").ignoreFailedDrops(true)
			.addScript(prefix + "schema.sql").addScripts(prefix + "users.sql", prefix + "roles.sql")
			.addScripts(prefix + "custom_users.sql", prefix + "custom_roles.sql").build();
	return bean;
}
 
Example 47
Project: minitwit   File: DatabaseConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
	
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
			.setType(EmbeddedDatabaseType.HSQL)
			.addScript("sql/create-db.sql")
			.addScript("sql/insert-data.sql")
			.build();
	return db;
}
 
Example 48
Project: wte4j   File: StandaloneJPAConfigTest.java   Source Code and License 5 votes vote down vote up
@Bean
@Qualifier("wte4j")
public DataSource dataSource() {

	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).build();
	return db;

}
 
Example 49
Project: camunda-bpm-spring-boot-starter   File: HistoryLevelDeterminatorJdbcTemplateImplTestApplication.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
  EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  EmbeddedDatabase db = builder.setName("testdbForHistoryLevelDetermination").setType(EmbeddedDatabaseType.H2)
      .addScript("/org/camunda/bpm/engine/db/create/activiti.h2.create.engine.sql").addScript("db/sql/insert-history-data.sql").continueOnError(true).build();
  return db;
}
 
Example 50
Project: contestparser   File: EmbeddedDataSourceConfiguration.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseConnection.get(this.classLoader).getType());
	this.database = builder.setName(this.properties.getName()).build();
	return this.database;
}
 
Example 51
Project: proflr-server   File: Application.java   Source Code and License 5 votes vote down vote up
@Bean(destroyMethod = "shutdown") public EmbeddedDatabase dataSource() {
    return new EmbeddedDatabaseBuilder().
        setType(EmbeddedDatabaseType.H2).
        addScript("db-schema.sql").
        addScript("db-test-data.sql").
        build();
}
 
Example 52
Project: elpaaso-core   File: CleanerTestContext.java   Source Code and License 5 votes vote down vote up
@Bean(name = "datasource")
public DataSource toto() {
    EmbeddedDatabaseBuilder embeddedDatabaseBuilder = new EmbeddedDatabaseBuilder();
    final EmbeddedDatabase database = embeddedDatabaseBuilder.setType(EmbeddedDatabaseType.HSQL).build();

    return database;
}
 
Example 53
Project: celerio   File: MetaDataExtractorTest.java   Source Code and License 5 votes vote down vote up
@Test
public void minimal() throws ClassNotFoundException, SQLException, JAXBException, IOException {
    EmbeddedDatabase embeddedDatabase = createMinimalEmbeddedDatabase(MINIMAL_SCRIPT);
    Metadata meta = extractor.extract(embeddedDatabase.getConnection());

    assertThat(countTables(meta)).isEqualTo(6);
    assertThat(countColumns(meta)).isEqualTo(29);
    assertThat(countPrimaryKeys(meta)).isEqualTo(9);
    assertThat(countImportedKeys(meta)).isEqualTo(4);
    assertThat(countIndexes(meta)).isEqualTo(13);
    assertThat(countEnums(meta)).isZero();

    embeddedDatabase.shutdown();
}
 
Example 54
Project: spring-embedded-database   File: HsqlDataSource.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
	
	// no need shutdown, EmbeddedDatabaseFactoryBean will take care of this
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).addScript("db/sql/create-db.sql").addScript("db/sql/insert-data.sql").build();
	return db;
}
 
Example 55
Project: spring-embedded-database   File: DerbyDataSource.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {

	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.DERBY).addScript("db/sql/create-db.sql").addScript("db/sql/insert-data.sql").build();
	return db;

}
 
Example 56
Project: spring-embedded-database   File: H2DataSource.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {

	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("db/sql/create-db.sql").addScript("db/sql/insert-data.sql").build();
	return db;

}
 
Example 57
Project: netty.book.kor   File: HsqlDataSource.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {

    // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).addScript("db/sql/create-db.sql")
            .addScript("db/sql/insert-data.sql").setName("NETTY_EXAMPLE_DB").build();
    return db;
}
 
Example 58
Project: netty.book.kor   File: HsqlDataSource.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {

	// no need shutdown, EmbeddedDatabaseFactoryBean will take care of this
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
			.setType(EmbeddedDatabaseType.HSQL)
			.addScript("db/sql/create-db.sql")
			.addScript("db/sql/insert-data.sql")
			.setName("NETTY_EXAMPLE_DB")
			.build();
	return db;
}
 
Example 59
Project: spring-session   File: HsqldbJdbcOperationsSessionRepositoryITests.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	return new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseType.HSQL)
			.addScript("org/springframework/session/jdbc/schema-hsqldb.sql")
			.build();
}
 
Example 60
Project: spring-session   File: H2JdbcOperationsSessionRepositoryITests.java   Source Code and License 5 votes vote down vote up
@Bean
public EmbeddedDatabase dataSource() {
	return new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseType.H2)
			.addScript("org/springframework/session/jdbc/schema-h2.sql")
			.build();
}