Skip to content

Commit 3a12654

Browse files
committed
Modernize Everything
1 parent 91a6717 commit 3a12654

55 files changed

Lines changed: 1232 additions & 1584 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
USERNAME_TOKEN=
2+
PASSWORD_TOKEN=
3+
PASSPHRASE=

.github/dependabot.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Dokka to GitHub Pages
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: "pages"
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Validate Gradle Wrapper
24+
uses: gradle/actions/wrapper-validation@v5
25+
26+
- name: Set up Java
27+
uses: actions/setup-java@v5
28+
with:
29+
distribution: temurin
30+
java-version: 25
31+
cache: gradle
32+
33+
- name: Make Gradle wrapper executable
34+
run: chmod +x gradlew
35+
36+
- name: Build Dokka HTML
37+
run: ./gradlew dokkaGenerateHtml
38+
39+
- name: Upload Pages artifact
40+
uses: actions/upload-pages-artifact@v4
41+
with:
42+
path: build/dokka/html
43+
44+
deploy:
45+
needs: build
46+
runs-on: ubuntu-latest
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
steps:
51+
- id: deployment
52+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
java: [17, 21, 25] # LTS and newer versions
9+
java: [25]
1010
steps:
1111
- name: Checkout project
1212
uses: actions/checkout@v5
@@ -15,9 +15,9 @@ jobs:
1515
- name: Set up JDK
1616
uses: actions/setup-java@v5
1717
with:
18-
distribution: 'zulu'
18+
distribution: temurin
1919
java-version: ${{ matrix.java }}
20-
cache: 'gradle'
20+
cache: gradle
2121
- name: Make Gradle wrapper executable
2222
run: chmod +x gradlew
2323
- name: Build with Gradle

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ dist/
2020
.gradle/
2121
build/
2222
out/
23-
classes/
23+
classes/
24+
.PVS-Studio
25+
.env
26+
private-key.asc

HEADER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright ${CREATION_YEAR} Tomas Vanek
1+
Copyright ${CREATION_YEAR} Nikan Radan
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

LICENSE.txt

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -174,29 +174,4 @@
174174
incurred by, or claims asserted against, such Contributor by reason
175175
of your accepting any such warranty or additional liability.
176176

177-
END OF TERMS AND CONDITIONS
178-
179-
APPENDIX: How to apply the Apache License to your work.
180-
181-
To apply the Apache License to your work, attach the following
182-
boilerplate notice, with the fields enclosed by brackets "[]"
183-
replaced with your own identifying information. (Don't include
184-
the brackets!) The text should be enclosed in the appropriate
185-
comment syntax for the file format. We also recommend that a
186-
file or class name and description of purpose be included on the
187-
same "printed page" as the copyright notice for easier
188-
identification within third-party archives.
189-
190-
Copyright [yyyy] [name of copyright owner]
191-
192-
Licensed under the Apache License, Version 2.0 (the "License");
193-
you may not use this file except in compliance with the License.
194-
You may obtain a copy of the License at
195-
196-
http://www.apache.org/licenses/LICENSE-2.0
197-
198-
Unless required by applicable law or agreed to in writing, software
199-
distributed under the License is distributed on an "AS IS" BASIS,
200-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201-
See the License for the specific language governing permissions and
202-
limitations under the License.
177+
END OF TERMS AND CONDITIONS

README.md

Lines changed: 46 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
1-
# <img src="zonky.jpg" height="100"> Embedded Postgres
1+
# Embedded Postgres
22

33
## Introduction
44

