Java 类org.springframework.jdbc.datasource.embedded.EmbeddedDatabase 实例源码

项目:FHIR-CQL-ODM-service    文件:FhirTerminologyProviderServiceIT.java   
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); 
}
项目:FHIR-CQL-ODM-service    文件:JpaFhirTerminologyProviderIT.java   
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); 
}
项目:FHIR-CQL-ODM-service    文件:FhirServiceIT.java   
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); 
}
项目:saluki    文件:MybatisConfiguration.java   
@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;
}
项目:spring-test-examples    文件:Spring_2_IT_Configuration.java   
@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;
}
项目:odotCore    文件:TestCategoryDaoConfiguration.java   
@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;
}
项目:java-samples    文件:Application.java   
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();
}
项目:celerio    文件:MetaDataExtractorTest.java   
@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();
}
项目:celerio    文件:MetaDataExtractorTest.java   
@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();
}
项目:easy-props    文件:PropertiesInjectorImplTest.java   
@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();
}
项目:pndao    文件:MyBatisConfig.java   
@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;
}
项目:real-time-risk    文件:H2DataSource.java   
@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;

}
项目:Using-Spring-Oauth2-to-secure-REST    文件:Oauth2Application.java   
@Bean @Qualifier("mainDataSource")
public DataSource dataSource(){
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder
            .setType(EmbeddedDatabaseType.H2)
            .build();
    return db;
}
项目:Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token    文件:DemoOauth2Application.java   
@Bean @Qualifier("mainDataSource")
public DataSource dataSource(){
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder
            .setType(EmbeddedDatabaseType.H2)
            .build();
    return db;
}
项目:spring-i18n-support    文件:WebappConfig.java   
@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;
}
项目:saluki    文件:MybatisConfiguration.java   
@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);
    }
}
项目:odotCore    文件:TestConfiguration.java   
@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;
}
项目:odotCore    文件:ItemDaoTest.java   
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
项目:odotCore    文件:ItemDaoTest.java   
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
项目:odotCore    文件:ItemDaoTest.java   
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
项目:odotCore    文件:CategoryDaoTest.java   
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
项目:odotCore    文件:CategoryDaoTest.java   
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
项目:odotCore    文件:CategoryDaoTest.java   
@AfterEach
public void tearDown() throws Exception {
  DataSource dataSource = (DataSource) ctx.getBean("dataSource");
  if (dataSource instanceof EmbeddedDatabase) {
    ((EmbeddedDatabase) dataSource).shutdown();
  }
}
项目:odotCore    文件:TestConfigurationEmptyDb.java   
@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;
}
项目:siga    文件:SpringDBConfig.java   
@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;
}
项目:introducing-spring-framework    文件:JDBCConfig.java   
@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;
}
项目:introducing-spring-framework    文件:MyDocumentsApp.java   
@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;
}
项目:introducing-spring-framework    文件:MyDocumentsWebApp.java   
@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;
}
项目:pndaox    文件:MyBatisConfig.java   
@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;
}
项目:spring-data-mybatis    文件:TestConfig.java   
@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;
}
项目:unitils    文件:ProfileModuleTest.java   
private void dropTableDummyTable() {
    EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder()
    .setType(EmbeddedDatabaseType.HSQL)
    .build();

    executeUpdate("drop table DUMMYTABLE", dataSource);
}
项目:spring-micro-service-jwt    文件:DbConfig.java   
@Bean
@Profile("test")
public DataSource getTestDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) // .H2 or
            .addScript("userRole.sql").build();
    return db;

}
项目:bglogin    文件:TestModelConfig.java   
@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;
}
项目:bglogin    文件:TestWebConfig.java   
@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;
}
项目:bglogin    文件:TestServicesConfig.java   
@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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:TestDatabaseAutoConfiguration.java   
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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedDataSourceConfiguration.java   
@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;
}
项目:gest-ecole    文件:GestEcoleTestPersistenceConfig.java   
@Bean
public DataSource dataSource() {
  final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  final EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).build();
  return db;

}
项目:java-samples    文件:ApplicationConfiguration.java   
@Bean
public EmbeddedDatabase dataSource() {
    return new EmbeddedDatabaseBuilder()
            .generateUniqueName(true)
            .setType(H2)
            .setScriptEncoding("UTF-8")
            .ignoreFailedDrops(true)
            .addScripts("schema.sql", "data.sql")
            .build();
}
项目:java-samples    文件:ApplicationTestConfiguration.java   
/**
 * 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();
}