Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ankitrajput0096/swagger_and_junit_springboot_dockerized

Dockerized Spring Boot application with Swagger 2 implementation and Unit testCases
https://github.com/ankitrajput0096/swagger_and_junit_springboot_dockerized

docker docker-compose java junit mokito postgresql spring-boot swagger-ui swagger2

Last synced: about 1 month ago
JSON representation

Dockerized Spring Boot application with Swagger 2 implementation and Unit testCases

Awesome Lists containing this project

README

        

# Swagger 2 (Using Springfox) And JUnit Test-cases (Mockito) Spring boot application

Dockerized Spring Boot application with Swagger 2 implementation and JUnit test-cases using Mockito.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development purposes. See running for notes on how to run the project on a system.

### Prerequisites

1. Clone the project to your local environment:
```
git clone https://github.com/ankitrajput0096/Swagger_And_JUnit_SpringBoot_Dockerized
```

2. You need maven installed on your environment:

#### Mac (homebrew):

```
brew install maven
```
#### Ubuntu:
```
sudo apt-get install maven
```

3. You need Docker to be installed:

#### Windows:
https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe

#### Mac:
https://download.docker.com/mac/stable/Docker.dmg

#### Ubuntu:
https://docs.docker.com/install/linux/docker-ce/ubuntu/

### Installing

Once you have maven and docker installed on your environment, install the project dependencies via:

```
mvn install
```

Build docker Image:

```
docker-compose build
```

Start docker:

```
docker-compose up
```
# Testing of Unit Test Cases using Mockito
1. Open terminal or command prompt with directory location as `spring_boot_jpa` folder.
2. Write this command in terminal or command prompt : `mvn test`
3. All test-cases will be run automatically of this spring boot application.
4. Enjoy !!

## Running

Start docker:
```
docker-compose up
```

Run the application from the `Application.java` main method directly,
or from a command line:
```
mvn spring-boot:run
```

Keep docker running in a separate terminal tab, create another tab to run the application.

Your server should be now running on http://localhost:8090

# Get an access to all exposed API's using SWAGGER 2

1. Open any web browser.
2. Write this URL in the web browser : http://localhost:8090/swagger-ui.html
3. Enjoy !!

## Get an access to all exposed API's with Postman

1. Install Postman (https://www.getpostman.com)
2. Import Postman collection from the `Swagger_SpringBoot_Dockerized.postman_collection.json` file
3. Enjoy !!

## Built With

* [Spring Boot](https://spring.io/projects/spring-boot) - Spring Boot 2
* [Maven](https://maven.apache.org/) - Dependency Management
* [Docker](https://www.docker.com/) - For containerization of application
* [PostgreSQL](https://www.postgresql.org/) - Database
* [Mockito](https://site.mockito.org/) - Mockito Testing Framework

## Contributing

If you have any improvement suggestions please create a pull request and I'll review it.

## Authors

* **Ankit Rajput** - *Initial work* - [Github](https://github.com/ankitrajput0096)

## License

This project is licensed under the MIT License

## Acknowledgments

* Big thanks to Pivotal for Spring Boot framework, love it!