Skip to main content

Posts

Showing posts with the label File upload

File upload using Spring boot rest service with unit testing

We will create a REST service using spring boot which will have an endpoint to upload the file. Then we create JUnit test for upload service using mocking. Maven dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> REST Service for file upload Below service reads the content of uploaded file and print on the console. Client application will upload the file using given endpoint ...