Skip to content

Commit f7d8f7c

Browse files
authored
Make mongo-hibernate.jar a Java module (#149)
Also: fix the INFO log message about the DBMS and the driver HIBERNATE-52 HIBERNATE-141
1 parent d875845 commit f7d8f7c

File tree

104 files changed

+1748
-179
lines changed

Some content is hidden

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

104 files changed

+1748
-179
lines changed

.evergreen/config.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ tasks:
137137
args:
138138
- run-integration-tests.sh
139139

140+
- name: run-smoke-tests
141+
tags:
142+
- pr
143+
commands:
144+
- func: bootstrap-mongo-orchestration
145+
- command: subprocess.exec
146+
type: test
147+
params:
148+
working_dir: src
149+
binary: bash
150+
add_to_path:
151+
- .evergreen
152+
args:
153+
- run-smoke-tests.sh
154+
140155
- name: publish-snapshot
141156
depends_on:
142157
- variant: static-checks
@@ -227,9 +242,16 @@ buildvariants:
227242
tasks:
228243
- name: run-unit-tests
229244

230-
- matrix_name: mongo-hibernate
231-
matrix_spec: { mongo-version: "*", topology: "*", os: "*" }
245+
- matrix_name: run-smoke-tests
246+
matrix_spec: { mongo-version: "8.0", topology: replicaset, os: linux }
247+
display_name: "Smoke Tests"
248+
tags:
249+
- pr
250+
tasks:
251+
- name: run-smoke-tests
232252

253+
- matrix_name: run-integration-tests
254+
matrix_spec: { mongo-version: "*", topology: "*", os: "*" }
233255
display_name: "${mongo-version} ${topology} ${os}"
234256
tags:
235257
- pr

.evergreen/fetch-drivers-tools.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ if [[ -z "$DRIVERS_TOOLS" ]]; then
77
exit 1
88
fi
99

10-
rm -rf $DRIVERS_TOOLS
11-
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
10+
rm -rf "$DRIVERS_TOOLS"
11+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git "$DRIVERS_TOOLS"

.evergreen/java-config.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Java configurations for evergreen
44

55
export JDK17="/opt/java/jdk17"
6-
export JDK21="/opt/java/jdk21"
76

87
if [ -d "$JDK17" ]; then
98
export JAVA_HOME=$JDK17

.evergreen/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ fi
2525
SYSTEM_PROPERTIES="-Dorg.gradle.internal.publish.checksums.insecure=true"
2626

2727
./gradlew -version
28-
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info ${TASK}
28+
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info "${TASK}"

.evergreen/run-integration-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ echo "MongoDB version: ${MONGODB_VERSION}; topology: ${TOPOLOGY}"
1515

1616
./gradlew -version
1717

18-
./gradlew -PjavaVersion=${JAVA_VERSION} --stacktrace --info --continue clean integrationTest
18+
./gradlew -PjavaVersion="${JAVA_VERSION}" --stacktrace --info --continue clean integrationTest

.evergreen/run-smoke-tests.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -o xtrace # Write all commands first to stderr
4+
set -o errexit # Exit the script with error if any of the commands fail
5+
6+
############################################
7+
# Main Program #
8+
############################################
9+
10+
source java-config.sh
11+
12+
echo "mongo-hibernate: running smoke tests ..."
13+
14+
echo "MongoDB version: ${MONGODB_VERSION}; topology: ${TOPOLOGY}"
15+
16+
./gradlew -version
17+
18+
./gradlew -PjavaVersion="${JAVA_VERSION}" publishToMavenLocal \
19+
&& ./example-module/mvnw clean verify --file ./example-module/pom.xml \
20+
-DjavaVersion="${JAVA_VERSION}" \
21+
-DprojectVersion="$(./gradlew -q printProjectVersion)"

.evergreen/run-unit-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ echo "mongo-hibernate: running unit tests ..."
1313

1414
./gradlew -version
1515

16-
./gradlew -PjavaVersion=${JAVA_VERSION} --stacktrace --info --continue clean test
16+
./gradlew -PjavaVersion="${JAVA_VERSION}" --stacktrace --info --continue clean test

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# These are Windows script files and should use crlf
88
*.bat text eol=crlf
9+
*.cmd text eol=crlf
910

1011
# Binary files should be left untouched
1112
*.jar binary
12-

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/bin/
2525

2626
# Intellij IDEA
27-
/.idea/
27+
.idea/
2828
/*.ipr
2929
/*.iws
3030
/*.iml
@@ -34,4 +34,5 @@
3434
# Gradle
3535
.gradle/
3636
.kotlin/
37-
build/
37+
build/
38+
target/

README.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ instead of SQL. This product works by:
3535
- [Manual](https://www.mongodb.com/docs/languages/java/mongodb-hibernate/current)
3636
- [API](https://javadoc.io/doc/org.mongodb/mongodb-hibernate/latest/index.html)
3737

38-
[Standalone deployments](https://www.mongodb.com/docs/manual/reference/glossary/#std-term-standalone) are not supported,
38+
MongoDB [standalone deployments](https://www.mongodb.com/docs/manual/reference/glossary/#std-term-standalone) are not supported,
3939
because they [do not support transactions](https://www.mongodb.com/docs/manual/core/transactions-production-consideration/).
4040
If you use one, you may [convert it to a replica set](https://www.mongodb.com/docs/manual/tutorial/convert-standalone-to-replica-set/).
4141

@@ -46,6 +46,16 @@ The `groupId:artifactId` coordinates: `org.mongodb:mongodb-hibernate`.
4646
- [Maven Central Repository](https://repo.maven.apache.org/maven2/org/mongodb/mongodb-hibernate/)
4747
- [Maven Central Repository Search](https://central.sonatype.com/artifact/org.mongodb/mongodb-hibernate)
4848

49+
### Examples
50+
51+
[Maven](https://maven.apache.org/) is used as a build tool.
52+
53+
The Java module with example applications is located in
54+
55+
- [`./example-module`](example-module)
56+
57+
The examples may be run by running the smoke tests as specified in [Run Smoke Tests](#run-smoke-tests).
58+
4959
### Bug Reports
5060

5161
Use ["Extension for Hibernate ORM" at jira.mongodb.org](https://jira.mongodb.org/projects/HIBERNATE/issues).
@@ -61,7 +71,7 @@ Use ["Drivers & Frameworks"/"Frameworks (e.g. Django, Hibernate, EFCore)" at fee
6171
### Build from Source
6272

6373
```console
64-
./gradlew clean build
74+
./gradlew build
6575
```
6676

6777
### Static Code Analysis
@@ -97,19 +107,11 @@ The analysis is done as part of the Gradle `compileJava` task execution.
97107

98108
### Testing
99109

100-
This project uses separate directories for unit and integration tests:
110+
This project uses separate directories for unit, integration, smoke tests:
101111

102112
- [`./src/test`](src/test)
103113
- [`./src/integrationTest`](src/integrationTest)
104-
105-
Integration tests require a MongoDB deployment with test commands enabled, which may be achieved with the
106-
[`--setParameter enableTestCommands=1`](https://www.mongodb.com/docs/manual/reference/parameters/)
107-
command-line arguments.
108-
109-
You may change the [MongoDB connection string](https://www.mongodb.com/docs/manual/reference/connection-string/)
110-
via the [`jakarta.persistence.jdbc.url`](https://docs.hibernate.org/orm/6.6/userguide/html_single/#settings-jakarta.persistence.jdbc.url)
111-
configuration property
112-
in [`./src/integrationTest/resources/hibernate.properties`](src/integrationTest/resources/hibernate.properties).
114+
- [`./example-module/src/smokeTest`](example-module/src/smokeTest)
113115

114116
#### Run Unit Tests
115117

@@ -119,10 +121,38 @@ in [`./src/integrationTest/resources/hibernate.properties`](src/integrationTest/
119121

120122
#### Run Integration Tests
121123

124+
The integration tests require a MongoDB deployment that
125+
126+
- is accessible at `localhost:27017`;
127+
- You may change the [MongoDB connection string](https://www.mongodb.com/docs/manual/reference/connection-string/)
128+
via the [`jakarta.persistence.jdbc.url`](https://docs.hibernate.org/orm/6.6/userguide/html_single/#settings-jakarta.persistence.jdbc.url)
129+
configuration property
130+
in [`./src/integrationTest/resources/hibernate.properties`](src/integrationTest/resources/hibernate.properties).
131+
- has test commands enabled.
132+
- This may be achieved with the
133+
[`--setParameter enableTestCommands=1`](https://www.mongodb.com/docs/manual/reference/parameters/)
134+
command-line arguments.
135+
122136
```console
123137
./gradlew integrationTest
124138
```
125139

140+
#### Run Smoke Tests
141+
142+
The smoke tests with the `Tests` suffix do not require a MongoDB deployment.
143+
The smoke tests with the `IntegrationTests` suffix, as well as the examples, require a MongoDB deployment that
144+
145+
- is accessible at `localhost:27017`.
146+
- You may change this by modifying the examples run by the smoke tests.
147+
148+
```console
149+
source ./.evergreen/java-config.sh \
150+
&& ./gradlew -PjavaVersion=${JAVA_VERSION} publishToMavenLocal \
151+
&& ./example-module/mvnw verify --file ./example-module/pom.xml \
152+
-DjavaVersion="${JAVA_VERSION}" \
153+
-DprojectVersion="$(./gradlew -q printProjectVersion)"
154+
```
155+
126156
### Continuous Integration
127-
[Evergreen](https://github.com/evergreen-ci/evergreen) and [GitHub actions](https://docs.github.com/en/actions)
157+
[Evergreen](https://github.com/evergreen-ci/evergreen) and [GitHub Actions](https://docs.github.com/en/actions)
128158
are used for continuous integration.

0 commit comments

Comments
 (0)