postgresql-jdbc.git / summary / log / commit / refs
commit b4b28bf7ea29ded5bdd68d2beed4b67f9450f84c
Author: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
Date: Fri Dec 01 12:44:37 2023 +0000
chore: add src/testFixtures to share test-related code across subprojects
Previously TestUtil.java was declared in src/test/..., and there was no way
to reuse it in the benchmarks.
benchmarks/build.gradle.kts | 3 +++
.../src/jmh/java/org/postgresql/util/ConnectionUtil.java | 15 +++++++--------
pgjdbc/build.gradle.kts | 4 ++++
.../java/org/postgresql/test/TestUtil.java | 0
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts
index c5ccc572..25521870 100644
--- a/benchmarks/build.gradle.kts
+++ b/benchmarks/build.gradle.kts
@@ -3,6 +3,7 @@
* See the LICENSE file in the project root for more information.
*/
plugins {
+ id("java-test-fixtures")
id("build-logic.java-library")
id("me.champeau.jmh")
}
@@ -10,6 +11,8 @@ plugins {
dependencies {
// Make jmhCompileClasspath resolvable
jmhImplementation(project(":postgresql"))
+ jmhImplementation(testFixtures(project(":postgresql")))
+ jmhRuntimeOnly("com.ongres.scram:client:2.1")
jmhImplementation("org.openjdk.jmh:jmh-core:1.37")
jmhImplementation("org.openjdk.jmh:jmh-generator-annprocess:1.37")
}
diff --git a/benchmarks/src/jmh/java/org/postgresql/util/ConnectionUtil.java b/benchmarks/src/jmh/java/org/postgresql/util/ConnectionUtil.java
index 5a186418..91225671 100644
--- a/benchmarks/src/jmh/java/org/postgresql/util/ConnectionUtil.java
+++ b/benchmarks/src/jmh/java/org/postgresql/util/ConnectionUtil.java
@@ -6,6 +6,7 @@
package org.postgresql.util;
import org.postgresql.PGProperty;
+import org.postgresql.test.TestUtil;
import java.util.Properties;
@@ -14,44 +15,42 @@ public class ConnectionUtil {
* @return the Postgresql username
*/
public static String getUser() {
- return System.getProperty("user", "test");
+ return TestUtil.getUser();
}
/**
* @return the user's password
*/
public static String getPassword() {
- return System.getProperty("password", "password");
+ return TestUtil.getPassword();
}
/**
* @return the test server
*/
public static String getServer() {
- return System.getProperty("server", "localhost");
+ return TestUtil.getServer();
}
/**
* @return the test port
*/
public static int getPort() {
- return Integer.parseInt(System.getProperty("port", System.getProperty("def_pgport", "5432")));
+ return TestUtil.getPort();
}
/**
* @return the Test database
*/
public static String getDatabase() {
- return System.getProperty("database", "test");
+ return TestUtil.getDatabase();
}
/**
* @return connection url to server
*/
public static String getURL() {
- return "jdbc:postgresql://" + ConnectionUtil.getServer() + ":" + ConnectionUtil.getPort() + "/"
- + ConnectionUtil
- .getDatabase();
+ return TestUtil.getURL();
}
/**
diff --git a/pgjdbc/build.gradle.kts b/pgjdbc/build.gradle.kts
index 7025dcd4..287c244b 100644
--- a/pgjdbc/build.gradle.kts
+++ b/pgjdbc/build.gradle.kts
@@ -16,6 +16,7 @@ import com.github.vlsi.gradle.release.dsl.dependencyLicenses
import com.github.vlsi.gradle.release.dsl.licensesCopySpec
plugins {
+ id("java-test-fixtures")
id("build-logic.java-published-library")
id("build-logic.test-junit5")
id("build-logic.java-comment-preprocessor")
@@ -87,6 +88,8 @@ dependencies {
implementation("org.checkerframework:checker-qual:3.40.0")
testImplementation("se.jiderhamn:classloader-leak-test-framework:1.1.2")
+ testFixturesImplementation("junit:junit:4.13.2")
+ testFixturesImplementation("org.checkerframework:checker-qual:3.40.0")
}
val skipReplicationTests by props()
@@ -381,6 +384,7 @@ val sourceDistribution by tasks.registering(Tar::class) {
exclude("*/org/postgresql/test/sspi/*.java")
exclude("*/org/postgresql/replication/**")
}
+ from("$withoutAnnotations/src/testFixtures")
}
into("certdir") {
from("$rootDir/certdir") {
diff --git a/pgjdbc/src/test/java/org/postgresql/test/TestUtil.java b/pgjdbc/src/testFixtures/java/org/postgresql/test/TestUtil.java
similarity index 100%
rename from pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
rename to pgjdbc/src/testFixtures/java/org/postgresql/test/TestUtil.java
[parent: 7ee6a373de3e]