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:
Adam
2019-03-04 14:01:34 -05:00
committed by GitHub
7 changed files with 50 additions and 34 deletions

View File

@@ -44,7 +44,6 @@ import org.slf4j.ILoggerFactory;
import org.slf4j.impl.StaticLoggerBinder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
@@ -58,9 +57,8 @@ import org.sql2o.Sql2o;
import org.sql2o.converters.Converter;
import org.sql2o.quirks.NoQuirks;
@SpringBootApplication
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableScheduling
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
@Slf4j
public class SpringBootWebApplication extends SpringBootServletInitializer
{

View File

@@ -5,8 +5,33 @@ datasource:
jndiName: java:comp/env/jdbc/runelite-cache2
runelite-tracker:
jndiName: java:comp/env/jdbc/runelite-tracker
# 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
# 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

View File

@@ -34,10 +34,9 @@ public class SpringBootWebApplicationTest
@Ignore
public void run() throws InterruptedException
{
String[] args = new String[]{
"--spring.config.location=classpath:/application.yaml,classpath:/dev.yaml"
};
SpringApplication.run(SpringBootWebApplication.class, args);
System.setProperty("spring.profiles.active", "dev");
SpringApplication.run(SpringBootWebApplication.class);
for (;;)
{
Thread.sleep(100L);

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,19 +1,27 @@
# Enable debug logging
debug: true
logging.level.net.runelite: DEBUG
# Development data sources
datasource:
runelite:
jndiName:
driverClassName: com.mysql.jdbc.Driver
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.1.2/runelite
url: jdbc:mysql://localhost:3306/runelite
username: runelite
password: runelite
runelite-cache:
jndiName:
driverClassName: com.mysql.jdbc.Driver
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.1.2/cache
url: jdbc:mysql://localhost:3306/runelite-cache
username: runelite
password: runelite
runelite-tracker:
jndiName:
driverClassName: com.mysql.jdbc.Driver
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.1.2/xptracker
url: jdbc:mysql://localhost:3306/runelite-tracker
username: runelite
password: runelite

View File

@@ -1,35 +1,17 @@
oauth:
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
# 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