2

Wee have migration files using Flyway that can't be loaded into enbedded-postgresql (from yandex) during tests execution on Windows 10. On OS X they are working fine.

For example we are getting:

Message    : ERROR: character with byte sequence 0xc5 0xbc in encoding "UTF8" has no equivalent in encoding "WIN1252"
Location   : db/migration/V1475170474871__email_templates.sql (D:\work\project\build\resources\main\db\migration\V1475170474871___email_templates.sql)

Our test setup Spock class tarting embedded-postgresql looks like follows:

class TestDBConfig {

final PostgresConfig config = new PostgresConfig(
    Version.V9_5_0,
    new AbstractPostgresConfig.Net('localhost', Network.freeServerPort),
    new AbstractPostgresConfig.Storage('project'),
    new AbstractPostgresConfig.Timeout(),
    new AbstractPostgresConfig.Credentials('user', 'pass')
)

@Bean(destroyMethod = 'stop', name = 'postgresProcess')
PostgresProcess postgresProcess() {

    config.getAdditionalInitDbParams().addAll(asList(
            "-E", "UTF-8",
            "--locale=en_US.UTF-8",
            "--lc-collate=en_US.UTF-8",
            "--lc-ctype=en_US.UTF-8",
            "--client_encoding=UTF-8",
            "--client-encoding=UTF-8",
    ));
    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance()
    PostgresExecutable exec = runtime.prepare(config)
    PostgresProcess process = exec.start()
    process
}

@Bean(destroyMethod = 'close')
@DependsOn('postgresProcess')
DataSource dataSource() {
    PGPoolingDataSource ds = new PGPoolingDataSource()
    ds.user = config.credentials().username()
    ds.password = config.credentials().password()
    ds.setCurrentSchema('project')
    ds.portNumber = config.net().port()
    ds.serverName = config.net().host()
    ds.databaseName = config.storage().dbName()
    ds
}

}

I have experimented with some parameters to specify connection encoding, but so far nothing helped.

Navita Saini
  • 362
  • 3
  • 12
Tomasz Dziurko
  • 1,668
  • 2
  • 17
  • 21
  • None of these help?: http://stackoverflow.com/questions/4867272/invalid-byte-sequence-for-encoding-utf8 http://stackoverflow.com/questions/1565234/character-with-encoding-utf8-has-no-equivalent-in-win1252 – Nick Nov 17 '16 at 23:04

0 Answers0