Details
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/BeatrixTestSuite.java b/beatrix/src/test/java/com/ning/billing/beatrix/BeatrixTestSuite.java
new file mode 100644
index 0000000..a94d343
--- /dev/null
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/BeatrixTestSuite.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.beatrix;
+
+import com.ning.billing.KillbillTestSuite;
+
+public abstract class BeatrixTestSuite extends KillbillTestSuite {
+}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/BeatrixTestSuiteWithEmbeddedDB.java b/beatrix/src/test/java/com/ning/billing/beatrix/BeatrixTestSuiteWithEmbeddedDB.java
new file mode 100644
index 0000000..b6a8d20
--- /dev/null
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/BeatrixTestSuiteWithEmbeddedDB.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.beatrix;
+
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
+
+public abstract class BeatrixTestSuiteWithEmbeddedDB extends KillbillTestSuiteWithEmbeddedDB {
+}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixModule.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixModule.java
index c26fac5..96fcca7 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixModule.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixModule.java
@@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
import com.ning.billing.account.api.AccountService;
import com.ning.billing.account.glue.AccountModule;
import com.ning.billing.analytics.setup.AnalyticsModule;
@@ -65,7 +66,6 @@ import static org.testng.Assert.assertNotNull;
public class BeatrixModule extends AbstractModule {
-
public static final String PLUGIN_NAME = "yoyo";
@Override
@@ -77,7 +77,7 @@ public class BeatrixModule extends AbstractModule {
bind(ClockMock.class).asEagerSingleton();
bind(Lifecycle.class).to(SubsetDefaultLifecycle.class).asEagerSingleton();
- final MysqlTestingHelper helper = new MysqlTestingHelper();
+ final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
bind(MysqlTestingHelper.class).toInstance(helper);
final IDBI dbi;
if (helper.isUsingLocalInstance()) {
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
index 7ea68a6..f20ac76 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
@@ -43,6 +43,7 @@ import com.ning.billing.analytics.AnalyticsListener;
import com.ning.billing.analytics.api.user.DefaultAnalyticsUserApi;
import com.ning.billing.api.TestApiListener;
import com.ning.billing.api.TestListenerStatus;
+import com.ning.billing.beatrix.BeatrixTestSuiteWithEmbeddedDB;
import com.ning.billing.beatrix.lifecycle.Lifecycle;
import com.ning.billing.catalog.api.Currency;
import com.ning.billing.dbi.MysqlTestingHelper;
@@ -77,7 +78,7 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-public class TestIntegrationBase implements TestListenerStatus {
+public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB implements TestListenerStatus {
protected static final DateTimeZone testTimeZone = DateTimeZone.UTC;
protected static final int NUMBER_OF_DECIMALS = InvoicingConfiguration.getNumberOfDecimals();
@@ -173,47 +174,17 @@ public class TestIntegrationBase implements TestListenerStatus {
}
}
- protected void setupMySQL() throws IOException {
- final String accountDdl = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/account/ddl.sql"));
- final String analyticsDdl = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/analytics/ddl.sql"));
- final String entitlementDdl = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/entitlement/ddl.sql"));
- final String invoiceDdl = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/invoice/ddl.sql"));
- final String paymentDdl = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/payment/ddl.sql"));
- final String utilDdl = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
- final String junctionDb = IOUtils.toString(TestIntegration.class.getResourceAsStream("/com/ning/billing/junction/ddl.sql"));
-
- helper.startMysql();
-
- helper.initDb(accountDdl);
- helper.initDb(analyticsDdl);
- helper.initDb(entitlementDdl);
- helper.initDb(invoiceDdl);
- helper.initDb(paymentDdl);
- helper.initDb(utilDdl);
- helper.initDb(junctionDb);
- }
-
@BeforeClass(groups = "slow")
public void setup() throws Exception {
- setupMySQL();
-
context = new DefaultCallContextFactory(clock).createCallContext("Integration Test", CallOrigin.TEST, UserType.TEST);
busHandler = new TestApiListener(this);
}
- @AfterClass(groups = "slow")
- public void tearDown() throws Exception {
- helper.stopMysql();
- }
-
@BeforeMethod(groups = "slow")
public void setupTest() throws Exception {
log.warn("\n");
log.warn("RESET TEST FRAMEWORK\n\n");
- // Pre test cleanup
- helper.cleanupAllTables();
-
clock.resetDeltaFromReality();
resetTestListenerStatus();
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/lifecycle/TestLifecycle.java b/beatrix/src/test/java/com/ning/billing/beatrix/lifecycle/TestLifecycle.java
index ac41b0e..649297c 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/lifecycle/TestLifecycle.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/lifecycle/TestLifecycle.java
@@ -27,13 +27,12 @@ import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Stage;
+import com.ning.billing.beatrix.BeatrixTestSuite;
import com.ning.billing.lifecycle.KillbillService;
import com.ning.billing.lifecycle.LifecycleHandlerType;
import com.ning.billing.lifecycle.LifecycleHandlerType.LifecycleLevel;
-
-public class TestLifecycle {
-
+public class TestLifecycle extends BeatrixTestSuite {
private static final Logger log = LoggerFactory.getLogger(TestLifecycle.class);
private Service1 s1;
@@ -42,7 +41,6 @@ public class TestLifecycle {
private DefaultLifecycle lifecycle;
public static class ServiceBase {
-
private int count = 0;
public ServiceBase() {
@@ -63,7 +61,6 @@ public class TestLifecycle {
}
public static class Service1 extends ServiceBase implements KillbillService {
-
@LifecycleHandlerType(LifecycleLevel.INIT_BUS)
public void initBus() {
log.info("Service1 : got INIT_BUS");
@@ -89,7 +86,6 @@ public class TestLifecycle {
}
public static class Service2 extends ServiceBase implements KillbillService {
-
@LifecycleHandlerType(LifecycleLevel.LOAD_CATALOG)
public void loadCatalog() {
log.info("Service2 : got LOAD_CATALOG");
@@ -120,8 +116,7 @@ public class TestLifecycle {
}
}
-
- @BeforeClass(alwaysRun = true)
+ @BeforeClass(groups = "fast")
public void setup() {
final Injector g = Guice.createInjector(Stage.DEVELOPMENT, new TestLifecycleModule());
s1 = g.getInstance(Service1.class);
@@ -129,7 +124,7 @@ public class TestLifecycle {
lifecycle = g.getInstance(DefaultLifecycle.class);
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testLifecycle() {
s1.reset();
s2.reset();
@@ -153,7 +148,6 @@ public class TestLifecycle {
}
public static class LifecycleNoWarn extends DefaultLifecycle {
-
@Inject
public LifecycleNoWarn(final Injector injector) {
super(injector);
@@ -165,14 +159,12 @@ public class TestLifecycle {
}
public static class TestLifecycleModule extends AbstractModule {
-
@Override
protected void configure() {
bind(DefaultLifecycle.class).to(LifecycleNoWarn.class).asEagerSingleton();
bind(Service1.class).asEagerSingleton();
bind(Service2.class).asEagerSingleton();
}
-
}
}