Search in sources :

Example 1 with NonCachedPostgresArtifactStoreBuilder

use of de.flapdoodle.embed.process.store.NonCachedPostgresArtifactStoreBuilder in project raml-module-builder by folio-org.

the class PostgresClient method startEmbeddedPostgres.

/**
 * Start an embedded PostgreSQL using the configuration of {@link #getConnectionConfig()}.
 * It also sets embedded mode to true, see {@link #setIsEmbedded(boolean)}, but
 * doesn't change the configuration.
 *
 * @throws IOException  when starting embedded PostgreSQL fails
 */
public void startEmbeddedPostgres() throws IOException {
    // starting Postgres
    embeddedMode = true;
    if (postgresProcess == null || !postgresProcess.isProcessRunning()) {
        // turns off the default functionality of unzipping on every run.
        IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(Command.Postgres).artifactStore(new NonCachedPostgresArtifactStoreBuilder().defaults(Command.Postgres).download(new PostgresDownloadConfigBuilder().defaultsForCommand(Command.Postgres).build())).build();
        PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig);
        int port = postgreSQLClientConfig.getInteger(PORT);
        String username = postgreSQLClientConfig.getString(_USERNAME);
        String password = postgreSQLClientConfig.getString(_PASSWORD);
        String database = postgreSQLClientConfig.getString(DATABASE);
        String locale = "en_US.UTF-8";
        String OS = System.getProperty("os.name").toLowerCase();
        if (OS.indexOf("win") >= 0) {
            locale = "american_usa";
        }
        final PostgresConfig config = new PostgresConfig(Version.Main.V10, new AbstractPostgresConfig.Net(DEFAULT_IP, port), new AbstractPostgresConfig.Storage(database), new AbstractPostgresConfig.Timeout(20000), new AbstractPostgresConfig.Credentials(username, password));
        config.getAdditionalInitDbParams().addAll(Arrays.asList("-E", "UTF-8", "--locale", locale));
        postgresProcess = runtime.prepare(config).start();
        log.info("embedded postgress started....");
    } else {
        log.info("embedded postgress is already running...");
    }
}
Also used : PostgresConfig(ru.yandex.qatools.embed.postgresql.config.PostgresConfig) AbstractPostgresConfig(ru.yandex.qatools.embed.postgresql.config.AbstractPostgresConfig) NonCachedPostgresArtifactStoreBuilder(de.flapdoodle.embed.process.store.NonCachedPostgresArtifactStoreBuilder) PostgresExecutable(ru.yandex.qatools.embed.postgresql.PostgresExecutable) PostgresProcess(ru.yandex.qatools.embed.postgresql.PostgresProcess) IRuntimeConfig(de.flapdoodle.embed.process.config.IRuntimeConfig) AbstractPostgresConfig(ru.yandex.qatools.embed.postgresql.config.AbstractPostgresConfig) PostgresDownloadConfigBuilder(ru.yandex.qatools.embed.postgresql.config.PostgresDownloadConfigBuilder) RuntimeConfigBuilder(ru.yandex.qatools.embed.postgresql.config.RuntimeConfigBuilder)

Aggregations

IRuntimeConfig (de.flapdoodle.embed.process.config.IRuntimeConfig)1 NonCachedPostgresArtifactStoreBuilder (de.flapdoodle.embed.process.store.NonCachedPostgresArtifactStoreBuilder)1 PostgresExecutable (ru.yandex.qatools.embed.postgresql.PostgresExecutable)1 PostgresProcess (ru.yandex.qatools.embed.postgresql.PostgresProcess)1 AbstractPostgresConfig (ru.yandex.qatools.embed.postgresql.config.AbstractPostgresConfig)1 PostgresConfig (ru.yandex.qatools.embed.postgresql.config.PostgresConfig)1 PostgresDownloadConfigBuilder (ru.yandex.qatools.embed.postgresql.config.PostgresDownloadConfigBuilder)1 RuntimeConfigBuilder (ru.yandex.qatools.embed.postgresql.config.RuntimeConfigBuilder)1