package {{context.group}}.{{context.project}}.dal.database.datasource; import org.junit.Test; import java.util.List; import org.junit.Assert; import javax.sql.DataSource; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.beans.factory.annotation.Autowired; @SpringBootTest @RunWith(SpringRunner.class) public class DataSourceTest { @Autowired DataSource dataSource; @Value("${spring.profiles.active}") List activeProfiles; @Test public void load() throws Exception { if (activeProfiles.contains("test-datasource")) { Assert.assertNotNull(dataSource); Assert.assertNotNull(dataSource.getConnection()); System.out.println("pass datasource connection test."); } } }