Testing the Spring Boot framework. The idea is to create a REST microservice, package it to docker and serve it from a Kubernetes cluser in the cloud.
- The Spring Boot reference guide
- Common application properties
- https://cloud.google.com/kubernetes-engine/docs/tutorials/
- https://blog.philipphauer.de/dont-use-in-memory-databases-tests-h2/
- Java 8
- Postgres server
- Docker
- Maven 3.5.2
- Spring Boot
- Flyway
- Postgres
- Docker
- Create TWO postgres databases, one for running the application, and one for automated tests. You can use the SQL below.
- Create a user in Postgres with full rights on the databases (see below).
- In
src/main/java/resources
:- Copy
application-local.properties-example
to `application-local.properties' - Enter the correct database credentials in the local config.
- Copy
- Repeat for
src/test/java/resources
. - Run
mvn clean install
. The project should compile, and all tests should pass.
- <...>
- From the project root directory:
mvn clean package
. This creates an self contained web server. - Create a local config in a secure directory, outside of the webroot.
- Example:
~/.desertsnake/application.config
chmod -R 700 ~/.desertsnake
- Example:
- Run the application:
java -jar -Dspring.config.location=~/.desertsnake/application.config
.
-- Create database
CREATE DATABASE desertsnake;
-- Create user
CREATE ROLE developer WITH LOGIN PASSWORD '<password>';
GRANT ALL PRIVILEGES ON DATABASE desertsnake TO developer;
mvn -Dflyway.url=jdbc:postgresql://localhost:5433/desertsnake_develop -Dflyway.user=developer -Dflyway.password=testpassword