Merge pull request #7904 from deathbeam/cleanup-spring-profiles
Properly use Spring profiles in http-service tests and main implementation
This commit is contained in:
@@ -44,7 +44,6 @@ import org.slf4j.ILoggerFactory;
|
|||||||
import org.slf4j.impl.StaticLoggerBinder;
|
import org.slf4j.impl.StaticLoggerBinder;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||||
@@ -58,9 +57,8 @@ import org.sql2o.Sql2o;
|
|||||||
import org.sql2o.converters.Converter;
|
import org.sql2o.converters.Converter;
|
||||||
import org.sql2o.quirks.NoQuirks;
|
import org.sql2o.quirks.NoQuirks;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SpringBootWebApplication extends SpringBootServletInitializer
|
public class SpringBootWebApplication extends SpringBootServletInitializer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,8 +5,33 @@ datasource:
|
|||||||
jndiName: java:comp/env/jdbc/runelite-cache2
|
jndiName: java:comp/env/jdbc/runelite-cache2
|
||||||
runelite-tracker:
|
runelite-tracker:
|
||||||
jndiName: java:comp/env/jdbc/runelite-tracker
|
jndiName: java:comp/env/jdbc/runelite-tracker
|
||||||
|
|
||||||
# By default Spring tries to register the datasource as an MXBean,
|
# By default Spring tries to register the datasource as an MXBean,
|
||||||
# so if multiple apis are delpoyed on one web container with
|
# so if multiple apis are deployed on one web container with
|
||||||
# shared datasource it tries to register it multiples times and
|
# shared datasource it tries to register it multiples times and
|
||||||
# fails when starting the 2nd api
|
# fails when starting the 2nd api
|
||||||
spring.jmx.enabled: false
|
spring.jmx.enabled: false
|
||||||
|
|
||||||
|
# Google OAuth client
|
||||||
|
oauth:
|
||||||
|
client-id:
|
||||||
|
client-secret:
|
||||||
|
|
||||||
|
# Minio client storage for cache
|
||||||
|
minio:
|
||||||
|
endpoint: http://localhost:9000
|
||||||
|
accesskey: AM54M27O4WZK65N6F8IP
|
||||||
|
secretkey: /PZCxzmsJzwCHYlogcymuprniGCaaLUOET2n6yMP
|
||||||
|
bucket: runelite
|
||||||
|
|
||||||
|
# Redis client for temporary data storage
|
||||||
|
redis:
|
||||||
|
pool.size: 10
|
||||||
|
host: http://localhost:6379
|
||||||
|
|
||||||
|
# Twitter client for feed
|
||||||
|
runelite:
|
||||||
|
twitter:
|
||||||
|
consumerkey:
|
||||||
|
secretkey:
|
||||||
|
listid: 968949795153948673
|
||||||
@@ -34,10 +34,9 @@ public class SpringBootWebApplicationTest
|
|||||||
@Ignore
|
@Ignore
|
||||||
public void run() throws InterruptedException
|
public void run() throws InterruptedException
|
||||||
{
|
{
|
||||||
String[] args = new String[]{
|
System.setProperty("spring.profiles.active", "dev");
|
||||||
"--spring.config.location=classpath:/application.yaml,classpath:/dev.yaml"
|
SpringApplication.run(SpringBootWebApplication.class);
|
||||||
};
|
|
||||||
SpringApplication.run(SpringBootWebApplication.class, args);
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
Thread.sleep(100L);
|
Thread.sleep(100L);
|
||||||
|
|||||||
@@ -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,19 +1,27 @@
|
|||||||
|
# Enable debug logging
|
||||||
|
debug: true
|
||||||
|
logging.level.net.runelite: DEBUG
|
||||||
|
|
||||||
|
# Development data sources
|
||||||
datasource:
|
datasource:
|
||||||
runelite:
|
runelite:
|
||||||
|
jndiName:
|
||||||
driverClassName: com.mysql.jdbc.Driver
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
|
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
|
||||||
url: jdbc:mysql://192.168.1.2/runelite
|
url: jdbc:mysql://localhost:3306/runelite
|
||||||
username: runelite
|
username: runelite
|
||||||
password: runelite
|
password: runelite
|
||||||
runelite-cache:
|
runelite-cache:
|
||||||
|
jndiName:
|
||||||
driverClassName: com.mysql.jdbc.Driver
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
|
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
|
||||||
url: jdbc:mysql://192.168.1.2/cache
|
url: jdbc:mysql://localhost:3306/runelite-cache
|
||||||
username: runelite
|
username: runelite
|
||||||
password: runelite
|
password: runelite
|
||||||
runelite-tracker:
|
runelite-tracker:
|
||||||
|
jndiName:
|
||||||
driverClassName: com.mysql.jdbc.Driver
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
|
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
|
||||||
url: jdbc:mysql://192.168.1.2/xptracker
|
url: jdbc:mysql://localhost:3306/runelite-tracker
|
||||||
username: runelite
|
username: runelite
|
||||||
password: runelite
|
password: runelite
|
||||||
@@ -1,35 +1,17 @@
|
|||||||
oauth:
|
# Use in-memory database for tests
|
||||||
client-id: moo
|
|
||||||
client-secret: cow
|
|
||||||
|
|
||||||
minio:
|
|
||||||
endpoint: http://10.96.22.171:9000
|
|
||||||
accesskey: AM54M27O4WZK65N6F8IP
|
|
||||||
secretkey: /PZCxzmsJzwCHYlogcymuprniGCaaLUOET2n6yMP
|
|
||||||
bucket: runelite
|
|
||||||
|
|
||||||
runelite:
|
|
||||||
twitter:
|
|
||||||
consumerkey: moo
|
|
||||||
secretkey: cow
|
|
||||||
listid: 968949795153948673
|
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
net:
|
|
||||||
runelite:
|
|
||||||
DEBUG
|
|
||||||
|
|
||||||
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