Skip to main content

Posts

Showing posts from February, 2014

Again writing fast & maintainable integration tests using in-memory db, liquibase, gradle and spring mvc test

This blog is improvisation to previously blogged testing effectively with database blog . In this blog we will remove the jetty setup and instead use Spring MVC Test framework which kind of simulate the request/response for your controllers via Spring Web Application context (no deployment, to http client tests) Here, we will write Spring MVC tests and - Create the HSQLDB in-memory instance (instantiating datasource instance) and run Liquibase scripts against them. (using Spring Lqiuibase bean) 1. Setup your web-service. Write usual Controller->Service->Repository layer. @Controller @RequestMapping("/reports") public class MapAnomalyReportEndpoint { @Autowired private MapAnomalyReportService reportService; @ResponseBody @RequestMapping(method = RequestMethod.GET) public Collection getReports() { return reportService.getReports(); } } 2. Create Spring Java Config (No XML) Configure the controllers. @Configuration @Enabl