Skip to content

Commit 66894cb

Browse files
committed
Remove unused Dockerfiles and configuration files, update application.properties.
upgraded spring boot and swagger from 2 to 3 Added conrtoller description Fixed readme and added images updated workflow file
1 parent 2790c2b commit 66894cb

29 files changed

+270
-435
lines changed

.github/workflows/tests.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ jobs:
1212
run_tests:
1313
name: Run Tests
1414
runs-on: ubuntu-latest
15+
env:
16+
DB_CONN_STR: ${{ vars.DB_CONN_STR }}
17+
DB_USERNAME: ${{ vars.DB_USERNAME }}
18+
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
1519
strategy:
1620
matrix:
17-
java-version: ["8", "11", "17"]
21+
java-version: ["17", "21"]
1822
steps:
1923
- name: Update repositories
2024
run: |
@@ -30,21 +34,12 @@ jobs:
3034
distribution: "adopt"
3135
cache: "maven"
3236

33-
- name: Replace secrets in application.properties
34-
run: |
35-
sed -i "s#DB_CONN_STR#${{ vars.DB_CONN_STR }}#g" src/main/resources/application.properties
36-
sed -i "s#DB_USERNAME#${{ vars.DB_USERNAME }}#g" src/main/resources/application.properties
37-
sed -i "s#DB_PASSWORD#${{ secrets.DB_PASSWORD }}#g" src/main/resources/application.properties
38-
39-
# Print the updated file for verification
40-
cat ./src/main/resources/application.properties
41-
4237
- name: Run Maven Tests
4338
id: run
4439
run: |
45-
chmod +x mvnw
46-
./mvnw clean install -DskipTests=false -Dmaven.javadoc.skip=true -Dgpg.skip=true -B -V -e
47-
40+
chmod +x mvnw
41+
./mvnw clean install -DskipTests=false -Dmaven.javadoc.skip=true -Dgpg.skip=true -B -V -e
42+
4843
- name: Report Status
4944
if: always()
5045
uses: ravsamhq/notify-slack-action@v1

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ EXPOSE 8080
3232
# Set the entrypoint command to run the JAR file
3333
ENTRYPOINT java -jar /app/runner.jar
3434

35-
# docker build -t java-springboot-quickstart .
36-
# docker run -d --name springboot-container -p 9440:8080 java-springboot-quickstart
35+
# This Dockerfile is used to build a Docker image for a Java Spring Boot application.
36+
# To build the image, run:
37+
# docker build -t java-springboot-quickstart .
38+
# To run the container, use:
39+
# docker run -d --name springboot-container -p 9440:8080 java-springboot-quickstart -e DB_CONN_STR=<connection_string> -e DB_USERNAME=<username> -e DB_PASSWORD=<password>

Dockerfile-couchbase-server

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

Dockerfile-java-springboot-quickstart

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

README.md

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mvn clean install -DskipTests=true
4343

4444
Note: The `-DskipTests=true` option is used to skip the tests. The tests require the application to be running.
4545

46-
Note: The application is tested with Java 17. If you are using a different version of Java, please update the `pom.xml` file accordingly.
46+
Note: The application is tested with Java 11. If you are using a different version of Java, please update the `pom.xml` file accordingly.
4747

4848
### Setup Database Configuration
4949

