@BeforeClass
 public static void init() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   database = builder.build();
   flyway = new Flyway();
   flyway.setInitVersion("1.5.2");
   flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
   flyway.setDataSource(database);
   flyway.migrate();
 }
 @Bean
 public DataSource dataSource() {
   boolean hsql = StringUtils.containsIgnoreCase(hibernateDialect, "hsql");
   boolean mysql = StringUtils.containsIgnoreCase(hibernateDialect, "mysql");
   if (hsql) {
     EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
     builder.setType(EmbeddedDatabaseType.HSQL);
     builder.addScript(embeddedDatabaseSchemaSQL);
     builder.addScript(embeddedDatabaseDataSQL);
     return builder.build();
   } else if (mysql) {
     DriverManagerDataSource dataSource = new DriverManagerDataSource();
     dataSource.setDriverClassName("com.mysql.jdbc.Driver");
     dataSource.setUrl("jdbc:mysql://localhost:3306/aj");
     dataSource.setUsername(user);
     dataSource.setPassword(password);
     return dataSource;
   } else {
     throw new IllegalStateException();
   }
 }
  @Bean
  public DataSource dataSource() {
    DataSource dataSource = null;
    if (env.getProperty("spring.database.vendor").equals(Database.H2.toString())) {

      EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
      edb.setType(EmbeddedDatabaseType.H2);
      edb.addScript("classpath:db/h2/schema.sql");
      edb.addScript("classpath:db/h2/test-data.sql");
      EmbeddedDatabase embeddedDatabase = edb.build();

      dataSource = embeddedDatabase;

    } else if (env.getProperty("spring.database.vendor").equals(Database.POSTGRESQL.toString())) {

      // TODO Review all parameters for this class and update this setup as appropriate
      BasicDataSource basicDataSource = new BasicDataSource();
      basicDataSource.setDriverClassName(env.getProperty("db.jdbc.driverclass"));
      basicDataSource.setUrl(env.getProperty("db.jdbc.url"));
      basicDataSource.setUsername(env.getProperty("db.username"));
      basicDataSource.setPassword(env.getProperty("db.password"));
      // basicDataSource.setDefaultCatalog("ServerCommon");
      basicDataSource.setInitialSize(0);
      // basicDataSource.setMaxActive(this.dbConcurrentCallsMaxCalls + 8);  // This is for DBCB v1.4
      basicDataSource.setMaxTotal(10); // This is for DBCB v2.0 (API change)
      //		basicDataSource.setMaxIdle(this.dbConcurrentCallsMaxCalls / 2 + 8);
      basicDataSource.setMinIdle(0);
      // basicDataSource.setRemoveAbandoned(true);		// Can help to reduce chance of memory leaks //
      // This is for DBCB v1.4
      basicDataSource.setRemoveAbandonedTimeout(300); // this is the default (5 minutes)

      dataSource = basicDataSource;

    } else {
      logger.error("Unsupported database: {}", env.getProperty("spring.database.vendor"));
      throw new UnsupportedOperationException(
          "Unsupported database: " + env.getProperty("spring.database.vendor"));
    }
    return dataSource;
  }
 @Before
 public void setUp() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   database = builder.build();
   flyway = new Flyway();
   flyway.setInitVersion("1.5.2");
   flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
   flyway.setDataSource(database);
   flyway.migrate();
   JdbcTemplate jdbcTemplate = new JdbcTemplate(database);
   JdbcPagingListFactory pagingListFactory =
       new JdbcPagingListFactory(jdbcTemplate, new DefaultLimitSqlAdapter());
   db = new JdbcScimUserProvisioning(jdbcTemplate, pagingListFactory);
   db.setPasswordValidator(new NullPasswordValidator());
   gdb = new JdbcScimGroupProvisioning(jdbcTemplate, pagingListFactory);
   mdb = new JdbcScimGroupMembershipManager(jdbcTemplate, pagingListFactory);
   mdb.setScimUserProvisioning(db);
   mdb.setScimGroupProvisioning(gdb);
   userEndpoints = new ScimUserEndpoints();
   userEndpoints.setScimGroupMembershipManager(mdb);
   userEndpoints.setScimUserProvisioning(db);
 }
 @Bean
 public EmbeddedDatabase db() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   builder.setType(EmbeddedDatabaseType.H2).addScript("file:src/test/resources/schema_h2.sql");
   return builder.build();
 }
 @Bean
 public EmbeddedDatabase embeddedDatabase() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   builder.setType(EmbeddedDatabaseType.H2);
   return builder.build();
 }