Skip to content

Commit

Permalink
PostgreSQLSuite: simplified (but still no caching)
Browse files Browse the repository at this point in the history
  • Loading branch information
edrdo committed May 8, 2017
1 parent 2631263 commit 1b89729
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions src/test/java/org/jdbdt/postgresql/PostgreSQLSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,28 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;

import ru.yandex.qatools.embed.postgresql.PostgresExecutable;
import ru.yandex.qatools.embed.postgresql.PostgresProcess;
import ru.yandex.qatools.embed.postgresql.PostgresStarter;
import ru.yandex.qatools.embed.postgresql.config.PostgresConfig;
import ru.yandex.qatools.embed.postgresql.EmbeddedPostgres;
import ru.yandex.qatools.embed.postgresql.distribution.Version;


@SuppressWarnings("javadoc")
public class PostgreSQLSuite extends DBEngineTestSuite {

private static EmbeddedPostgres postgres;

@BeforeClass
public static void setup() throws ClassNotFoundException, IOException {
postgres = new EmbeddedPostgres(Version.V9_6_2);

String url = postgres.start("localhost", 5432, "jdbdt", "jdbt", "jdbdt");

DBConfig.getConfig()
.reset()
.setDriver("org.postgresql.Driver")
.setURL(startDatabase());
.reset()
.setDriver("org.postgresql.Driver")
.setURL(url);
}

@AfterClass
public static void teardown() {
stopDatabase();
}

private static PostgresProcess process;

private static String startDatabase() throws IOException {
PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance();
final PostgresConfig config = PostgresConfig.defaultWithDbName("jdbdt-postgresql-test");
PostgresExecutable exec = runtime.prepare(config);
process = exec.start();
return String.format("jdbc:postgresql://%s:%s/%s",
config.net().host(),
config.net().port(),
config.storage().dbName());
}

private static void stopDatabase() {
process.stop();
postgres.stop();
}
}

1 comment on commit 1b89729

@edrdo
Copy link
Member Author

@edrdo edrdo commented on 1b89729 May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7

Please sign in to comment.