0

We have spring-boot-starter-parent 1.4.3.RELEASE as the base for our simple RESTful application. IBM DB2 10.5 is our runtime db

We are using HSQLDB embedded database for our DAO unit tests and that's working fine. We have Unit Test cases with Moquito mocks for the back end services, etc. All good.

We are now trying to create Integration Test cases to test the exposed REST methods end-to-end. Would like to use the Embedded HSQLDB and not DB2 for this test. The trouble is that the Integration Test cases insists on using our runtime db2 database and we don't know why.
Q1: Is this the typical behavior?!
Q2: How can we override this behavior to use HSQLDB instead?

package com.ibm.cio.cloud.cost.spreadsheet.controller;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;

import com.ibm.cio.cloud.cost.spreadsheet.BlueCostSpreadsheetUploadWebApplication;


@RunWith(SpringRunner.class)
@SpringBootTest(classes = BlueCostSpreadsheetUploadWebApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)   
public class ITBlueCostRestControllerTests  {

    @LocalServerPort
    private int port;

    TestRestTemplate restTemplate = new TestRestTemplate();

    HttpHeaders headers = new HttpHeaders();

    @Test
    public void testMethod() {

    }

    private String createURLWithPort(String uri) {
        return "http://localhost:" + port + uri;
    }

}

The exception I see when attempting to run this simple test case is this:

2018-08-06 13:13:50 ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException: 
Unable to obtain database connection
JamesD
  • 679
  • 10
  • 36
  • In this [link](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html) document, section 43.3.13 - it states that I should be able to add \@JdbcTest annotation which wires an in-memory embedded database, but my project configuration does not recognize that \@JdbcTest annotation?! – JamesD Aug 06 '18 at 21:43
  • OK - I think I solved that part by upgrading Spring-boot to 2.0.4 – JamesD Aug 06 '18 at 23:31

0 Answers0