From 5077bd734659cf22d4e98519ccd4c6eb026a4ec3 Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Sun, 2 Dec 2018 21:19:10 -0500 Subject: [PATCH 1/7] Add jar plugin version --- pom.xml | 447 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 227 insertions(+), 220 deletions(-) diff --git a/pom.xml b/pom.xml index e739dc5..7cff557 100644 --- a/pom.xml +++ b/pom.xml @@ -1,235 +1,242 @@ - + - - org.sonatype.oss - oss-parent - 9 - + + org.sonatype.oss + oss-parent + 9 + - 4.0.0 - ru.yandex.qatools.embed - postgresql-embedded - 2.11-SNAPSHOT - Embedded PostgreSQL (based on Flapdoodle-OSS embedded services) + 4.0.0 + ru.yandex.qatools.embed + postgresql-embedded + 2.11-SNAPSHOT + Embedded PostgreSQL (based on Flapdoodle-OSS embedded services) - An embedded PostgreSQL... + An embedded PostgreSQL... - - Yandex - http://company.yandex.com - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - GitHub Issues - https://github.com/yandex-qatools/postgresql-embedded/issues - + + Yandex + http://company.yandex.com + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + GitHub Issues + https://github.com/yandex-qatools/postgresql-embedded/issues + - - scm:git:git@github.com:yandex-qatools/postgresql-embedded.git - scm:git:git@github.com:yandex-qatools/postgresql-embedded.git - git@github.com:yandex-qatools/postgresql-embedded.git - HEAD - + + scm:git:git@github.com:yandex-qatools/postgresql-embedded.git + scm:git:git@github.com:yandex-qatools/postgresql-embedded.git + git@github.com:yandex-qatools/postgresql-embedded.git + HEAD + - - + + - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - ${jdk} - ${jdk} - UTF-8 - - + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + ${jdk} + ${jdk} + UTF-8 + + - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - UTF-8 - - - - org.apache.maven.plugins - maven-release-plugin - 2.5 - - deploy -DskipTests=true - - - - org.apache.maven.scm - maven-scm-api - 1.9.1 - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.9.1 - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - verify - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - -Xdoclint:none - - - - + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + UTF-8 + + + + org.apache.maven.plugins + maven-release-plugin + 2.5 + + deploy -DskipTests=true + + + + org.apache.maven.scm + maven-scm-api + 1.9.1 + + + org.apache.maven.scm + maven-scm-provider-gitexe + 1.9.1 + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + verify + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + -Xdoclint:none + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.1 - - - sign-artifacts - verify - - sign - - - - - - - - + + + release-sign-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.1 + + + sign-artifacts + verify + + sign + + + + + + + + - - - de.flapdoodle.embed - de.flapdoodle.embed.process - 2.0.2 - + + + de.flapdoodle.embed + de.flapdoodle.embed.process + 2.0.2 + - - org.postgresql - postgresql - 9.3-1100-jdbc41 - test - + + org.postgresql + postgresql + 9.3-1100-jdbc41 + test + - - - org.springframework - spring-beans - ${spring.version} - test - - - org.springframework - spring-core - ${spring.version} - test - - - org.springframework - spring-context - ${spring.version} - test - - - org.springframework - spring-test - ${spring.version} - test - - - junit - junit - ${junit.version} - test - - - org.mockito - mockito-core - ${mockito.version} - test - - - org.hamcrest - hamcrest-all - ${hamcrest.version} - test - - - org.kubek2k - springockito - 1.0.9 - test - - - org.slf4j - slf4j-log4j12 - ${deps.slf4j} - test - - - org.slf4j - jcl-over-slf4j - ${deps.slf4j} - test - - - org.slf4j - jul-to-slf4j - ${deps.slf4j} - test - - - log4j - log4j - 1.2.17 - test - - + + + org.springframework + spring-beans + ${spring.version} + test + + + org.springframework + spring-core + ${spring.version} + test + + + org.springframework + spring-context + ${spring.version} + test + + + org.springframework + spring-test + ${spring.version} + test + + + junit + junit + ${junit.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.hamcrest + hamcrest-all + ${hamcrest.version} + test + + + org.kubek2k + springockito + 1.0.9 + test + + + org.slf4j + slf4j-log4j12 + ${deps.slf4j} + test + + + org.slf4j + jcl-over-slf4j + ${deps.slf4j} + test + + + org.slf4j + jul-to-slf4j + ${deps.slf4j} + test + + + log4j + log4j + 1.2.17 + test + + - - 1.10.19 - 4.12 - 1.3 - 4.3.2.RELEASE - 1.7.12 - 8 - + + 1.10.19 + 4.12 + 1.3 + 4.3.2.RELEASE + 1.7.12 + 8 + From 7f72ed3114f3eef0ecb99510fabe4f2dbdf1a38f Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Sun, 2 Dec 2018 21:20:29 -0500 Subject: [PATCH 2/7] Add generic --- .../ru/yandex/qatools/embed/postgresql/PostgresStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresStarter.java b/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresStarter.java index d0354fb..88df666 100644 --- a/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresStarter.java +++ b/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresStarter.java @@ -52,7 +52,7 @@ public static IRuntimeConfig runtimeConfig(Command cmd) { public static , P extends AbstractPGProcess> PostgresStarter getCommand(Command command, IRuntimeConfig config) { - return new PostgresStarter<>(command.executableClass(), config); + return new PostgresStarter(command.executableClass(), config); } public static , P extends AbstractPGProcess> From c337356c85ec01be16fac396c99736942b2b27a4 Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Mon, 3 Dec 2018 23:50:03 -0500 Subject: [PATCH 3/7] Allow command-line APIs for all processes --- .../embed/postgresql/PostgresProcess.java | 74 +++++++++--------- .../postgresql/TestPsqlDumpEndToEnd.java | 76 +++++++++++++++++++ 2 files changed, 116 insertions(+), 34 deletions(-) create mode 100644 src/test/java/ru/yandex/qatools/embed/postgresql/TestPsqlDumpEndToEnd.java diff --git a/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresProcess.java b/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresProcess.java index f8f2a7d..fbae1ab 100644 --- a/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresProcess.java +++ b/src/main/java/ru/yandex/qatools/embed/postgresql/PostgresProcess.java @@ -283,22 +283,13 @@ protected final void onAfterProcessStart(ProcessControl process, } while (trial++ < MAX_CREATEDB_TRIALS); } - /** - * Import into database from file - * - * @param file The file to import into database - */ - public void importFromFile(File file) { - importFromFileWithArgs(file); - } - /** * Import into database from file with additional args * * @param file * @param cliArgs additional arguments for psql (be sure to separate args from their values) */ - public void importFromFileWithArgs(File file, String... cliArgs) { + public void importFromFile(File file, String... cliArgs) { if (file.exists()) { String[] args = { "-U", getConfig().credentials().username(), @@ -334,36 +325,51 @@ public void restoreFromFile(File file, String... cliArgs) { } } - public void exportToFile(File file) { - runCmd(getConfig(), runtimeConfig, PgDump, "", new HashSet<>(singletonList("export from " + getConfig().storage().dbName() + " failed")), - "-U", getConfig().credentials().username(), - "-d", getConfig().storage().dbName(), - "-h", getConfig().net().host(), - "-p", String.valueOf(getConfig().net().port()), - "-f", file.getAbsolutePath() - ); + /** + * Export (dump) database to file with additional args + * + * @param file + * @param cliArgs additional arguments for psql (be sure to separate args from their values) + */ + public void exportToFile(File file, String... cliArgs) { + String[] args = { + "-U", getConfig().credentials().username(), + "-d", getConfig().storage().dbName(), + "-h", getConfig().net().host(), + "-p", String.valueOf(getConfig().net().port()), + "-f", file.getAbsolutePath()}; + if (cliArgs != null && cliArgs.length != 0) { + args = ArrayUtils.addAll(args, cliArgs); + } + runCmd(getConfig(), runtimeConfig, PgDump, "", new HashSet<>(singletonList("export from " + getConfig().storage().dbName() + " failed")), args); } + /** + * Export (dump) database schema to file + * + * @param file + */ public void exportSchemeToFile(File file) { - runCmd(getConfig(), runtimeConfig, PgDump, "", new HashSet<>(singletonList("export from " + getConfig().storage().dbName() + " failed")), - "-U", getConfig().credentials().username(), - "-d", getConfig().storage().dbName(), - "-h", getConfig().net().host(), - "-p", String.valueOf(getConfig().net().port()), - "-f", file.getAbsolutePath(), - "-s" - ); + exportToFile(file, "-s"); } + /** + * Export (dump) database schema to file + * + * @param file + */ + /* Alias for English speakers */ + public void exportSchemaToFile(File file) { + exportSchemeToFile(file); + } + + /** + * Export (dump) database data to file + * + * @param file + */ public void exportDataToFile(File file) { - runCmd(getConfig(), runtimeConfig, PgDump, "", new HashSet<>(singletonList("export from " + getConfig().storage().dbName() + " failed")), - "-U", getConfig().credentials().username(), - "-d", getConfig().storage().dbName(), - "-h", getConfig().net().host(), - "-p", String.valueOf(getConfig().net().port()), - "-f", file.getAbsolutePath(), - "-a" - ); + exportToFile(file, "-a"); } public boolean isProcessReady() { diff --git a/src/test/java/ru/yandex/qatools/embed/postgresql/TestPsqlDumpEndToEnd.java b/src/test/java/ru/yandex/qatools/embed/postgresql/TestPsqlDumpEndToEnd.java new file mode 100644 index 0000000..4f07cf7 --- /dev/null +++ b/src/test/java/ru/yandex/qatools/embed/postgresql/TestPsqlDumpEndToEnd.java @@ -0,0 +1,76 @@ +package ru.yandex.qatools.embed.postgresql; + +import org.junit.Test; + +import java.io.File; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public class TestPsqlDumpEndToEnd extends AbstractPsqlTest { + + @Test + public void testPsqlDumpEndToEnd() throws Exception { + + // Load dump + process.importFromFile(new File("src/test/resources/test.backup")); + assertThat(conn, not(nullValue())); + + assertSchemaAndData(); + + // Create binary dump + File fullExportDump = File.createTempFile("full_", ".dmp"); + process.exportToFile(fullExportDump, "-Fc"); + assertTrue(fullExportDump.exists()); + assertTrue(fullExportDump.length() > 0); + + // Create new connection + tearDown(); + setUp(); + + // Load binary dump into a fresh database + assertTrue(fullExportDump.exists()); + process.restoreFromFile(fullExportDump); + assertThat(conn, not(nullValue())); + + assertSchemaAndData(); + + } + + private void assertSchemaAndData() throws SQLException { + + String expected; + try (Statement statement = conn.createStatement(); + ResultSet res = statement.executeQuery("SELECT * FROM table1;")) { + assertThat(res, not(nullValue())); + String tableString = readTable(res); + + assertThat("Missing content in relation 'table1' in dump file!", tableString, not(nullValue())); + + expected = "test\t1\ta\n" + "test\t2\tb\n" + "test\t3\tc\n" + "test\t4\td\n"; + assertEquals(expected, tableString); + } + } + + private String readTable(ResultSet res) throws SQLException { + StringBuilder sb = null; + while (res.next()) { + if (null == sb) + sb = new StringBuilder(); + sb.append(res.getString("col1")); + sb.append("\t"); + sb.append(res.getInt("col2")); + sb.append("\t"); + sb.append(res.getString("col3")); + sb.append("\n"); + } + return null != sb ? sb.toString() : null; + } +} \ No newline at end of file From ccfd12bb3f45ee295ff45ffa1d126ed61b85c90f Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Tue, 4 Dec 2018 19:53:04 -0500 Subject: [PATCH 4/7] Trigger a new build --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6583652..89b8d8b 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,4 @@ postgres.start(cachedRuntimeConfig("C:\\Users\\vasya\\pgembedded-installation")) * 11.1: on Mac OS X and Windows 64 bit * 10.6, 9.6.11, 9.5.15: on Linux, Windows, Mac OS X * any custom version + \ No newline at end of file From 9c36b9eec5033b719e6ed49a229e86d1d25a872a Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Wed, 30 Jan 2019 20:07:50 -0500 Subject: [PATCH 5/7] Attempt to reformat using IntelliJ IDEA --- pom.xml | 452 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 226 insertions(+), 226 deletions(-) diff --git a/pom.xml b/pom.xml index 7cff557..974d4c0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,242 +1,242 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - org.sonatype.oss - oss-parent - 9 - + + org.sonatype.oss + oss-parent + 9 + - 4.0.0 - ru.yandex.qatools.embed - postgresql-embedded - 2.11-SNAPSHOT - Embedded PostgreSQL (based on Flapdoodle-OSS embedded services) + 4.0.0 + ru.yandex.qatools.embed + postgresql-embedded + 2.11-SNAPSHOT + Embedded PostgreSQL (based on Flapdoodle-OSS embedded services) - An embedded PostgreSQL... + An embedded PostgreSQL... - - Yandex - http://company.yandex.com - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - GitHub Issues - https://github.com/yandex-qatools/postgresql-embedded/issues - + + Yandex + http://company.yandex.com + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + GitHub Issues + https://github.com/yandex-qatools/postgresql-embedded/issues + - - scm:git:git@github.com:yandex-qatools/postgresql-embedded.git - scm:git:git@github.com:yandex-qatools/postgresql-embedded.git - git@github.com:yandex-qatools/postgresql-embedded.git - HEAD - + + scm:git:git@github.com:yandex-qatools/postgresql-embedded.git + scm:git:git@github.com:yandex-qatools/postgresql-embedded.git + git@github.com:yandex-qatools/postgresql-embedded.git + HEAD + - - + + - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - ${jdk} - ${jdk} - UTF-8 - - + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + ${jdk} + ${jdk} + UTF-8 + + - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - UTF-8 - - - - org.apache.maven.plugins - maven-release-plugin - 2.5 - - deploy -DskipTests=true - - - - org.apache.maven.scm - maven-scm-api - 1.9.1 - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.9.1 - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - verify - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - -Xdoclint:none - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.0 - - - + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + UTF-8 + + + + org.apache.maven.plugins + maven-release-plugin + 2.5 + + deploy -DskipTests=true + + + + org.apache.maven.scm + maven-scm-api + 1.9.1 + + + org.apache.maven.scm + maven-scm-provider-gitexe + 1.9.1 + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + verify + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + -Xdoclint:none + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.1 - - - sign-artifacts - verify - - sign - - - - - - - - + + + release-sign-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.1 + + + sign-artifacts + verify + + sign + + + + + + + + - - - de.flapdoodle.embed - de.flapdoodle.embed.process - 2.0.2 - + + + de.flapdoodle.embed + de.flapdoodle.embed.process + 2.0.2 + - - org.postgresql - postgresql - 9.3-1100-jdbc41 - test - + + org.postgresql + postgresql + 9.3-1100-jdbc41 + test + - - - org.springframework - spring-beans - ${spring.version} - test - - - org.springframework - spring-core - ${spring.version} - test - - - org.springframework - spring-context - ${spring.version} - test - - - org.springframework - spring-test - ${spring.version} - test - - - junit - junit - ${junit.version} - test - - - org.mockito - mockito-core - ${mockito.version} - test - - - org.hamcrest - hamcrest-all - ${hamcrest.version} - test - - - org.kubek2k - springockito - 1.0.9 - test - - - org.slf4j - slf4j-log4j12 - ${deps.slf4j} - test - - - org.slf4j - jcl-over-slf4j - ${deps.slf4j} - test - - - org.slf4j - jul-to-slf4j - ${deps.slf4j} - test - - - log4j - log4j - 1.2.17 - test - - + + + org.springframework + spring-beans + ${spring.version} + test + + + org.springframework + spring-core + ${spring.version} + test + + + org.springframework + spring-context + ${spring.version} + test + + + org.springframework + spring-test + ${spring.version} + test + + + junit + junit + ${junit.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.hamcrest + hamcrest-all + ${hamcrest.version} + test + + + org.kubek2k + springockito + 1.0.9 + test + + + org.slf4j + slf4j-log4j12 + ${deps.slf4j} + test + + + org.slf4j + jcl-over-slf4j + ${deps.slf4j} + test + + + org.slf4j + jul-to-slf4j + ${deps.slf4j} + test + + + log4j + log4j + 1.2.17 + test + + - - 1.10.19 - 4.12 - 1.3 - 4.3.2.RELEASE - 1.7.12 - 8 - + + 1.10.19 + 4.12 + 1.3 + 4.3.2.RELEASE + 1.7.12 + 8 + From 72f5ea86f3be795c126c6c56c376c863ba41aa90 Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Wed, 30 Jan 2019 20:09:27 -0500 Subject: [PATCH 6/7] Attempt to reformat --- pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 974d4c0..85cd55b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,5 @@ - + org.sonatype.oss From ad9779bfedc401f6726776daf32c377170124ffa Mon Sep 17 00:00:00 2001 From: Sualeh Fatehi Date: Wed, 30 Jan 2019 20:11:16 -0500 Subject: [PATCH 7/7] Attempt to remove diff --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 89b8d8b..fb5ef62 100644 --- a/README.md +++ b/README.md @@ -121,5 +121,4 @@ postgres.start(cachedRuntimeConfig("C:\\Users\\vasya\\pgembedded-installation")) * 11.1: on Mac OS X and Windows 64 bit * 10.6, 9.6.11, 9.5.15: on Linux, Windows, Mac OS X -* any custom version - \ No newline at end of file +* any custom version \ No newline at end of file