5-
This project is a fork of [OpenTable Embedded PostgreSQL Component](https://github.com/opentable/otj-pg-embedded) created back in 2018. The original
5+
This project is a fork of [Zonkyio Embedded PostgreSQL](https://github.com/zonkyio/embedded-postgres) which is a fork of [OpenTable Embedded PostgreSQL Component](https://github.com/opentable/otj-pg-embedded) created back in 2018. The original
66
project continues, but with a very different philosophy - wrapping the postgres instance in a docker container.
77
Whereas this project follows the original approach of using native postgres binaries running directly on the target platform without the overhead of virtualization.
88

9+
This fork also differs from the Zonkyio fork in the sense that it depends on the latest LTS version of Java, migrates from the legacy `File` to the modern `Path`, has full javadoc coverage, and drops legacy JUnit 4 support. Think of this as a comprehensive modernization.
10+
911
The library allows embedding PostgreSQL into Java application code with no external dependencies.
1012
Excellent for allowing you to unit test with a "real" Postgres without requiring end users to install and set up a database cluster.
1113

12-
If you are using `Spring` or `Spring Boot` framework you can also consider using the following more specialized [embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) project.
13-
1414
## Features
1515

1616
* All features of `com.opentable:otj-pg-embedded:0.13.3`
1717
* Configurable version of [PostgreSQL binaries](https://github.com/zonkyio/embedded-postgres-binaries)
1818
* PostgreSQL 11+ support even for Linux platform
1919
* Support for running inside Docker, including Alpine Linux
2020

21-
## Maven Configuration
21+
## Gradle Configuration
2222

23-
Add the following Maven dependency:
2423

25-
```xml
26-
<dependency>
27-
<groupId>io.zonky.test</groupId>
28-
<artifactId>embedded-postgres</artifactId>
29-
<version>2.1.1</version>
30-
<scope>test</scope>
31-
</dependency>
24+
To use this with Gradle, add the following to your `build.gradle.kts`:
25+
```kotlin
26+
val embeddedPostgresVersion = providers.gradleProperty("embedded_postgres_version")
27+
dependencies {
28+
testImplementation("com.smushytaco:embedded-postgres:${embeddedPostgresVersion.get()}")
29+
}
30+
```
31+
And the following to your `gradle.properties`:
32+
```properties
33+
# Check this on https://central.sonatype.com/artifact/com.smushytaco/embedded-postgres/
34+
embedded_postgres_version = 3.0.0
3235
```
3336

34-
The default version of the embedded postgres is `PostgreSQL 14.19`, but you can change it by following the instructions described in [Postgres version](#postgres-version).
37+
The default version of the embedded postgres is `PostgreSQL 18.0.0`, but you can change it by following the instructions described in [Postgres version](#postgres-version).
3538

3639
## Basic Usage
3740

3841
In your JUnit test just add:
3942

4043
```java
41-
@Rule
42-
public SingleInstancePostgresRule pg = EmbeddedPostgresRules.singleInstance();
44+
@RegisterExtension
45+
SingleInstancePostgresExtension pg = EmbeddedPostgresExtension.singleInstance();
4346
```
4447

4548
This simply has JUnit manage an instance of EmbeddedPostgres (start, stop). You can then use this to get a DataSource with: `pg.getEmbeddedPostgres().getPostgresDatabase();`
4649

47-
Additionally you may use the [`EmbeddedPostgres`](src/main/java/io/zonky/test/db/postgres/embedded/EmbeddedPostgres.java) class directly by manually starting and stopping the instance; see [`EmbeddedPostgresTest`](src/test/java/io/zonky/test/db/postgres/embedded/EmbeddedPostgresTest.java) for an example.
50+
Additionally, you may use the [`EmbeddedPostgres`](src/main/java/com/smushytaco/postgres/embedded/EmbeddedPostgres.java) class directly by manually starting and stopping the instance; see [`EmbeddedPostgresTest`](src/test/java/com/smushytaco/postgres/embedded/EmbeddedPostgresTest.java) for an example.
4851

4952
Default username/password is: postgres/postgres and the default database is 'postgres'
5053

@@ -53,18 +56,14 @@ Default username/password is: postgres/postgres and the default database is 'pos
5356
You can easily integrate Flyway or Liquibase database schema migration:
5457
##### Flyway
5558
```java
56-
@Rule
57-
public PreparedDbRule db =
58-
EmbeddedPostgresRules.preparedDatabase(
59-
FlywayPreparer.forClasspathLocation("db/my-db-schema"));
59+
@RegisterExtension
60+
PreparedDbExtension db = EmbeddedPostgresExtension.preparedDatabase(FlywayPreparer.forClasspathLocation("db/my-db-schema"));
6061
```
6162

6263
##### Liquibase
6364
```java
64-
@Rule
65-
public PreparedDbRule db =
66-
EmbeddedPostgresRules.preparedDatabase(
67-
LiquibasePreparer.forClasspathLocation("liqui/master.xml"));
65+
@RegisterExtension
66+
PreparedDbExtension db = EmbeddedPostgresExtension.preparedDatabase(LiquibasePreparer.forClasspathLocation("liqui/master.xml"));
6867
```
6968

7069
This will create an independent database for every test with the given schema loaded from the classpath.
@@ -73,78 +72,41 @@ independent databases gives you.
7372

7473
## Postgres version
7574

76-
The default version of the embedded postgres is `PostgreSQL 14.19`, but it can be changed by importing `embedded-postgres-binaries-bom` in a required version into your dependency management section.
77-
78-
```xml
79-
<dependencyManagement>
80-
<dependencies>
81-
<dependency>
82-
<groupId>io.zonky.test.postgres</groupId>
83-
<artifactId>embedded-postgres-binaries-bom</artifactId>
84-
<version>17.6.0</version>
85-
<type>pom</type>
86-
<scope>import</scope>
87-
</dependency>
88-
</dependencies>
89-
</dependencyManagement>
90-
```
75+
The default version of the embedded postgres is `PostgreSQL 18.0.0`, but it can be changed by importing `embedded-postgres-binaries-bom`.
9176

92-
<details>
93-
<summary>Using Maven BOMs in Gradle</summary>
94-
95-
In Gradle, there are several ways how to import a Maven BOM.
96-
97-
1. You can define a resolution strategy to check and change the version of transitive dependencies manually:
98-
99-
configurations.all {
100-
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
101-
if (details.requested.group == 'io.zonky.test.postgres') {
102-
details.useVersion '17.6.0'
103-
}
104-
}
105-
}
106-
107-
2. If you use Gradle 5+, [Maven BOMs are supported out of the box](https://docs.gradle.org/5.0/userguide/managing_transitive_dependencies.html#sec:bom_import), so you can import the bom:
108-
109-
dependencies {
110-
testImplementation enforcedPlatform('io.zonky.test.postgres:embedded-postgres-binaries-bom:17.6.0')
111-
}
112-
113-
3. Or, you can use [Spring's dependency management plugin](https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/#dependency-management-configuration-bom-import) that provides Maven-like dependency management to Gradle:
114-
115-
plugins {
116-
id "io.spring.dependency-management" version "1.1.0"
117-
}
118-
119-
dependencyManagement {
120-
imports {
121-
mavenBom 'io.zonky.test.postgres:embedded-postgres-binaries-bom:17.6.0'
122-
}
123-
}
77+
Add the following to your `build.gradle.kts`;
78+
```kotlin
79+
val postgresqlVersion = providers.gradleProperty("postgresql_version")
80+
dependencies {
81+
testImplementation(enforcedPlatform("io.zonky.test.postgres:embedded-postgres-binaries-bom:${postgresqlVersion.get()}"))
82+
}
83+
```
12484

125-
</details><br/>
85+
And the following to your `gradle.properties`:
86+
```properties
87+
# Check this on https://central.sonatype.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom/
88+
postgresql_version = 18.0.0
89+
```
12690

127-
A list of all available versions of postgres binaries is here: https://mvnrepository.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom
91+
A list of all available versions of postgres binaries can be found [here](https://central.sonatype.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom/).
12892

12993
Note that the release cycle of the postgres binaries is independent of the release cycle of this library, so you can upgrade to a new version of postgres binaries immediately after it is released.
13094

13195
## Additional architectures
13296

13397
By default, only the support for `amd64` architecture is enabled.
134-
Support for other architectures can be enabled by adding the corresponding Maven dependencies as shown in the example below.
135-
136-
```xml
137-
<dependency>
138-
<groupId>io.zonky.test.postgres</groupId>
139-
<artifactId>embedded-postgres-binaries-linux-i386</artifactId>
140-
<scope>test</scope>
141-
</dependency>
98+
Support for other architectures can be enabled by adding the corresponding Maven dependencies as shown in the example below:
99+
100+
```kotlin
101+
dependencies {
102+
testImplementation("io.zonky.test.postgres:embedded-postgres-binaries-linux-i386")
103+
}
142104
```
143105

144106
**Supported platforms:** `Darwin`, `Windows`, `Linux`, `Alpine Linux`
145107
**Supported architectures:** `amd64`, `i386`, `arm32v6`, `arm32v7`, `arm64v8`, `ppc64le`
146108

147-
Note that not all architectures are supported by all platforms, look here for an exhaustive list of all available artifacts: https://mvnrepository.com/artifact/io.zonky.test.postgres
109+
Note that not all architectures are supported by all platforms, look [here](https://central.sonatype.com/namespace/io.zonky.test.postgres/) for an exhaustive list of all available artifacts.
148110

149111
Since `PostgreSQL 10.0`, there are additional artifacts with `alpine-lite` suffix. These artifacts contain postgres binaries for Alpine Linux with disabled [ICU support](https://blog.2ndquadrant.com/icu-support-postgresql-10/) for further size reduction.
150112

@@ -216,4 +178,4 @@ Below are some examples of how to prepare a docker image running with a non-root
216178
If the above do not resolve your error, verify that the correct locales are available in your container. For example, many variants of AlmaLinux:9 do not come with `glibc-langpack-en`. This will lead to misleading errors during `initdb`. Additionally, you can optionally set your locale with `setLocaleConfig()` when building your EmbeddedPostgres instance.
217179

218180
## License
219-
The project is released under version 2.0 of the [Apache License](http://www.apache.org/licenses/LICENSE-2.0.html).
181+
The project is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0).

0 commit comments

Comments
 (0)