You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
6
6
project continues, but with a very different philosophy - wrapping the postgres instance in a docker container.
7
7
Whereas this project follows the original approach of using native postgres binaries running directly on the target platform without the overhead of virtualization.
8
8
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
+
9
11
The library allows embedding PostgreSQL into Java application code with no external dependencies.
10
12
Excellent for allowing you to unit test with a "real" Postgres without requiring end users to install and set up a database cluster.
11
13
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
-
14
14
## Features
15
15
16
16
* All features of `com.opentable:otj-pg-embedded:0.13.3`
17
17
* Configurable version of [PostgreSQL binaries](https://github.com/zonkyio/embedded-postgres-binaries)
18
18
* PostgreSQL 11+ support even for Linux platform
19
19
* Support for running inside Docker, including Alpine Linux
20
20
21
-
## Maven Configuration
21
+
## Gradle Configuration
22
22
23
-
Add the following Maven dependency:
24
23
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")
# Check this on https://central.sonatype.com/artifact/com.smushytaco/embedded-postgres/
34
+
embedded_postgres_version = 3.0.0
32
35
```
33
36
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).
This simply has JUnit manage an instance of EmbeddedPostgres (start, stop). You can then use this to get a DataSource with: `pg.getEmbeddedPostgres().getPostgresDatabase();`
46
49
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.
48
51
49
52
Default username/password is: postgres/postgres and the default database is 'postgres'
50
53
@@ -53,18 +56,14 @@ Default username/password is: postgres/postgres and the default database is 'pos
53
56
You can easily integrate Flyway or Liquibase database schema migration:
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.
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:
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"
# Check this on https://central.sonatype.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom/
88
+
postgresql_version = 18.0.0
89
+
```
126
90
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/).
128
92
129
93
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.
130
94
131
95
## Additional architectures
132
96
133
97
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.
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.
148
110
149
111
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.
150
112
@@ -216,4 +178,4 @@ Below are some examples of how to prepare a docker image running with a non-root
216
178
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.
217
179
218
180
## 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