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...");
}
}
Aggregations