|
4 | 4 |
|
5 | 5 | This project provides lightweight bundles of PostgreSQL binaries with reduced size that are intended for testing purposes. |
6 | 6 | It is a supporting project for the primary [io.zonky.test:embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) and [io.zonky.test:embedded-postgres](https://github.com/zonkyio/embedded-postgres) projects. |
7 | | -However, with a little effort it can be also applicable with [com.opentable:otj-pg-embedded](https://github.com/opentable/otj-pg-embedded) and maybe some other projects. |
| 7 | +However, with a little effort, the embedded binaries can also be integrated with other projects. |
8 | 8 |
|
9 | | -## Provides |
| 9 | +## Provided features |
10 | 10 |
|
11 | 11 | * Lightweight bundles of PostgreSQL binaries with reduced size (~10MB) |
12 | 12 | * Embedded PostgreSQL 11+ binaries even for Linux platform |
13 | 13 | * Configurable version of PostgreSQL binaries |
14 | 14 |
|
15 | | -## Use with [embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) or [embedded-postgres](https://github.com/zonkyio/embedded-postgres) project |
| 15 | +## Projects using embedded binaries |
16 | 16 |
|
17 | | -All necessary dependencies are already included in these projects, so no further action is required. |
18 | | -However, you can change the version of the postgres binaries by following the instructions described in [Postgres version](#postgres-version). |
19 | | - |
20 | | -## Use with [com.opentable:otj-pg-embedded](https://github.com/opentable/otj-pg-embedded) project |
21 | | - |
22 | | -First, you have to add any of the [available dependencies](https://mvnrepository.com/artifact/io.zonky.test.postgres) to your Maven configuration: |
23 | | - |
24 | | -```xml |
25 | | -<dependency> |
26 | | - <groupId>io.zonky.test.postgres</groupId> |
27 | | - <artifactId>embedded-postgres-binaries-linux-amd64</artifactId> |
28 | | - <version>11.11.0</version> |
29 | | - <scope>test</scope> |
30 | | -</dependency> |
31 | | -``` |
32 | | - |
33 | | -Then you need to implement a custom [PgBinaryResolver](https://github.com/opentable/otj-pg-embedded/blob/master/src/main/java/com/opentable/db/postgres/embedded/PgBinaryResolver.java): |
34 | | -```java |
35 | | -public class CustomPostgresBinaryResolver implements PgBinaryResolver { |
36 | | - public InputStream getPgBinary(String system, String architecture) throws IOException { |
37 | | - ClassPathResource resource = new ClassPathResource(format("postgres-%s-%s.txz", system, architecture)); |
38 | | - return resource.getInputStream(); |
39 | | - } |
40 | | -} |
41 | | -``` |
42 | | - |
43 | | -<details> |
44 | | - <summary>Alpine variant</summary> |
45 | | - |
46 | | - ```java |
47 | | - public class CustomPostgresBinaryResolver implements PgBinaryResolver { |
48 | | - public InputStream getPgBinary(String system, String architecture) throws IOException { |
49 | | - ClassPathResource resource = new ClassPathResource(format("postgres-%s-%s-alpine_linux.txz", system, architecture)); |
50 | | - return resource.getInputStream(); |
51 | | - } |
52 | | - } |
53 | | - ``` |
54 | | - |
55 | | -</details><br/> |
56 | | - |
57 | | -And finally register it to the junit rule. |
58 | | - |
59 | | -```java |
60 | | -@Rule |
61 | | -public SingleInstancePostgresRule pg = EmbeddedPostgresRules.singleInstance() |
62 | | - .customize(builder -> builder.setPgBinaryResolver(new CustomPostgresBinaryResolver())); |
63 | | -``` |
| 17 | +* [zonkyio/embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) (Java - Spring) |
| 18 | +* [zonkyio/embedded-postgres](https://github.com/zonkyio/embedded-postgres) (Java) |
| 19 | +* [hgschmie/pg-embedded](https://github.com/hgschmie/pg-embedded) (Java) |
| 20 | +* [fergusstrange/embedded-postgres](https://github.com/fergusstrange/embedded-postgres) (Go) |
| 21 | +* [faokunega/pg-embed](https://github.com/faokunega/pg-embed) (Rust) |
64 | 22 |
|
65 | 23 | ## Postgres version |
66 | 24 |
|
|
0 commit comments