killbill-uncached

tenant: update tests to new conventions See #38. Signed-off-by:

2/18/2013 2:53:50 AM

Details

diff --git a/tenant/src/test/java/com/ning/billing/tenant/dao/TestDefaultTenantDao.java b/tenant/src/test/java/com/ning/billing/tenant/dao/TestDefaultTenantDao.java
index 58d5026..e10b69e 100644
--- a/tenant/src/test/java/com/ning/billing/tenant/dao/TestDefaultTenantDao.java
+++ b/tenant/src/test/java/com/ning/billing/tenant/dao/TestDefaultTenantDao.java
@@ -28,17 +28,11 @@ import org.testng.annotations.Test;
 import com.ning.billing.tenant.TenantTestSuiteWithEmbeddedDb;
 import com.ning.billing.tenant.api.DefaultTenant;
 import com.ning.billing.tenant.security.KillbillCredentialsMatcher;
-import com.ning.billing.util.cache.CacheControllerDispatcher;
-import com.ning.billing.util.dao.DefaultNonEntityDao;
 
 public class TestDefaultTenantDao extends TenantTestSuiteWithEmbeddedDb {
 
-    private CacheControllerDispatcher controllerDispatcher = new CacheControllerDispatcher();
-
     @Test(groups = "slow")
     public void testWeCanStoreAndMatchCredentials() throws Exception {
-        final DefaultTenantDao tenantDao = new DefaultTenantDao(getDBI(), clock, controllerDispatcher, new DefaultNonEntityDao(getDBI()));
-
         final DefaultTenant tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(),
                                                        UUID.randomUUID().toString(), UUID.randomUUID().toString());
         tenantDao.create(new TenantModelDao(tenant), internalCallContext);
@@ -60,7 +54,6 @@ public class TestDefaultTenantDao extends TenantTestSuiteWithEmbeddedDb {
 
     @Test(groups = "slow")
     public void testTenantKeyValue() throws Exception {
-        final DefaultTenantDao tenantDao = new DefaultTenantDao(getDBI(), clock, controllerDispatcher, new DefaultNonEntityDao(getDBI()));
         final DefaultTenant tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(),
                                                        UUID.randomUUID().toString(), UUID.randomUUID().toString());
         tenantDao.create(new TenantModelDao(tenant), internalCallContext);
diff --git a/tenant/src/test/java/com/ning/billing/tenant/glue/TestTenantModule.java b/tenant/src/test/java/com/ning/billing/tenant/glue/TestTenantModule.java
new file mode 100644
index 0000000..b59207d
--- /dev/null
+++ b/tenant/src/test/java/com/ning/billing/tenant/glue/TestTenantModule.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010-2013 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.tenant.glue;
+
+import java.util.Properties;
+
+import org.skife.config.ConfigSource;
+import org.skife.config.SimplePropertyConfigSource;
+
+import com.ning.billing.util.glue.CacheModule;
+import com.ning.billing.util.glue.CallContextModule;
+
+public class TestTenantModule extends TenantModule {
+
+    protected final ConfigSource configSource;
+
+    public TestTenantModule() {
+        final Properties properties = new Properties(System.getProperties());
+        // Speed up the bus
+        properties.put("killbill.billing.util.persistent.bus.sleep", "10");
+        properties.put("killbill.billing.util.persistent.bus.nbThreads", "1");
+        configSource = new SimplePropertyConfigSource(properties);
+
+        // Ignore ehcache checks. Unfortunately, ehcache looks at system properties directly...
+        System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");
+    }
+
+    @Override
+    protected void configure() {
+        super.configure();
+
+        install(new CacheModule());
+        install(new CallContextModule());
+    }
+}
diff --git a/tenant/src/test/java/com/ning/billing/tenant/glue/TestTenantModuleWithEmbeddedDB.java b/tenant/src/test/java/com/ning/billing/tenant/glue/TestTenantModuleWithEmbeddedDB.java
new file mode 100644
index 0000000..8a3821b
--- /dev/null
+++ b/tenant/src/test/java/com/ning/billing/tenant/glue/TestTenantModuleWithEmbeddedDB.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2010-2013 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.tenant.glue;
+
+import com.ning.billing.GuicyKillbillTestWithEmbeddedDBModule;
+import com.ning.billing.util.glue.NonEntityDaoModule;
+
+public class TestTenantModuleWithEmbeddedDB extends TestTenantModule {
+
+    @Override
+    public void configure() {
+        super.configure();
+
+        install(new GuicyKillbillTestWithEmbeddedDBModule());
+        install(new NonEntityDaoModule());
+    }
+}
diff --git a/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteNoDB.java b/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteNoDB.java
new file mode 100644
index 0000000..0e12ad0
--- /dev/null
+++ b/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteNoDB.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010-2013 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.tenant;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+
+import com.ning.billing.GuicyKillbillTestSuiteNoDB;
+import com.ning.billing.tenant.glue.TestTenantModuleNoDB;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class TenantTestSuiteNoDB extends GuicyKillbillTestSuiteNoDB {
+
+    @BeforeClass(groups = "fast")
+    protected void setup() throws Exception {
+        final Injector injector = Guice.createInjector(new TestTenantModuleNoDB());
+        injector.injectMembers(this);
+    }
+
+    @BeforeMethod(groups = "fast")
+    public void setupTest() {
+    }
+
+    @AfterMethod(groups = "fast")
+    public void cleanupTest() {
+    }
+}
diff --git a/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteWithEmbeddedDb.java b/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteWithEmbeddedDb.java
index a38fe9b..18f36a1 100644
--- a/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteWithEmbeddedDb.java
+++ b/tenant/src/test/java/com/ning/billing/tenant/TenantTestSuiteWithEmbeddedDb.java
@@ -16,8 +16,34 @@
 
 package com.ning.billing.tenant;
 
-import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
 
-public class TenantTestSuiteWithEmbeddedDb extends KillbillTestSuiteWithEmbeddedDB {
+import com.ning.billing.GuicyKillbillTestSuiteWithEmbeddedDB;
+import com.ning.billing.tenant.dao.DefaultTenantDao;
+import com.ning.billing.tenant.glue.TestTenantModuleWithEmbeddedDB;
 
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+public class TenantTestSuiteWithEmbeddedDb extends GuicyKillbillTestSuiteWithEmbeddedDB {
+
+    @Inject
+    protected DefaultTenantDao tenantDao;
+
+    @BeforeClass(groups = "slow")
+    protected void setup() throws Exception {
+        final Injector injector = Guice.createInjector(new TestTenantModuleWithEmbeddedDB());
+        injector.injectMembers(this);
+    }
+
+    @BeforeMethod(groups = "slow")
+    public void setupTest() {
+    }
+
+    @AfterMethod(groups = "slow")
+    public void cleanupTest() {
+    }
 }