@@ -54,7 +54,9 @@ Specifically, you need to do the following:
5454
- Create the [database credentials](https://docs.couchbase.com/cloud/clusters/manage-database-users.html) to access the travel-sample bucket (Read and Write) used in the application.
5555
- [Allow access](https://docs.couchbase.com/cloud/clusters/allow-ip-address.html) to the Cluster from the IP on which the application is running.
5656

57-
All configuration for communication with the database is read from the environment variables. We have provided a convenience feature in this quickstart to read the environment variables from a local file, `application.properties` in the `src/main/resources` folder.
57+
All configuration for communication with the database is read from the application properties. We have provided a convenience feature in this quickstart to read the properties from a local file, `application.properties` in the `src/main/resources` folder.
58+
59+
You can also use your system environment variables to set the properties. The properties are read from the environment variables if they are set. The properties are read from the `application.properties` file if the environment variables are not set.
5860

5961
```properties
6062
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
@@ -64,8 +66,7 @@ spring.couchbase.bucket.user=DB_USERNAME
6466
spring.couchbase.bucket.password=DB_PASSWORD
6567
```
6668

67-
Instead of the DB_CONN_STR, DB_USERNAME and DB_PASSWORD
68-
, you need to add the values for the Couchbase connection.
69+
Instead of the DB_CONN_STR, DB_USERNAME and DB_PASSWORD, you need to add the values for the Couchbase connection.
6970

7071
> Note: The connection string expects the `couchbases://` or `couchbase://` part.
7172
@@ -90,32 +91,53 @@ docker build -t java-springboot-quickstart .
9091
Run the Docker image
9192

9293
```sh
93-
docker run -d --name springboot-container -p 8080:8080 java-springboot-quickstart
94+
docker run -d --name springboot-container -p 9440:8080 java-springboot-quickstart -e DB_CONN_STR=<connection_string> -e DB_USERNAME=<username> -e DB_PASSWORD=<password>
9495
```
9596

96-
Note: The `application.properties` file has the connection information to connect to your Capella cluster. These will be part of the environment variables in the Docker container.
97+
Note: The `application.properties` file has the connection information to connect to your Capella cluster. You can also pass the connection information as environment variables to the Docker container.
98+
If you choose not to pass the environment variables, you can update the `application.properties` file in the `src/main/resources` folder.
9799

98100
### Verifying the Application
99101

100102
Once the application starts, you can see the details of the application on the logs.
101103

102-
![Application Startup](app_startup.png)
104+
![Application Startup](./assets/images/app-startup-spring-boot.png)
103105

104106
The application will run on port 8080 of your local machine (http://localhost:8080). You will find the interactive Swagger documentation of the API if you go to the URL in your browser. Swagger documentation is used in this demo to showcase the different API endpoints and how they can be invoked. More details on the Swagger documentation can be found in the [appendix](#swagger-documentation).
105107

106-
![Swagger Documentation](swagger_documentation.png)
107-
108+
![Swagger Documentation](./assets/images/swagger-documentation-spring-boot.png)
108109
## Running Tests
109110

110-
To run the integration tests, use the following commands:
111+
To test your application, you can use Maven (mvn) to run the test suite. Here are the steps to run the tests:
112+
113+
### Run All Tests:
114+
115+
```sh
116+
mvn test
117+
```
118+
119+
This command will execute all the test cases in your project.
120+
121+
### Run Individual Tests:
122+
123+
Additionally, you can run individual test classes or methods using the following commands:
124+
125+
To run the tests for the AirlineIntegrationTest class:
111126

112127
```sh
113128
mvn test -Dtest=org.couchbase.quickstart.springboot.controllers.AirlineIntegrationTest
129+
```
130+
131+
To run the tests for the AirportIntegrationTest class:
132+
133+
```sh
114134
mvn test -Dtest=org.couchbase.quickstart.springboot.controllers.AirportIntegrationTest
115-
mvn test -Dtest=org.couchbase.quickstart.springboot.controllers.RouteIntegrationTest
135+
```
116136

117-
You can also run all the tests using the following command:
118-
mvn test
137+
To run the tests for the RouteIntegrationTest class:
138+
139+
```sh
140+
mvn test -Dtest=org.couchbase.quickstart.springboot.controllers.Rout
119141
```
120142

121143
## Appendix
@@ -124,16 +146,16 @@ mvn test
124146

125147
For this quickstart, we use three collections, `airport`, `airline` and `routes` that contain sample airports, airlines and airline routes respectively. The routes collection connects the airports and airlines as seen in the figure below. We use these connections in the quickstart to generate airports that are directly connected and airlines connecting to a destination airport. Note that these are just examples to highlight how you can use SQL++ queries to join the collections.
126148

127-
![travel-sample data model](travel_sample_data_model.png)
149+
![travel-sample data model](/assets/images/travel_sample_data_model.png)
128150

129151
### Extending API by Adding New Entity
130152

131153
If you would like to add another entity to the APIs, these are the steps to follow:
132154

133-
- Create the new entity (collection) in the Couchbase bucket. You can create the collection using the [SDK](https://docs.couchbase.com/java-sdk/current/howtos/provisioning-cluster-resources.html#collection-management) or via the [Couchbase Server interface](https://docs.couchbase.com/cloud/n1ql/n1ql-language-reference/createcollection.html).
134-
- Define the routes in a new file in the `controllers` folder similar to the existing routes like `AirportController.java`.
135-
- Define the service in a new file in the `services` folder similar to the existing services like `AirportService.java`. You'll have to implement the service interface `AirportServiceImpl.java`.
136-
- Define the repository in a new file in the `repositories` folder similar to the existing repositories like `AirportRepository.java`. You'll have to implement the repository interface `AirportRepositoryImpl.java`.
155+
- Create the new entity (collection) in the Couchbase scope. You can create the collection using the [SDK](https://docs.couchbase.com/java-sdk/current/howtos/provisioning-cluster-resources.html#collection-management) or via the [Couchbase Server interface](https://docs.couchbase.com/cloud/n1ql/n1ql-language-reference/createcollection.html).
156+
- Define the routes in a new class in the `controllers` package similar to the existing routes like `AirportController.java`.
157+
- Define the service in a new class in the `services` package similar to the existing services like `AirportService.java`. You'll have to implement the service interface `AirportServiceImpl.java`.
158+
- Define the repository in a new class in the `repositories` package similar to the existing repositories like `AirportRepository.java`. You'll have to implement the repository interface `AirportRepositoryImpl.java`.
137159

138160
### Running Self-Managed Couchbase Cluster
139161

967 KB
Loading
Loading
66.7 KB
Loading

configure-server.sh

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

docker-compose.yml

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

0 commit comments

Comments
 (0)