diff --git a/.travis.yml b/.travis.yml index b01f606e1..cbdae5bc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ jdk: - openjdk7 - oraclejdk8 env: - - SPRING_PROFILES_ACTIVE=nflow.h2 - - SPRING_PROFILES_ACTIVE=nflow.postgresql - - SPRING_PROFILES_ACTIVE=nflow.mysql + - SPRING_PROFILES_ACTIVE=nflow.db.h2 + - SPRING_PROFILES_ACTIVE=nflow.db.postgresql + - SPRING_PROFILES_ACTIVE=nflow.db.mysql addons: postgresql: "9.3" before_script: diff --git a/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/H2DatabaseConfiguration.java b/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/H2DatabaseConfiguration.java index ad297dbff..8fbd789d2 100644 --- a/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/H2DatabaseConfiguration.java +++ b/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/H2DatabaseConfiguration.java @@ -10,7 +10,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; -@Profile("!nflow.mysql,!nflow.postgresql") +@Profile("nflow.db.h2") @Configuration public class H2DatabaseConfiguration extends DatabaseConfiguration { public H2DatabaseConfiguration() { diff --git a/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/MysqlDatabaseConfiguration.java b/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/MysqlDatabaseConfiguration.java index faf5d581f..67c9e1e50 100644 --- a/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/MysqlDatabaseConfiguration.java +++ b/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/MysqlDatabaseConfiguration.java @@ -3,7 +3,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -@Profile("nflow.mysql") +@Profile("nflow.db.mysql") @Configuration public class MysqlDatabaseConfiguration extends DatabaseConfiguration { public MysqlDatabaseConfiguration() { diff --git a/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/PgDatabaseConfiguration.java b/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/PgDatabaseConfiguration.java index fc5ded38c..32db6dce8 100644 --- a/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/PgDatabaseConfiguration.java +++ b/nflow-engine/src/main/java/com/nitorcreations/nflow/engine/db/PgDatabaseConfiguration.java @@ -3,7 +3,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -@Profile("nflow.postgresql") +@Profile("nflow.db.postgresql") @Configuration public class PgDatabaseConfiguration extends DatabaseConfiguration { public PgDatabaseConfiguration() { diff --git a/nflow-engine/src/test/java/com/nitorcreations/nflow/engine/dao/BaseDaoTest.java b/nflow-engine/src/test/java/com/nitorcreations/nflow/engine/dao/BaseDaoTest.java index 5f7f3b6e1..9f46b2c62 100644 --- a/nflow-engine/src/test/java/com/nitorcreations/nflow/engine/dao/BaseDaoTest.java +++ b/nflow-engine/src/test/java/com/nitorcreations/nflow/engine/dao/BaseDaoTest.java @@ -16,6 +16,7 @@ import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -23,6 +24,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes={DaoTestConfiguration.class}) +@ActiveProfiles("nflow.db.h2") public abstract class BaseDaoTest extends BaseNflowTest { @Inject diff --git a/nflow-jetty/src/main/java/com/nitorcreations/nflow/jetty/spring/NflowStandardEnvironment.java b/nflow-jetty/src/main/java/com/nitorcreations/nflow/jetty/spring/NflowStandardEnvironment.java index 7dfc42d22..b6a57d741 100644 --- a/nflow-jetty/src/main/java/com/nitorcreations/nflow/jetty/spring/NflowStandardEnvironment.java +++ b/nflow-jetty/src/main/java/com/nitorcreations/nflow/jetty/spring/NflowStandardEnvironment.java @@ -1,5 +1,6 @@ package com.nitorcreations.nflow.jetty.spring; +import static java.util.Arrays.asList; import static org.slf4j.LoggerFactory.getLogger; import java.io.IOException; @@ -25,6 +26,22 @@ public NflowStandardEnvironment(Map overrideProperties) { addActiveProfile(profile); } } + setupDbProfile(); + } + + private void setupDbProfile() { + boolean dbProfileDefined = false; + for (String profile : asList(getActiveProfiles())) { + if (profile.startsWith("nflow.db")) { + if (dbProfileDefined) { + throw new RuntimeException("Multiple nflow.db-profiles defined"); + } + dbProfileDefined = true; + } + } + if (!dbProfileDefined) { + addActiveProfile("nflow.db.h2"); + } } private void addPropertyResource(String name) { diff --git a/nflow-jetty/src/test/java/com/nitorcreations/nflow/jetty/StartNflowTest.java b/nflow-jetty/src/test/java/com/nitorcreations/nflow/jetty/StartNflowTest.java index f5bccbfe7..5cf461117 100644 --- a/nflow-jetty/src/test/java/com/nitorcreations/nflow/jetty/StartNflowTest.java +++ b/nflow-jetty/src/test/java/com/nitorcreations/nflow/jetty/StartNflowTest.java @@ -37,13 +37,13 @@ private void startStop(String profiles) throws Exception { @Test @Ignore public void startNflowJettyMysql() throws Exception { - startStop("nflow.mysql"); + startStop("nflow.db.mysql"); } @Test @Ignore public void startNflowJettyPostgreSQL() throws Exception { - startStop("nflow.postgresql"); + startStop("nflow.db.postgresql"); } }