File tree Expand file tree Collapse file tree
src/test/java/io/github/thunderz99/cosmos/impl/postgres Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 # refer: https://hub.docker.com/_/postgres
2121 env :
2222 POSTGRES_USER : postgres
23- POSTGRES_PASSWORD : mysecretpassword
23+ POSTGRES_PASSWORD : postgres
2424 POSTGRES_DB : postgres
2525 ports :
2626 - 5432:5432
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ java-cosmos is a client for Azure CosmosDB 's SQL API (also called documentdb fo
2323<dependency >
2424 <groupId >com.github.thunderz99</groupId >
2525 <artifactId >java-cosmos</artifactId >
26- <version >0.8.22 </version >
26+ <version >0.8.23 </version >
2727</dependency >
2828```
2929
Original file line number Diff line number Diff line change 1+ # MongoDB local dev
2+
3+ This folder contains a Docker Compose setup for a single-node MongoDB replica set used by local unit tests.
4+
5+ ## Start
6+
7+ From the repository root:
8+
9+ ``` bash
10+ cd mongo
11+ docker-compose up -d
12+ ```
13+
14+ The setup starts:
15+ - ` mongo-replica ` on ` localhost:27017 `
16+ - ` mongo-init-replica ` to initialize replica set ` rs0 `
17+
18+ ## Verify
19+
20+ ``` bash
21+ docker-compose ps
22+ docker logs mongo-init-replica
23+ ```
24+
25+ When initialization succeeds, logs include ` Replica set initialized. `
26+
27+ ## Local unit test
28+
29+ Then you can run the follow cmd or use an IDE to run unit tests.
30+
31+ ``` bash
32+ mvn -Dtest=' io.github.thunderz99.cosmos.impl.mongo.**.*Test' test
33+ ```
34+
35+ ## Stop
36+
37+ ``` bash
38+ docker-compose down
39+ ```
Original file line number Diff line number Diff line change 1- version : ' 3.8'
21services :
32 mongo-replica :
43 image : mongo:5.0
Original file line number Diff line number Diff line change 44 <groupId >com.github.thunderz99</groupId >
55 <artifactId >java-cosmos</artifactId >
66 <packaging >jar</packaging >
7- <version >0.8.22 </version >
7+ <version >0.8.23 </version >
88 <name >${project.groupId} :${project.artifactId} $</name >
99 <description >A lightweight Azure CosmosDB client for Java</description >
1010 <url >https://github.com/thunderz99/java-cosmos</url >
Original file line number Diff line number Diff line change 1+ FROM postgres:16
2+
3+ # Install dependencies and add the PostgreSQL APT repository
4+ RUN set -eux; \
5+ apt-get update; \
6+ apt-get install -y --no-install-recommends ca-certificates gnupg lsb-release wget; \
7+ mkdir -p /etc/apt/keyrings; \
8+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/keyrings/pgdg.gpg; \
9+ echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list; \
10+ apt-get update; \
11+ apt-get install -y --no-install-recommends postgresql-16-cron; \
12+ rm -rf /var/lib/apt/lists/*
13+
14+ # Copy an initialization script to enable the extension
15+ COPY init-pgcron.sql /docker-entrypoint-initdb.d/
Original file line number Diff line number Diff line change 1+ # PostgreSQL local dev
2+
3+ This folder contains a Docker Compose setup for local PostgreSQL used by unit tests.
4+
5+ The image is built from ` postgres/Dockerfile ` , which installs ` postgresql-16-cron ` and runs ` init-pgcron.sql ` to enable ` pg_cron ` .
6+
7+ ## Start
8+
9+ From the repository root:
10+
11+ ``` bash
12+ cd postgres
13+ docker-compose up -d --build
14+ ```
15+
16+ Default connection details:
17+ - Host: ` localhost `
18+ - Port: ` 5432 `
19+ - Database: ` postgres `
20+ - User: ` postgres `
21+ - Password: ` postgres `
22+
23+ ## Verify
24+
25+ ``` bash
26+ docker-compose ps
27+ docker exec -it postgres16 psql -U postgres -d postgres -c " SELECT extname FROM pg_extension WHERE extname='pg_cron';"
28+ ```
29+
30+ ## Local unit test
31+
32+ Then you can run the follow cmd or use an IDE to run unit tests.
33+
34+ ``` bash
35+ mvn -Dtest=' io.github.thunderz99.cosmos.impl.postgres.**.*Test' test
36+ ```
37+
38+ ## Stop
39+
40+ ``` bash
41+ docker-compose down
42+ ```
Original file line number Diff line number Diff line change 1+ services :
2+ postgres :
3+ build :
4+ context : .
5+ dockerfile : Dockerfile
6+ container_name : postgres16
7+ environment :
8+ POSTGRES_USER : postgres
9+ POSTGRES_PASSWORD : postgres
10+ POSTGRES_DB : postgres
11+ ports :
12+ - " 5432:5432"
13+ command : postgres -c shared_preload_libraries=pg_cron
Original file line number Diff line number Diff line change 1+ CREATE EXTENSION IF NOT EXISTS pg_cron;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public class PostgresImplTest {
1313 /**
1414 * local postgres connection string if test against a local setup.
1515 */
16- public static final String LOCAL_CONNECTION_STRING = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=mysecretpassword &sslmode=disable" ;
16+ public static final String LOCAL_CONNECTION_STRING = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=postgres &sslmode=disable" ;
1717
1818 String db = "unit_test_db_" + RandomStringUtils .randomAlphanumeric (6 );
1919
You can’t perform that action at this time.
0 commit comments