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:
Tomas Slusny
2019-02-18 09:07:15 +00:00
parent 52a862c43b
commit f91412b33e
3 changed files with 8 additions and 0 deletions

View File

@@ -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.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
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)
@WebMvcTest(ConfigController.class)
@Slf4j
@ActiveProfiles("test")
public class ConfigControllerTest
{
@Autowired

View File

@@ -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.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
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)
@WebMvcTest(LootTrackerController.class)
@Slf4j
@ActiveProfiles("test")
public class LootTrackerControllerTest
{
@Autowired

View File

@@ -1,13 +1,17 @@
# Use in-memory database for tests
datasource:
runelite:
jndiName:
driverClassName: org.h2.Driver
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:runelite
runelite-cache:
jndiName:
driverClassName: org.h2.Driver
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:cache
runelite-tracker:
jndiName:
driverClassName: org.h2.Driver
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:xptracker