Ejemplo n.º 1
0
      private EmbeddedDatabase populateDatabase(EmbeddedDatabase database) {
        // populate db
        final ResourceDatabasePopulator populator = populator();
        populator.setSqlScriptEncoding("UTF-8");
        populator.addScript(new ClassPathResource("sql/test-data.sql"));
        DatabasePopulatorUtils.execute(populator, database);

        return database;
      }
 @PostConstruct
 protected void initialize() throws Exception {
   String platform = DatabaseType.fromMetaData(this.dataSource).toString().toLowerCase();
   if ("hsql".equals(platform)) {
     platform = "hsqldb";
   }
   ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(
       this.resourceLoader.getResource(this.schemaLocation.replace("@@platform@@", platform)));
   populator.setContinueOnError(true);
   DatabasePopulatorUtils.execute(populator, this.dataSource);
 }
  @Bean
  public DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(
        new ClassPathResource(
            "JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
    populator.addScript(new ClassPathResource("Account.sql", JdbcAccountRepository.class));
    populator.addScript(new ClassPathResource("data.sql", JdbcAccountRepository.class));

    DatabasePopulatorUtils.execute(populator, dataSource());
    return populator;
  }
Ejemplo n.º 4
0
 @Before
 public void setup() {
   ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(new ClassPathResource("jwp.sql"));
   DatabasePopulatorUtils.execute(populator, ConnectionManager.getDataSource());
 }