killbill-aplcache

util: revisit test setup * Add missing fast group so tests

7/7/2012 4:48:30 PM

Changes

Details

diff --git a/util/src/test/java/com/ning/billing/util/bus/TestEventBus.java b/util/src/test/java/com/ning/billing/util/bus/TestEventBus.java
index a91842d..0c92e6d 100644
--- a/util/src/test/java/com/ning/billing/util/bus/TestEventBus.java
+++ b/util/src/test/java/com/ning/billing/util/bus/TestEventBus.java
@@ -19,10 +19,7 @@ package com.ning.billing.util.bus;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-@Test(groups = {"slow"})
 public class TestEventBus extends TestEventBusBase {
-
-
     @BeforeClass(groups = "slow")
     public void setup() throws Exception {
         eventBus = new InMemoryBus();
diff --git a/util/src/test/java/com/ning/billing/util/bus/TestEventBusBase.java b/util/src/test/java/com/ning/billing/util/bus/TestEventBusBase.java
index 52f06c6..2364c2c 100644
--- a/util/src/test/java/com/ning/billing/util/bus/TestEventBusBase.java
+++ b/util/src/test/java/com/ning/billing/util/bus/TestEventBusBase.java
@@ -13,6 +13,7 @@
  * License for the specific language governing permissions and limitations
  * under the License.
  */
+
 package com.ning.billing.util.bus;
 
 import java.util.UUID;
@@ -28,10 +29,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.eventbus.Subscribe;
 import com.google.inject.Inject;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.bus.BusEvent.BusEventType;
 
-public class TestEventBusBase {
-
+public abstract class TestEventBusBase extends UtilTestSuiteWithEmbeddedDB {
     protected static final Logger log = LoggerFactory.getLogger(TestEventBusBase.class);
 
     @Inject
@@ -47,9 +48,7 @@ public class TestEventBusBase {
         eventBus.stop();
     }
 
-
     public static class MyEvent implements BusEvent {
-
         private final String name;
         private final Long value;
         private final UUID userToken;
@@ -102,7 +101,6 @@ public class TestEventBusBase {
         }
     }
 
-
     public static final class MyOtherEvent implements BusEvent {
 
         private final String name;
@@ -110,7 +108,6 @@ public class TestEventBusBase {
         private final UUID userToken;
         private final String type;
 
-
         @JsonCreator
         public MyOtherEvent(@JsonProperty("name") final String name,
                             @JsonProperty("value") final Double value,
@@ -159,7 +156,6 @@ public class TestEventBusBase {
 
         private volatile int gotEvents;
 
-
         public MyEventHandler(final int exp) {
             this.expectedEvents = exp;
             this.gotEvents = 0;
@@ -206,15 +202,12 @@ public class TestEventBusBase {
             eventBus.post(new MyEventWithException("my-event", 1L, UUID.randomUUID(), BusEventType.ACCOUNT_CHANGE.toString()));
 
             Thread.sleep(50000);
-        } catch (Exception e) {
-
+        } catch (Exception ignored) {
         }
-
     }
 
     public void testSimple() {
         try {
-
             final int nbEvents = 5;
             final MyEventHandler handler = new MyEventHandler(nbEvents);
             eventBus.register(handler);
@@ -232,7 +225,6 @@ public class TestEventBusBase {
 
     public void testDifferentType() {
         try {
-
             final MyEventHandler handler = new MyEventHandler(1);
             eventBus.register(handler);
 
@@ -246,6 +238,5 @@ public class TestEventBusBase {
         } catch (Exception e) {
             Assert.fail("", e);
         }
-
     }
 }
diff --git a/util/src/test/java/com/ning/billing/util/bus/TestPersistentEventBus.java b/util/src/test/java/com/ning/billing/util/bus/TestPersistentEventBus.java
index 1b58ce1..2fb937b 100644
--- a/util/src/test/java/com/ning/billing/util/bus/TestPersistentEventBus.java
+++ b/util/src/test/java/com/ning/billing/util/bus/TestPersistentEventBus.java
@@ -13,17 +13,17 @@
  * License for the specific language governing permissions and limitations
  * under the License.
  */
+
 package com.ning.billing.util.bus;
 
 import org.skife.config.ConfigurationObjectFactory;
 import org.skife.jdbi.v2.IDBI;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.DBIProvider;
 import com.ning.billing.dbi.DbiConfig;
 import com.ning.billing.dbi.MysqlTestingHelper;
@@ -31,28 +31,12 @@ import com.ning.billing.util.clock.Clock;
 import com.ning.billing.util.clock.ClockMock;
 import com.ning.billing.util.glue.BusModule;
 import com.ning.billing.util.glue.BusModule.BusType;
-import com.ning.billing.util.io.IOUtils;
 
 @Guice(modules = TestPersistentEventBus.PersistentBusModuleTest.class)
 public class TestPersistentEventBus extends TestEventBusBase {
     @Inject
     private MysqlTestingHelper helper;
 
-    @BeforeClass(groups = {"slow"})
-    public void setup() throws Exception {
-        helper.startMysql();
-        final String ddl = IOUtils.toString(TestPersistentEventBus.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-        helper.initDb(ddl);
-        cleanup();
-        super.setup();
-    }
-
-    @BeforeMethod(groups = {"slow"})
-    public void cleanup() {
-        helper.cleanupTable("bus_events");
-        helper.cleanupTable("claimed_bus_events");
-    }
-
     public static class PersistentBusModuleTest extends AbstractModule {
         @Override
         protected void configure() {
@@ -61,7 +45,7 @@ public class TestPersistentEventBus extends TestEventBusBase {
             bind(Clock.class).to(ClockMock.class).asEagerSingleton();
             bind(ClockMock.class).asEagerSingleton();
 
-            final MysqlTestingHelper helper = new MysqlTestingHelper();
+            final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
             bind(MysqlTestingHelper.class).toInstance(helper);
             if (helper.isUsingLocalInstance()) {
                 bind(IDBI.class).toProvider(DBIProvider.class).asEagerSingleton();
@@ -75,16 +59,14 @@ public class TestPersistentEventBus extends TestEventBusBase {
         }
     }
 
-    @Test(groups = {"slow"})
+    @Test(groups = "slow")
     public void testSimple() {
         super.testSimple();
     }
 
     // Until Guava fixes exception handling, r13?
-    @Test(groups = {"slow"}, enabled = false)
+    @Test(groups = "slow", enabled = false)
     public void testSimpleWithException() {
         super.testSimpleWithException();
-
     }
-
 }
diff --git a/util/src/test/java/com/ning/billing/util/callcontext/TestCallContext.java b/util/src/test/java/com/ning/billing/util/callcontext/TestCallContext.java
index 3ed0f8d..2ecc629 100644
--- a/util/src/test/java/com/ning/billing/util/callcontext/TestCallContext.java
+++ b/util/src/test/java/com/ning/billing/util/callcontext/TestCallContext.java
@@ -23,7 +23,6 @@ import org.joda.time.DateTime;
 import com.ning.billing.util.clock.DefaultClock;
 
 public class TestCallContext implements CallContext {
-
     private final String userName;
     private final DateTime updatedDate;
     private final DateTime createdDate;
diff --git a/util/src/test/java/com/ning/billing/util/clock/ClockMock.java b/util/src/test/java/com/ning/billing/util/clock/ClockMock.java
index d8542e0..681b0b2 100644
--- a/util/src/test/java/com/ning/billing/util/clock/ClockMock.java
+++ b/util/src/test/java/com/ning/billing/util/clock/ClockMock.java
@@ -32,11 +32,9 @@ import com.ning.billing.catalog.api.Duration;
 import com.ning.billing.catalog.api.TimeUnit;
 
 public class ClockMock implements Clock {
-
     private MutablePeriod delta = new MutablePeriod();
     private static final Logger log = LoggerFactory.getLogger(ClockMock.class);
 
-
     @Override
     public synchronized DateTime getNow(final DateTimeZone tz) {
         return getUTCNow().toDateTime(tz);
@@ -146,6 +144,4 @@ public class ClockMock implements Clock {
                 return new Period();
         }
     }
-
-
 }
diff --git a/util/src/test/java/com/ning/billing/util/clock/OldClockMock.java b/util/src/test/java/com/ning/billing/util/clock/OldClockMock.java
index b032bed..4197b24 100644
--- a/util/src/test/java/com/ning/billing/util/clock/OldClockMock.java
+++ b/util/src/test/java/com/ning/billing/util/clock/OldClockMock.java
@@ -158,6 +158,4 @@ public class OldClockMock extends DefaultClock {
     public String toString() {
         return getUTCNow().toString();
     }
-
-
 }
diff --git a/util/src/test/java/com/ning/billing/util/config/TestXMLLoader.java b/util/src/test/java/com/ning/billing/util/config/TestXMLLoader.java
index 96f7a06..0c3a5dd 100644
--- a/util/src/test/java/com/ning/billing/util/config/TestXMLLoader.java
+++ b/util/src/test/java/com/ning/billing/util/config/TestXMLLoader.java
@@ -28,11 +28,12 @@ import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 import com.ning.billing.catalog.api.InvalidConfigException;
+import com.ning.billing.util.UtilTestSuite;
 
 import static org.testng.Assert.assertEquals;
 
 
-public class TestXMLLoader {
+public class TestXMLLoader extends UtilTestSuite {
     public static final String TEST_XML =
             "<xmlTestClass>" +
                     "	<foo>foo</foo>" +
@@ -40,7 +41,7 @@ public class TestXMLLoader {
                     "	<lala>42</lala>" +
                     "</xmlTestClass>";
 
-    @Test
+    @Test(groups = "fast")
     public void test() throws SAXException, InvalidConfigException, JAXBException, IOException, TransformerException, URISyntaxException, ValidationException {
         final InputStream is = new ByteArrayInputStream(TEST_XML.getBytes());
         final XmlTestClass test = XMLLoader.getObjectFromStream(new URI("internal:/"), is, XmlTestClass.class);
@@ -48,6 +49,4 @@ public class TestXMLLoader {
         assertEquals(test.getBar(), 1.0);
         assertEquals(test.getLala(), 42);
     }
-
-
 }
diff --git a/util/src/test/java/com/ning/billing/util/config/TestXMLSchemaGenerator.java b/util/src/test/java/com/ning/billing/util/config/TestXMLSchemaGenerator.java
index 8eae647..fde04b0 100644
--- a/util/src/test/java/com/ning/billing/util/config/TestXMLSchemaGenerator.java
+++ b/util/src/test/java/com/ning/billing/util/config/TestXMLSchemaGenerator.java
@@ -23,9 +23,10 @@ import java.io.InputStream;
 
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.io.IOUtils;
 
-public class TestXMLSchemaGenerator {
+public class TestXMLSchemaGenerator extends UtilTestSuite {
     @Test(groups = "fast", enabled = false)
     public void test() throws IOException, TransformerException, JAXBException {
         final InputStream stream = XMLSchemaGenerator.xmlSchema(XmlTestClass.class);
diff --git a/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java b/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java
index 11878b9..53c854a 100644
--- a/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java
+++ b/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java
@@ -22,9 +22,11 @@ import java.net.URI;
 
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
+
 import static org.testng.Assert.assertEquals;
 
-public class TestXMLWriter {
+public class TestXMLWriter extends UtilTestSuite {
     public static final String TEST_XML =
             "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                     "<xmlTestClass>" +
@@ -33,7 +35,7 @@ public class TestXMLWriter {
                     "<lala>42</lala>" +
                     "</xmlTestClass>";
 
-    @Test
+    @Test(groups = "fast")
     public void test() throws Exception {
         final InputStream is = new ByteArrayInputStream(TEST_XML.getBytes());
         final XmlTestClass test = XMLLoader.getObjectFromStream(new URI("internal:/"), is, XmlTestClass.class);
@@ -42,11 +44,7 @@ public class TestXMLWriter {
         assertEquals(test.getLala(), 42);
 
         final String output = XMLWriter.writeXML(test, XmlTestClass.class);
-
-        System.out.println(output);
+        //System.out.println(output);
         assertEquals(output.replaceAll("\\s", ""), TEST_XML.replaceAll("\\s", ""));
-
     }
-
-
 }
diff --git a/util/src/test/java/com/ning/billing/util/customfield/TestFieldStore.java b/util/src/test/java/com/ning/billing/util/customfield/TestFieldStore.java
index e5caad4..6182629 100644
--- a/util/src/test/java/com/ning/billing/util/customfield/TestFieldStore.java
+++ b/util/src/test/java/com/ning/billing/util/customfield/TestFieldStore.java
@@ -22,11 +22,12 @@ import java.util.UUID;
 import org.skife.jdbi.v2.IDBI;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.callcontext.CallContext;
 import com.ning.billing.util.callcontext.CallOrigin;
 import com.ning.billing.util.callcontext.DefaultCallContextFactory;
@@ -36,28 +37,20 @@ import com.ning.billing.util.customfield.dao.AuditedCustomFieldDao;
 import com.ning.billing.util.customfield.dao.CustomFieldDao;
 import com.ning.billing.util.customfield.dao.CustomFieldSqlDao;
 import com.ning.billing.util.dao.ObjectType;
-import com.ning.billing.util.io.IOUtils;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.fail;
 
-@Test(groups = {"util", "slow"})
-public class TestFieldStore {
-    Logger log = LoggerFactory.getLogger(TestFieldStore.class);
-    private final MysqlTestingHelper helper = new MysqlTestingHelper();
+public class TestFieldStore extends UtilTestSuiteWithEmbeddedDB {
+    private final Logger log = LoggerFactory.getLogger(TestFieldStore.class);
+    private final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
     private CallContext context;
     private IDBI dbi;
     private CustomFieldDao customFieldDao;
 
-    @BeforeClass(groups = {"util", "slow"})
+    @BeforeClass(groups = "slow")
     protected void setup() throws IOException {
-        // Health check test to make sure MySQL is setup properly
         try {
-            final String utilDdl = IOUtils.toString(TestFieldStore.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-
-            helper.startMysql();
-            helper.initDb(utilDdl);
-
             dbi = helper.getDBI();
             customFieldDao = new AuditedCustomFieldDao(dbi);
             context = new DefaultCallContextFactory(new ClockMock()).createCallContext("Fezzik", CallOrigin.TEST, UserType.TEST);
@@ -67,14 +60,7 @@ public class TestFieldStore {
         }
     }
 
-    @AfterClass(groups = {"util", "slow"})
-    public void stopMysql() {
-        if (helper != null) {
-            helper.stopMysql();
-        }
-    }
-
-    @Test
+    @Test(groups = "slow")
     public void testFieldStore() {
         final UUID id = UUID.randomUUID();
         final ObjectType objectType = ObjectType.ACCOUNT;
diff --git a/util/src/test/java/com/ning/billing/util/email/DefaultCatalogTranslationTest.java b/util/src/test/java/com/ning/billing/util/email/DefaultCatalogTranslationTest.java
index 529616e..4fe5198 100644
--- a/util/src/test/java/com/ning/billing/util/email/DefaultCatalogTranslationTest.java
+++ b/util/src/test/java/com/ning/billing/util/email/DefaultCatalogTranslationTest.java
@@ -23,16 +23,17 @@ import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.template.translation.DefaultCatalogTranslator;
 import com.ning.billing.util.template.translation.Translator;
 import com.ning.billing.util.template.translation.TranslatorConfig;
 
 import static org.testng.Assert.assertEquals;
 
-public class DefaultCatalogTranslationTest {
+public class DefaultCatalogTranslationTest extends UtilTestSuite {
     private Translator translation;
 
-    @BeforeClass(groups = {"fast", "email"})
+    @BeforeClass(groups = "fast")
     public void setup() {
         final ConfigSource configSource = new ConfigSource() {
             private final Map<String, String> properties = ImmutableMap.<String, String>of("killbill.template.invoiceFormatterFactoryClass",
diff --git a/util/src/test/java/com/ning/billing/util/email/EmailSenderTest.java b/util/src/test/java/com/ning/billing/util/email/EmailSenderTest.java
index b3e4d64..81b40d9 100644
--- a/util/src/test/java/com/ning/billing/util/email/EmailSenderTest.java
+++ b/util/src/test/java/com/ning/billing/util/email/EmailSenderTest.java
@@ -21,8 +21,10 @@ import org.skife.config.ConfigurationObjectFactory;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-@Test(groups = {"slow", "email"})
-public class EmailSenderTest {
+import com.ning.billing.util.UtilTestSuite;
+
+@Test(groups = "slow")
+public class EmailSenderTest extends UtilTestSuite {
     private EmailConfig config;
 
     @BeforeClass
diff --git a/util/src/test/java/com/ning/billing/util/globallocker/MockGlobalLocker.java b/util/src/test/java/com/ning/billing/util/globallocker/MockGlobalLocker.java
index 1e46918..4466b1a 100644
--- a/util/src/test/java/com/ning/billing/util/globallocker/MockGlobalLocker.java
+++ b/util/src/test/java/com/ning/billing/util/globallocker/MockGlobalLocker.java
@@ -17,7 +17,6 @@
 package com.ning.billing.util.globallocker;
 
 public class MockGlobalLocker implements GlobalLocker {
-
     @Override
     public GlobalLock lockWithNumberOfTries(final LockerType service,
                                             final String lockKey, final int retry) {
diff --git a/util/src/test/java/com/ning/billing/util/globallocker/TestMysqlGlobalLocker.java b/util/src/test/java/com/ning/billing/util/globallocker/TestMysqlGlobalLocker.java
index f2fd01a..ed05f5f 100644
--- a/util/src/test/java/com/ning/billing/util/globallocker/TestMysqlGlobalLocker.java
+++ b/util/src/test/java/com/ning/billing/util/globallocker/TestMysqlGlobalLocker.java
@@ -24,45 +24,35 @@ import org.skife.jdbi.v2.IDBI;
 import org.skife.jdbi.v2.TransactionCallback;
 import org.skife.jdbi.v2.TransactionStatus;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.globallocker.GlobalLocker.LockerType;
 import com.ning.billing.util.io.IOUtils;
 
-@Test(groups = "slow")
 @Guice(modules = TestMysqlGlobalLocker.TestMysqlGlobalLockerModule.class)
-public class TestMysqlGlobalLocker {
-
+public class TestMysqlGlobalLocker extends UtilTestSuiteWithEmbeddedDB {
     @Inject
     private IDBI dbi;
 
     @Inject
     private MysqlTestingHelper helper;
 
-    @BeforeClass(groups = "slow")
+    @BeforeMethod(groups = "slow")
     public void setup() throws IOException {
         final String testDdl = IOUtils.toString(TestMysqlGlobalLocker.class.getResourceAsStream("/com/ning/billing/util/ddl_test.sql"));
-        helper.startMysql();
         helper.initDb(testDdl);
     }
 
-    @AfterClass(groups = "slow")
-    public void tearDown() {
-        if (helper != null) {
-            helper.stopMysql();
-        }
-    }
-
     // Used as a manual test to validate the simple DAO by stepping through that locking is done and release correctly
-    @Test(groups = "slow", enabled = true)
+    @Test(groups = "slow")
     public void testSimpleLocking() {
-
         final String lockName = UUID.randomUUID().toString();
 
         final GlobalLocker locker = new MySqlGlobalLocker(dbi);
@@ -92,10 +82,9 @@ public class TestMysqlGlobalLocker {
     }
 
     public static final class TestMysqlGlobalLockerModule extends AbstractModule {
-
         @Override
         protected void configure() {
-            final MysqlTestingHelper helper = new MysqlTestingHelper();
+            final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
             bind(MysqlTestingHelper.class).toInstance(helper);
             final IDBI dbi = helper.getDBI();
             bind(IDBI.class).toInstance(dbi);
diff --git a/util/src/test/java/com/ning/billing/util/notificationq/dao/TestNotificationSqlDao.java b/util/src/test/java/com/ning/billing/util/notificationq/dao/TestNotificationSqlDao.java
index 5a6c4a1..ba2232a 100644
--- a/util/src/test/java/com/ning/billing/util/notificationq/dao/TestNotificationSqlDao.java
+++ b/util/src/test/java/com/ning/billing/util/notificationq/dao/TestNotificationSqlDao.java
@@ -16,8 +16,6 @@
 
 package com.ning.billing.util.notificationq.dao;
 
-import java.io.IOException;
-import java.sql.SQLException;
 import java.util.List;
 import java.util.UUID;
 
@@ -27,7 +25,6 @@ import org.skife.jdbi.v2.Handle;
 import org.skife.jdbi.v2.IDBI;
 import org.skife.jdbi.v2.tweak.HandleCallback;
 import org.testng.Assert;
-import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeSuite;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Guice;
@@ -35,21 +32,19 @@ import org.testng.annotations.Test;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.MysqlTestingHelper;
-import com.ning.billing.util.io.IOUtils;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.notificationq.DefaultNotification;
 import com.ning.billing.util.notificationq.Notification;
 import com.ning.billing.util.notificationq.dao.NotificationSqlDao.NotificationSqlMapper;
-import com.ning.billing.util.queue.PersistentQueueBase;
 import com.ning.billing.util.queue.PersistentQueueEntryLifecycle.PersistentQueueEntryLifecycleState;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
-@Test(groups = "slow")
 @Guice(modules = TestNotificationSqlDao.TestNotificationSqlDaoModule.class)
-public class TestNotificationSqlDao {
-
+public class TestNotificationSqlDao extends UtilTestSuiteWithEmbeddedDB {
     private static final UUID accountId = UUID.randomUUID();
     private static final String hostname = "Yop";
 
@@ -61,34 +56,14 @@ public class TestNotificationSqlDao {
 
     private NotificationSqlDao dao;
 
-    private void startMysql() throws IOException, ClassNotFoundException, SQLException {
-        final String ddl = IOUtils.toString(NotificationSqlDao.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-        helper.startMysql();
-        helper.initDb(ddl);
-    }
-
     @BeforeSuite(groups = "slow")
     public void setup() {
-        try {
-            startMysql();
-            dao = dbi.onDemand(NotificationSqlDao.class);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    @AfterSuite(groups = "slow")
-    public void stopMysql() {
-        if (helper != null) {
-            helper.stopMysql();
-        }
+        dao = dbi.onDemand(NotificationSqlDao.class);
     }
 
-
     @BeforeTest(groups = "slow")
     public void cleanupDb() {
         dbi.withHandle(new HandleCallback<Void>() {
-
             @Override
             public Void withHandle(final Handle handle) throws Exception {
                 handle.execute("delete from notifications");
@@ -98,9 +73,8 @@ public class TestNotificationSqlDao {
         });
     }
 
-    @Test
+    @Test(groups = "slow")
     public void testBasic() throws InterruptedException {
-
         final String ownerId = UUID.randomUUID().toString();
 
         final String notificationKey = UUID.randomUUID().toString();
@@ -129,7 +103,7 @@ public class TestNotificationSqlDao {
         notification = fetchNotification(notification.getId().toString());
         assertEquals(notification.getNotificationKey(), notificationKey);
         validateDate(notification.getEffectiveDate(), effDt);
-        assertEquals(notification.getOwner().toString(), ownerId);
+        assertEquals(notification.getOwner(), ownerId);
         assertEquals(notification.getProcessingState(), PersistentQueueEntryLifecycleState.IN_PROCESSING);
         validateDate(notification.getNextAvailableDate(), nextAvailable);
 
@@ -141,15 +115,10 @@ public class TestNotificationSqlDao {
         //assertEquals(notification.getOwner(), null);
         assertEquals(notification.getProcessingState(), PersistentQueueEntryLifecycleState.PROCESSED);
         validateDate(notification.getNextAvailableDate(), nextAvailable);
-
     }
 
-
-
-    @Test
+    @Test(groups = "slow")
     public void testGetByAccountAndDate() throws InterruptedException {
-
-
         final String notificationKey = UUID.randomUUID().toString();
         final DateTime effDt = new DateTime();
         final Notification notif1 = new DefaultNotification("testBasic1", hostname, notificationKey.getClass().getName(), notificationKey, accountId, effDt);
@@ -158,49 +127,44 @@ public class TestNotificationSqlDao {
         final Notification notif2 = new DefaultNotification("testBasic2", hostname, notificationKey.getClass().getName(), notificationKey, accountId, effDt);
         dao.insertNotification(notif2);
 
-
-        List<Notification> notifications =  dao.getNotificationForAccountAndDate(accountId.toString(), effDt.toDate());
+        List<Notification> notifications = dao.getNotificationForAccountAndDate(accountId.toString(), effDt.toDate());
         assertEquals(notifications.size(), 2);
-        for (Notification cur : notifications) {
+        for (final Notification cur : notifications) {
             Assert.assertEquals(cur.getProcessingState(), PersistentQueueEntryLifecycleState.AVAILABLE);
             dao.removeNotification(cur.getId().toString());
         }
 
-        notifications =  dao.getNotificationForAccountAndDate(accountId.toString(), effDt.toDate());
+        notifications = dao.getNotificationForAccountAndDate(accountId.toString(), effDt.toDate());
         assertEquals(notifications.size(), 2);
-        for (Notification cur : notifications) {
+        for (final Notification cur : notifications) {
             Assert.assertEquals(cur.getProcessingState(), PersistentQueueEntryLifecycleState.REMOVED);
         }
     }
 
-
     private Notification fetchNotification(final String notificationId) {
-        final Notification res = dbi.withHandle(new HandleCallback<Notification>() {
-
+        return dbi.withHandle(new HandleCallback<Notification>() {
             @Override
             public Notification withHandle(final Handle handle) throws Exception {
-                final Notification res = handle.createQuery("   select" +
-                                                                    " record_id " +
-                                                                    ", id" +
-                                                                    ", class_name" +
-                                                                    ", account_id" +
-                                                                    ", notification_key" +
-                                                                    ", created_date" +
-                                                                    ", creating_owner" +
-                                                                    ", effective_date" +
-                                                                    ", queue_name" +
-                                                                    ", processing_owner" +
-                                                                    ", processing_available_date" +
-                                                                    ", processing_state" +
-                                                                    "    from notifications " +
-                                                                    " where " +
-                                                                    " id = '" + notificationId + "';")
-                                               .map(new NotificationSqlMapper())
-                                               .first();
-                return res;
+                return handle.createQuery("   select" +
+                                                  " record_id " +
+                                                  ", id" +
+                                                  ", class_name" +
+                                                  ", account_id" +
+                                                  ", notification_key" +
+                                                  ", created_date" +
+                                                  ", creating_owner" +
+                                                  ", effective_date" +
+                                                  ", queue_name" +
+                                                  ", processing_owner" +
+                                                  ", processing_available_date" +
+                                                  ", processing_state" +
+                                                  "    from notifications " +
+                                                  " where " +
+                                                  " id = '" + notificationId + "';")
+                             .map(new NotificationSqlMapper())
+                             .first();
             }
         });
-        return res;
     }
 
     private void validateDate(DateTime input, DateTime expected) {
@@ -226,8 +190,7 @@ public class TestNotificationSqlDao {
     public static class TestNotificationSqlDaoModule extends AbstractModule {
         @Override
         protected void configure() {
-
-            final MysqlTestingHelper helper = new MysqlTestingHelper();
+            final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
             bind(MysqlTestingHelper.class).toInstance(helper);
             final IDBI dbi = helper.getDBI();
             bind(IDBI.class).toInstance(dbi);
diff --git a/util/src/test/java/com/ning/billing/util/notificationq/TestNotificationQueue.java b/util/src/test/java/com/ning/billing/util/notificationq/TestNotificationQueue.java
index c9ba744..32fdc70 100644
--- a/util/src/test/java/com/ning/billing/util/notificationq/TestNotificationQueue.java
+++ b/util/src/test/java/com/ning/billing/util/notificationq/TestNotificationQueue.java
@@ -16,8 +16,6 @@
 
 package com.ning.billing.util.notificationq;
 
-import java.io.IOException;
-import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Map;
 import java.util.TreeMap;
@@ -34,7 +32,6 @@ import org.skife.jdbi.v2.tweak.HandleCallback;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeSuite;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Guice;
@@ -47,8 +44,10 @@ import com.google.common.collect.Collections2;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.name.Names;
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.config.NotificationConfig;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.clock.Clock;
 import com.ning.billing.util.clock.ClockMock;
 import com.ning.billing.util.io.IOUtils;
@@ -59,10 +58,9 @@ import static com.jayway.awaitility.Awaitility.await;
 import static java.util.concurrent.TimeUnit.MINUTES;
 import static org.testng.Assert.assertEquals;
 
-@Test(groups = "slow")
 @Guice(modules = TestNotificationQueue.TestNotificationQueueModule.class)
-public class TestNotificationQueue {
-    Logger log = LoggerFactory.getLogger(TestNotificationQueue.class);
+public class TestNotificationQueue extends UtilTestSuiteWithEmbeddedDB {
+    private final Logger log = LoggerFactory.getLogger(TestNotificationQueue.class);
 
     private static final UUID accountId = UUID.randomUUID();
 
@@ -79,23 +77,11 @@ public class TestNotificationQueue {
 
     private int eventsReceived;
 
-    // private NotificationQueue queue;
-
-    private void startMysql() throws IOException, ClassNotFoundException, SQLException {
-        final String ddl = IOUtils.toString(NotificationSqlDao.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-        final String testDdl = IOUtils.toString(NotificationSqlDao.class.getResourceAsStream("/com/ning/billing/util/ddl_test.sql"));
-        helper.startMysql();
-        helper.initDb(ddl);
-        helper.initDb(testDdl);
-    }
-
-
-    private final static class TestNotificationKey implements NotificationKey, Comparable<TestNotificationKey> {
-
+    private static final class TestNotificationKey implements NotificationKey, Comparable<TestNotificationKey> {
         private final String value;
 
         @JsonCreator
-        public TestNotificationKey(@JsonProperty("value") String value) {
+        public TestNotificationKey(@JsonProperty("value") final String value) {
             super();
             this.value = value;
         }
@@ -110,20 +96,13 @@ public class TestNotificationQueue {
         }
     }
 
-
     @BeforeSuite(groups = "slow")
     public void setup() throws Exception {
-        startMysql();
+        final String testDdl = IOUtils.toString(NotificationSqlDao.class.getResourceAsStream("/com/ning/billing/util/ddl_test.sql"));
+        helper.initDb(testDdl);
         dao = dbi.onDemand(DummySqlTest.class);
     }
 
-    @AfterClass(groups = "slow")
-    public void tearDown() {
-        if (helper != null) {
-            helper.stopMysql();
-        }
-    }
-
     @BeforeTest(groups = "slow")
     public void beforeTest() {
         dbi.withHandle(new HandleCallback<Void>() {
@@ -141,32 +120,30 @@ public class TestNotificationQueue {
         eventsReceived = 0;
     }
 
-
     /**
      * Test that we can post a notification in the future from a transaction and get the notification
      * callback with the correct key when the time is ready
      *
      * @throws Exception
      */
-    @Test(groups = {"slow"}, enabled = true)
+    @Test(groups = "slow")
     public void testSimpleNotification() throws Exception {
 
         final Map<NotificationKey, Boolean> expectedNotifications = new TreeMap<NotificationKey, Boolean>();
 
         final DefaultNotificationQueue queue = new DefaultNotificationQueue(dbi, clock, "test-svc", "foo",
-                new NotificationQueueHandler() {
-            @Override
-            public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDateTime) {
-                synchronized (expectedNotifications) {
-                    log.info("Handler received key: " + notificationKey);
-
-                    expectedNotifications.put(notificationKey, Boolean.TRUE);
-                    expectedNotifications.notify();
-                }
-            }
-        },
-        getNotificationConfig(false, 100, 1, 10000));
-
+                                                                            new NotificationQueueHandler() {
+                                                                                @Override
+                                                                                public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDateTime) {
+                                                                                    synchronized (expectedNotifications) {
+                                                                                        log.info("Handler received key: " + notificationKey);
+
+                                                                                        expectedNotifications.put(notificationKey, Boolean.TRUE);
+                                                                                        expectedNotifications.notify();
+                                                                                    }
+                                                                                }
+                                                                            },
+                                                                            getNotificationConfig(false, 100, 1, 10000));
 
         queue.startQueue();
 
@@ -178,16 +155,15 @@ public class TestNotificationQueue {
 
         expectedNotifications.put(notificationKey, Boolean.FALSE);
 
-
         // Insert dummy to be processed in 2 sec'
         dao.inTransaction(new Transaction<Void, DummySqlTest>() {
             @Override
             public Void inTransaction(final DummySqlTest transactional,
-                    final TransactionStatus status) throws Exception {
+                                      final TransactionStatus status) throws Exception {
 
                 transactional.insertDummy(obj);
                 queue.recordFutureNotificationFromTransaction(transactional,
-                        readyTime, accountId, notificationKey);
+                                                              readyTime, accountId, notificationKey);
                 log.info("Posted key: " + notificationKey);
 
                 return null;
@@ -214,17 +190,16 @@ public class TestNotificationQueue {
         final Map<NotificationKey, Boolean> expectedNotifications = new TreeMap<NotificationKey, Boolean>();
 
         final DefaultNotificationQueue queue = new DefaultNotificationQueue(dbi, clock, "test-svc", "many",
-                new NotificationQueueHandler() {
-            @Override
-            public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDateTime) {
-                synchronized (expectedNotifications) {
-                    expectedNotifications.put(notificationKey, Boolean.TRUE);
-                    expectedNotifications.notify();
-                }
-            }
-        },
-        getNotificationConfig(false, 100, 10, 10000));
-
+                                                                            new NotificationQueueHandler() {
+                                                                                @Override
+                                                                                public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDateTime) {
+                                                                                    synchronized (expectedNotifications) {
+                                                                                        expectedNotifications.put(notificationKey, Boolean.TRUE);
+                                                                                        expectedNotifications.notify();
+                                                                                    }
+                                                                                }
+                                                                            },
+                                                                            getNotificationConfig(false, 100, 10, 10000));
 
         queue.startQueue();
 
@@ -244,11 +219,11 @@ public class TestNotificationQueue {
             dao.inTransaction(new Transaction<Void, DummySqlTest>() {
                 @Override
                 public Void inTransaction(final DummySqlTest transactional,
-                        final TransactionStatus status) throws Exception {
+                                          final TransactionStatus status) throws Exception {
 
                     transactional.insertDummy(obj);
                     queue.recordFutureNotificationFromTransaction(transactional,
-                            now.plus((currentIteration + 1) * nextReadyTimeIncrementMs), accountId, notificationKey);
+                                                                  now.plus((currentIteration + 1) * nextReadyTimeIncrementMs), accountId, notificationKey);
                     return null;
                 }
             });
@@ -266,7 +241,6 @@ public class TestNotificationQueue {
         boolean success = false;
         do {
             synchronized (expectedNotifications) {
-
                 final Collection<Boolean> completed = Collections2.filter(expectedNotifications.values(), new Predicate<Boolean>() {
                     @Override
                     public boolean apply(final Boolean input) {
@@ -284,7 +258,7 @@ public class TestNotificationQueue {
         } while (nbTry-- > 0);
 
         queue.stopQueue();
-        log.info("STEPH GOT SIZE " +  Collections2.filter(expectedNotifications.values(), new Predicate<Boolean>() {
+        log.info("STEPH GOT SIZE " + Collections2.filter(expectedNotifications.values(), new Predicate<Boolean>() {
             @Override
             public boolean apply(final Boolean input) {
                 return input;
@@ -299,9 +273,8 @@ public class TestNotificationQueue {
      *
      * @throws Exception
      */
-    @Test(groups = {"slow"}, enabled = true)
+    @Test(groups = "slow")
     public void testMultipleHandlerNotification() throws Exception {
-
         final Map<NotificationKey, Boolean> expectedNotificationsFred = new TreeMap<NotificationKey, Boolean>();
         final Map<NotificationKey, Boolean> expectedNotificationsBarney = new TreeMap<NotificationKey, Boolean>();
 
@@ -319,7 +292,6 @@ public class TestNotificationQueue {
             }
         };
 
-
         final NotificationQueue queueFred = notificationQueueService.createNotificationQueue("UtilTest", "Fred", new NotificationQueueHandler() {
             @Override
             public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDateTime) {
@@ -328,7 +300,7 @@ public class TestNotificationQueue {
                 eventsReceived++;
             }
         },
-        config);
+                                                                                             config);
 
         final NotificationQueue queueBarney = notificationQueueService.createNotificationQueue("UtilTest", "Barney", new NotificationQueueHandler() {
             @Override
@@ -338,37 +310,34 @@ public class TestNotificationQueue {
                 eventsReceived++;
             }
         },
-        config);
+                                                                                               config);
 
         queueFred.startQueue();
         //		We don't start Barney so it can never pick up notifications
 
-
         final UUID key = UUID.randomUUID();
         final DummyObject obj = new DummyObject("foo", key);
         final DateTime now = new DateTime();
         final DateTime readyTime = now.plusMillis(2000);
         final NotificationKey notificationKeyFred = new TestNotificationKey("Fred");
 
-
         final NotificationKey notificationKeyBarney = new TestNotificationKey("Barney");
 
         expectedNotificationsFred.put(notificationKeyFred, Boolean.FALSE);
         expectedNotificationsFred.put(notificationKeyBarney, Boolean.FALSE);
 
-
         // Insert dummy to be processed in 2 sec'
         dao.inTransaction(new Transaction<Void, DummySqlTest>() {
             @Override
             public Void inTransaction(final DummySqlTest transactional,
-                    final TransactionStatus status) throws Exception {
+                                      final TransactionStatus status) throws Exception {
 
                 transactional.insertDummy(obj);
                 queueFred.recordFutureNotificationFromTransaction(transactional,
-                        readyTime, accountId, notificationKeyFred);
+                                                                  readyTime, accountId, notificationKeyFred);
                 log.info("posted key: " + notificationKeyFred.toString());
                 queueBarney.recordFutureNotificationFromTransaction(transactional,
-                        readyTime, accountId, notificationKeyBarney);
+                                                                    readyTime, accountId, notificationKeyBarney);
                 log.info("posted key: " + notificationKeyBarney.toString());
 
                 return null;
@@ -397,8 +366,7 @@ public class TestNotificationQueue {
         Assert.assertFalse(expectedNotificationsFred.get(notificationKeyBarney));
     }
 
-    NotificationConfig getNotificationConfig(final boolean off,
-            final long sleepTime, final int maxReadyEvents, final long claimTimeMs) {
+    NotificationConfig getNotificationConfig(final boolean off, final long sleepTime, final int maxReadyEvents, final long claimTimeMs) {
         return new NotificationConfig() {
             @Override
             public boolean isNotificationProcessingOff() {
@@ -412,27 +380,24 @@ public class TestNotificationQueue {
         };
     }
 
-
     @Test(groups = "slow")
     public void testRemoveNotifications() throws InterruptedException {
-
         final UUID key = UUID.randomUUID();
         final NotificationKey notificationKey = new TestNotificationKey(key.toString());
         final UUID key2 = UUID.randomUUID();
         final NotificationKey notificationKey2 = new TestNotificationKey(key2.toString());
 
         final DefaultNotificationQueue queue = new DefaultNotificationQueue(dbi, clock, "test-svc", "many",
-                new NotificationQueueHandler() {
-            @Override
-            public void handleReadyNotification(final NotificationKey inputKey, final DateTime eventDateTime) {
-                if (inputKey.equals(notificationKey) || inputKey.equals(notificationKey2)) { //ignore stray events from other tests
-                    log.info("Received notification with key: " + notificationKey);
-                    eventsReceived++;
-                }
-            }
-        },
-        getNotificationConfig(false, 100, 10, 10000));
-
+                                                                            new NotificationQueueHandler() {
+                                                                                @Override
+                                                                                public void handleReadyNotification(final NotificationKey inputKey, final DateTime eventDateTime) {
+                                                                                    if (inputKey.equals(notificationKey) || inputKey.equals(notificationKey2)) { //ignore stray events from other tests
+                                                                                        log.info("Received notification with key: " + notificationKey);
+                                                                                        eventsReceived++;
+                                                                                    }
+                                                                                }
+                                                                            },
+                                                                            getNotificationConfig(false, 100, 10, 10000));
 
         queue.startQueue();
 
@@ -444,19 +409,18 @@ public class TestNotificationQueue {
         dao.inTransaction(new Transaction<Void, DummySqlTest>() {
             @Override
             public Void inTransaction(final DummySqlTest transactional,
-                    final TransactionStatus status) throws Exception {
+                                      final TransactionStatus status) throws Exception {
 
                 queue.recordFutureNotificationFromTransaction(transactional,
-                        start.plus(nextReadyTimeIncrementMs), accountId, notificationKey);
+                                                              start.plus(nextReadyTimeIncrementMs), accountId, notificationKey);
                 queue.recordFutureNotificationFromTransaction(transactional,
-                        start.plus(2 * nextReadyTimeIncrementMs), accountId, notificationKey);
+                                                              start.plus(2 * nextReadyTimeIncrementMs), accountId, notificationKey);
                 queue.recordFutureNotificationFromTransaction(transactional,
-                        start.plus(3 * nextReadyTimeIncrementMs), accountId, notificationKey2);
+                                                              start.plus(3 * nextReadyTimeIncrementMs), accountId, notificationKey2);
                 return null;
             }
         });
 
-
         queue.removeNotificationsByKey(notificationKey); // should remove 2 of the 3
 
         // Move time in the future after the notification effectiveDate
@@ -477,26 +441,17 @@ public class TestNotificationQueue {
         queue.stopQueue();
     }
 
-
     public static class TestNotificationQueueModule extends AbstractModule {
         @Override
         protected void configure() {
-
             bind(Clock.class).to(ClockMock.class);
 
-            final MysqlTestingHelper helper = new MysqlTestingHelper();
+            final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
             bind(MysqlTestingHelper.class).toInstance(helper);
             final IDBI dbi = helper.getDBI();
             bind(IDBI.class).toInstance(dbi);
             final IDBI otherDbi = helper.getDBI();
             bind(IDBI.class).annotatedWith(Names.named("global-lock")).toInstance(otherDbi);
-            /*
-            bind(DBI.class).toProvider(DBIProvider.class).asEagerSingleton();
-            final DbiConfig config = new ConfigurationObjectFactory(System.getProperties()).build(DbiConfig.class);
-            bind(DbiConfig.class).toInstance(config);
-             */
         }
     }
-
-
 }
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagCreationEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagCreationEvent.java
index 5ebd270..9651c31 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagCreationEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagCreationEvent.java
@@ -21,13 +21,14 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.dao.ObjectType;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultControlTagCreationEvent {
+public class TestDefaultControlTagCreationEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionCreationEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionCreationEvent.java
index 05d4c05..7ad5252 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionCreationEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionCreationEvent.java
@@ -21,12 +21,13 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultControlTagDefinitionCreationEvent {
+public class TestDefaultControlTagDefinitionCreationEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagDefinitionId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionDeletionEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionDeletionEvent.java
index 08059d1..2ea3181 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionDeletionEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDefinitionDeletionEvent.java
@@ -21,12 +21,13 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultControlTagDefinitionDeletionEvent {
+public class TestDefaultControlTagDefinitionDeletionEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagDefinitionId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDeletionEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDeletionEvent.java
index 692149a..5f68460 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDeletionEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultControlTagDeletionEvent.java
@@ -21,13 +21,14 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.dao.ObjectType;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultControlTagDeletionEvent {
+public class TestDefaultControlTagDeletionEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagCreationEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagCreationEvent.java
index 4d8162a..e330375 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagCreationEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagCreationEvent.java
@@ -21,13 +21,14 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.dao.ObjectType;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultUserTagCreationEvent {
+public class TestDefaultUserTagCreationEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionCreationEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionCreationEvent.java
index 89507d3..ae7ddfa 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionCreationEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionCreationEvent.java
@@ -21,12 +21,13 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultUserTagDefinitionCreationEvent {
+public class TestDefaultUserTagDefinitionCreationEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagDefinitionId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionDeletionEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionDeletionEvent.java
index bdcfaff..9bc13a2 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionDeletionEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDefinitionDeletionEvent.java
@@ -21,12 +21,13 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultUserTagDefinitionDeletionEvent {
+public class TestDefaultUserTagDefinitionDeletionEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagDefinitionId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDeletionEvent.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDeletionEvent.java
index ff022ef..2b8bd68 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDeletionEvent.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestDefaultUserTagDeletionEvent.java
@@ -21,13 +21,14 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.dao.ObjectType;
 import com.ning.billing.util.jackson.ObjectMapper;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
 
-public class TestDefaultUserTagDeletionEvent {
+public class TestDefaultUserTagDeletionEvent extends UtilTestSuite {
     @Test(groups = "fast")
     public void testPojo() throws Exception {
         final UUID tagId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/api/user/TestTagEventBuilder.java b/util/src/test/java/com/ning/billing/util/tag/api/user/TestTagEventBuilder.java
index 724ad14..f9f7411 100644
--- a/util/src/test/java/com/ning/billing/util/tag/api/user/TestTagEventBuilder.java
+++ b/util/src/test/java/com/ning/billing/util/tag/api/user/TestTagEventBuilder.java
@@ -21,6 +21,7 @@ import java.util.UUID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.ning.billing.util.UtilTestSuite;
 import com.ning.billing.util.dao.ObjectType;
 import com.ning.billing.util.tag.DefaultTagDefinition;
 import com.ning.billing.util.tag.TagDefinition;
@@ -35,7 +36,7 @@ import com.ning.billing.util.tag.api.UserTagDefinitionCreationEvent;
 import com.ning.billing.util.tag.api.UserTagDefinitionDeletionEvent;
 import com.ning.billing.util.tag.api.UserTagDeletionEvent;
 
-public class TestTagEventBuilder {
+public class TestTagEventBuilder extends UtilTestSuite {
     @Test(groups = "fast")
     public void testNewUserTagDefinitionCreationEvent() throws Exception {
         final UUID tagDefinitionId = UUID.randomUUID();
diff --git a/util/src/test/java/com/ning/billing/util/tag/dao/TestAuditedTagDao.java b/util/src/test/java/com/ning/billing/util/tag/dao/TestAuditedTagDao.java
index c21cf14..35c3117 100644
--- a/util/src/test/java/com/ning/billing/util/tag/dao/TestAuditedTagDao.java
+++ b/util/src/test/java/com/ning/billing/util/tag/dao/TestAuditedTagDao.java
@@ -32,6 +32,7 @@ import org.testng.annotations.Test;
 import com.google.common.eventbus.Subscribe;
 import com.google.inject.Inject;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.bus.Bus;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.callcontext.CallContext;
@@ -48,7 +49,7 @@ import com.ning.billing.util.tag.TestTagStore;
 import com.ning.billing.util.tag.api.TagEvent;
 
 @Guice(modules = MockTagStoreModuleSql.class)
-public class TestAuditedTagDao {
+public class TestAuditedTagDao extends UtilTestSuiteWithEmbeddedDB {
     @Inject
     private MysqlTestingHelper helper;
 
@@ -69,25 +70,19 @@ public class TestAuditedTagDao {
 
     @BeforeClass(groups = "slow")
     public void setup() throws IOException {
-        final String utilDdl = IOUtils.toString(TestTagStore.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-
-        helper.startMysql();
-        helper.initDb(utilDdl);
-
         context = new DefaultCallContextFactory(clock).createCallContext("Tag DAO test", CallOrigin.TEST, UserType.TEST, UUID.randomUUID());
         bus.start();
     }
 
     @BeforeMethod(groups = "slow")
-    public void cleanup() throws Bus.EventBusException {
+    public void cleanupBeforeMethod() throws Bus.EventBusException {
         eventsListener = new EventsListener();
         bus.register(eventsListener);
     }
 
     @AfterClass(groups = "slow")
-    public void stopMysql() {
+    public void tearDown() {
         bus.stop();
-        helper.stopMysql();
     }
 
     @Test(groups = "slow")
diff --git a/util/src/test/java/com/ning/billing/util/tag/dao/TestDefaultTagDefinitionDao.java b/util/src/test/java/com/ning/billing/util/tag/dao/TestDefaultTagDefinitionDao.java
index c895b67..15d00e1 100644
--- a/util/src/test/java/com/ning/billing/util/tag/dao/TestDefaultTagDefinitionDao.java
+++ b/util/src/test/java/com/ning/billing/util/tag/dao/TestDefaultTagDefinitionDao.java
@@ -31,6 +31,7 @@ import org.testng.annotations.Test;
 import com.google.common.eventbus.Subscribe;
 import com.google.inject.Inject;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.bus.Bus;
 import com.ning.billing.util.bus.BusEvent;
 import com.ning.billing.util.callcontext.CallContext;
@@ -45,7 +46,7 @@ import com.ning.billing.util.tag.TestTagStore;
 import com.ning.billing.util.tag.api.TagDefinitionEvent;
 
 @Guice(modules = MockTagStoreModuleSql.class)
-public class TestDefaultTagDefinitionDao {
+public class TestDefaultTagDefinitionDao extends UtilTestSuiteWithEmbeddedDB {
     @Inject
     private MysqlTestingHelper helper;
 
@@ -63,25 +64,19 @@ public class TestDefaultTagDefinitionDao {
 
     @BeforeClass(groups = "slow")
     public void setup() throws IOException {
-        final String utilDdl = IOUtils.toString(TestTagStore.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-
-        helper.startMysql();
-        helper.initDb(utilDdl);
-
         context = new DefaultCallContextFactory(clock).createCallContext("TagDefinition DAO test", CallOrigin.TEST, UserType.TEST, UUID.randomUUID());
         bus.start();
     }
 
     @BeforeMethod(groups = "slow")
-    public void cleanup() throws Bus.EventBusException {
+    public void cleanupBeforeMethod() throws Bus.EventBusException {
         eventsListener = new EventsListener();
         bus.register(eventsListener);
     }
 
     @AfterClass(groups = "slow")
-    public void stopMysql() {
+    public void tearDown() {
         bus.stop();
-        helper.stopMysql();
     }
 
     @Test(groups = "slow")
diff --git a/util/src/test/java/com/ning/billing/util/tag/MockTagStoreModuleSql.java b/util/src/test/java/com/ning/billing/util/tag/MockTagStoreModuleSql.java
index d7a704b..56bb2f7 100644
--- a/util/src/test/java/com/ning/billing/util/tag/MockTagStoreModuleSql.java
+++ b/util/src/test/java/com/ning/billing/util/tag/MockTagStoreModuleSql.java
@@ -21,6 +21,7 @@ import org.skife.jdbi.v2.Handle;
 import org.skife.jdbi.v2.IDBI;
 import org.skife.jdbi.v2.tweak.HandleCallback;
 
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.MysqlTestingHelper;
 import com.ning.billing.mock.glue.MockClockModule;
 import com.ning.billing.util.bus.Bus;
@@ -32,7 +33,7 @@ public class MockTagStoreModuleSql extends TagStoreModule {
 
     @Override
     protected void configure() {
-        helper = new MysqlTestingHelper();
+        helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
         bind(IDBI.class).toInstance(helper.getDBI());
         bind(MysqlTestingHelper.class).toInstance(helper);
         install(new MockClockModule());
diff --git a/util/src/test/java/com/ning/billing/util/tag/TestTagStore.java b/util/src/test/java/com/ning/billing/util/tag/TestTagStore.java
index a5016a7..0fb9e97 100644
--- a/util/src/test/java/com/ning/billing/util/tag/TestTagStore.java
+++ b/util/src/test/java/com/ning/billing/util/tag/TestTagStore.java
@@ -36,6 +36,7 @@ import org.testng.annotations.Test;
 
 import com.google.inject.Inject;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.api.TagApiException;
 import com.ning.billing.util.api.TagDefinitionApiException;
 import com.ning.billing.util.bus.Bus;
@@ -57,7 +58,7 @@ import static org.testng.Assert.fail;
 
 @Test(groups = {"slow"})
 @Guice(modules = MockTagStoreModuleSql.class)
-public class TestTagStore {
+public class TestTagStore extends UtilTestSuiteWithEmbeddedDB {
     @Inject
     private MysqlTestingHelper helper;
 
@@ -83,17 +84,10 @@ public class TestTagStore {
 
     @BeforeClass(groups = "slow")
     protected void setup() throws IOException {
-        // Health check test to make sure MySQL is setup properly
         try {
-            final String utilDdl = IOUtils.toString(TestTagStore.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
-
-            helper.startMysql();
-            helper.initDb(utilDdl);
-
             context = new DefaultCallContextFactory(clock).createCallContext("Tag store test", CallOrigin.TEST, UserType.TEST);
             bus.start();
 
-            cleanupTags();
             tagDefinitionDao.create("tag1", "First tag", context);
             testTag = tagDefinitionDao.create("testTag", "Second tag", context);
         } catch (Throwable t) {
@@ -103,27 +97,8 @@ public class TestTagStore {
     }
 
     @AfterClass(groups = "slow")
-    public void stopMysql() {
+    public void tearDown() {
         bus.stop();
-        if (helper != null) {
-            helper.stopMysql();
-        }
-    }
-
-    private void cleanupTags() {
-        try {
-            helper.getDBI().withHandle(new HandleCallback<Void>() {
-                @Override
-                public Void withHandle(final Handle handle) throws Exception {
-                    handle.createScript("delete from tag_definitions").execute();
-                    handle.createScript("delete from tag_definition_history").execute();
-                    handle.createScript("delete from tags").execute();
-                    handle.createScript("delete from tag_history").execute();
-                    return null;
-                }
-            });
-        } catch (Throwable ignore) {
-        }
     }
 
     @Test(groups = "slow")
diff --git a/util/src/test/java/com/ning/billing/util/template/translation/TestDefaultTranslatorBase.java b/util/src/test/java/com/ning/billing/util/template/translation/TestDefaultTranslatorBase.java
index d379804..00fc0c2 100644
--- a/util/src/test/java/com/ning/billing/util/template/translation/TestDefaultTranslatorBase.java
+++ b/util/src/test/java/com/ning/billing/util/template/translation/TestDefaultTranslatorBase.java
@@ -23,7 +23,9 @@ import org.mockito.Mockito;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-public class TestDefaultTranslatorBase {
+import com.ning.billing.util.UtilTestSuite;
+
+public class TestDefaultTranslatorBase extends UtilTestSuite {
     private final class TestTranslatorBase extends DefaultTranslatorBase {
         public TestTranslatorBase(final TranslatorConfig config) {
             super(config);
diff --git a/util/src/test/java/com/ning/billing/util/UtilTestSuite.java b/util/src/test/java/com/ning/billing/util/UtilTestSuite.java
new file mode 100644
index 0000000..3b0658b
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/UtilTestSuite.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.util;
+
+import com.ning.billing.KillbillTestSuite;
+
+public abstract class UtilTestSuite extends KillbillTestSuite {
+}
diff --git a/util/src/test/java/com/ning/billing/util/UtilTestSuiteWithEmbeddedDB.java b/util/src/test/java/com/ning/billing/util/UtilTestSuiteWithEmbeddedDB.java
new file mode 100644
index 0000000..e0b2c3d
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/UtilTestSuiteWithEmbeddedDB.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.util;
+
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
+
+public abstract class UtilTestSuiteWithEmbeddedDB extends KillbillTestSuiteWithEmbeddedDB {
+}
diff --git a/util/src/test/java/com/ning/billing/util/validation/TestValidationManager.java b/util/src/test/java/com/ning/billing/util/validation/TestValidationManager.java
index 204abdb..9406f4d 100644
--- a/util/src/test/java/com/ning/billing/util/validation/TestValidationManager.java
+++ b/util/src/test/java/com/ning/billing/util/validation/TestValidationManager.java
@@ -25,7 +25,10 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.util.UtilTestSuite;
+import com.ning.billing.util.UtilTestSuiteWithEmbeddedDB;
 import com.ning.billing.util.globallocker.TestMysqlGlobalLocker;
 import com.ning.billing.util.io.IOUtils;
 import com.ning.billing.util.validation.dao.DatabaseSchemaDao;
@@ -36,8 +39,8 @@ import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
-public class TestValidationManager {
-    private final MysqlTestingHelper helper = new MysqlTestingHelper();
+public class TestValidationManager extends UtilTestSuiteWithEmbeddedDB {
+    private final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
     private static final String TABLE_NAME = "validation_test";
 
     private ValidationManager vm;
@@ -57,21 +60,9 @@ public class TestValidationManager {
 
     private void setupDatabase() throws IOException {
         final String testDdl = IOUtils.toString(TestMysqlGlobalLocker.class.getResourceAsStream("/com/ning/billing/util/ddl_test.sql"));
-        helper.startMysql();
         helper.initDb(testDdl);
     }
 
-    @AfterClass(groups = "slow")
-    public void tearDown() {
-        stopDatabase();
-    }
-
-    private void stopDatabase() {
-        if (helper != null) {
-            helper.stopMysql();
-        }
-    }
-
     @Test(groups = "slow")
     public void testRetrievingColumnInfo() {
         final Collection<ColumnInfo> columnInfoList = vm.getTableInfo(TABLE_NAME);