Template project to create a rest api. Make with Spring and Jersey.
Use eclipse to run server.
Use maven to build and run test.
- Build application
To build application on docker, run this command:
docker build -t PROJECT_NAME .
- Run docker compose
docker-compose up
In case of error don't forget to delete your container.
- Development mode
Eclipse doesn't use profiles on building application, so it's always in development mode.
If you use Tomcat in eclipse to run your application, run this command to have a docker database:
docker run -p 5432:5432 --rm -e POSTGRES_HOST_AUTH_METHOD=trust -v $(pwd)/src/main/resources/db/init.sql:/docker-entrypoint-initdb.d/init.sql -ti postgres:9.6
If you want to use application without docker in production from scratch, you need to have postgresql 9.6 and execute the init database file before running the application.
Init database file is src/main/resources/db/init.sql
.
Some unit tests need a real database to work, this database can be a docker container or another platform.
You need to initialize database before.
To run unit tests you must execute this commmands on your testing database:
mvn flyway:migrate -Dflyway.url=jdbc:postgresql://localhost:5432/db -Dflyway.user=#### -Dflyway.password=####
Behavior-driven development (or BDD) is an agile software development technique that encourages collaboration between developers, QA and non-technical or business participants in a software project.
behave uses tests written in a natural language style, backed up by Python code.
- behave documentation: http://behave.readthedocs.io/
- behave.example: https://github.com/behave/behave.example
Required minimum behave
version: 1.2.6
, so we can use tagged examples.
Required minimum python version is 3.7.
In order to run, got to src/test/behave
folder and please ensure you properly define the following variables, either via environment or via behave --define
:
URL
: defines the URL of the API. Defaulted to http://localhost:8080/PROJECT_NAME.
You can see documentation about steps using the following command:
behave --steps-catalog
- script
rebuild_dev_docker.sh
: destroy docker container, build application and start docker-compose.