Added ability to connect to existing db to make debugging easier. Specifically, I wanted to start a component test in a non-mocked environment, so that I could step through interaction with ribbon. To do this, I started an integration test, and then provisioned within the component test against the running integration test.
diff --git a/src/main/java/io/mifos/core/test/fixture/cassandra/CassandraInitializer.java b/src/main/java/io/mifos/core/test/fixture/cassandra/CassandraInitializer.java
index fd7b760..fdc954e 100644
--- a/src/main/java/io/mifos/core/test/fixture/cassandra/CassandraInitializer.java
+++ b/src/main/java/io/mifos/core/test/fixture/cassandra/CassandraInitializer.java
@@ -31,13 +31,18 @@
@SuppressWarnings({"WeakerAccess", "unused"})
public final class CassandraInitializer extends DataStoreTenantInitializer {
+ private final boolean useExistingDB;
+
public CassandraInitializer() {
- super();
+ this(false);
+ }
+ public CassandraInitializer(boolean useExistingDB) {
+ super();this.useExistingDB = useExistingDB;
}
@Override
public void initialize() throws Exception {
- CassandraInitializer.setup();
+ CassandraInitializer.setup(useExistingDB);
}
@Override
@@ -47,12 +52,18 @@
@Override
public void finish() {
- CassandraInitializer.tearDown();
+ if (!useExistingDB) CassandraInitializer.tearDown();
}
public static void setup() throws Exception {
- CassandraInitializer.startEmbeddedCassandra();
- CassandraInitializer.createKeyspaceSeshat();
+ setup(false);
+ }
+
+ public static void setup(final boolean useExistingDB) throws Exception {
+ if (!useExistingDB) {
+ CassandraInitializer.startEmbeddedCassandra();
+ CassandraInitializer.createKeyspaceSeshat();
+ }
}
public static void tearDown() {
diff --git a/src/main/java/io/mifos/core/test/fixture/mariadb/MariaDBInitializer.java b/src/main/java/io/mifos/core/test/fixture/mariadb/MariaDBInitializer.java
index 7d2781c..bfea20f 100644
--- a/src/main/java/io/mifos/core/test/fixture/mariadb/MariaDBInitializer.java
+++ b/src/main/java/io/mifos/core/test/fixture/mariadb/MariaDBInitializer.java
@@ -24,15 +24,22 @@
@SuppressWarnings({"WeakerAccess", "unused", "SqlNoDataSourceInspection", "SqlDialectInspection"})
public final class MariaDBInitializer extends DataStoreTenantInitializer {
+
+ private final boolean useExistingDB;
private static DB db;
public MariaDBInitializer() {
+ this(false);
+ }
+
+ public MariaDBInitializer(final boolean useExistingDB) {
super();
+ this.useExistingDB = useExistingDB;
}
@Override
public void initialize() throws Exception {
- MariaDBInitializer.setup();
+ MariaDBInitializer.setup(useExistingDB);
}
@Override
@@ -43,18 +50,23 @@
@Override
public void finish() {
- try {
- MariaDBInitializer.tearDown();
- }
- catch (final Exception e)
- {
- throw new RuntimeException(e);
+ if (!useExistingDB) {
+ try {
+ MariaDBInitializer.tearDown();
+ } catch (final Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
public static void setup() throws Exception {
- MariaDBInitializer.startEmbeddedMariaDB();
- MariaDBInitializer.createDatabaseSeshat();
+ setup(false);
+ }
+ public static void setup(final boolean useExistingDB) throws Exception {
+ if (!useExistingDB) {
+ MariaDBInitializer.startEmbeddedMariaDB();
+ MariaDBInitializer.createDatabaseSeshat();
+ }
}
public static void tearDown() throws Exception {