Migrate Spring unit tests to spring profiles
Instead of replacing configuration with test configuration on classpath, create test profile and use that. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
||||||
@@ -51,6 +52,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebMvcTest(ConfigController.class)
|
@WebMvcTest(ConfigController.class)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ActiveProfiles("test")
|
||||||
public class ConfigControllerTest
|
public class ConfigControllerTest
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
@@ -57,6 +58,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebMvcTest(LootTrackerController.class)
|
@WebMvcTest(LootTrackerController.class)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ActiveProfiles("test")
|
||||||
public class LootTrackerControllerTest
|
public class LootTrackerControllerTest
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
|
# Use in-memory database for tests
|
||||||
datasource:
|
datasource:
|
||||||
runelite:
|
runelite:
|
||||||
|
jndiName:
|
||||||
driverClassName: org.h2.Driver
|
driverClassName: org.h2.Driver
|
||||||
type: org.h2.jdbcx.JdbcDataSource
|
type: org.h2.jdbcx.JdbcDataSource
|
||||||
url: jdbc:h2:mem:runelite
|
url: jdbc:h2:mem:runelite
|
||||||
runelite-cache:
|
runelite-cache:
|
||||||
|
jndiName:
|
||||||
driverClassName: org.h2.Driver
|
driverClassName: org.h2.Driver
|
||||||
type: org.h2.jdbcx.JdbcDataSource
|
type: org.h2.jdbcx.JdbcDataSource
|
||||||
url: jdbc:h2:mem:cache
|
url: jdbc:h2:mem:cache
|
||||||
runelite-tracker:
|
runelite-tracker:
|
||||||
|
jndiName:
|
||||||
driverClassName: org.h2.Driver
|
driverClassName: org.h2.Driver
|
||||||
type: org.h2.jdbcx.JdbcDataSource
|
type: org.h2.jdbcx.JdbcDataSource
|
||||||
url: jdbc:h2:mem:xptracker
|
url: jdbc:h2:mem:xptracker
|
||||||
Reference in New Issue
Block a user