killbill-memoizeit
Changes
entitlement/pom.xml 48(+21 -27)
entitlement/src/test/java/com/ning/billing/entitlement/api/billing/TestDefaultEntitlementBillingApi.java 74(+40 -34)
entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java 10(+5 -5)
Details
entitlement/pom.xml 48(+21 -27)
diff --git a/entitlement/pom.xml b/entitlement/pom.xml
index cf8d926..363e948 100644
--- a/entitlement/pom.xml
+++ b/entitlement/pom.xml
@@ -8,7 +8,8 @@
OR CONDITIONS OF ANY KIND, either express or implied. See the ~ License for
the specific language governing permissions and limitations ~ under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ning.billing</groupId>
@@ -29,10 +30,6 @@
<artifactId>jdbi-metrics</artifactId>
</dependency>
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- </dependency>
- <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
@@ -56,10 +53,10 @@
<artifactId>killbill-catalog</artifactId>
<scope>test</scope>
</dependency>
+ <!-- Should be in test scope , but broken right now -->
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-account</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>com.ning.billing</groupId>
@@ -72,16 +69,26 @@
<artifactId>killbill-util</artifactId>
</dependency>
<dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-account</artifactId>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-account</artifactId>
- <type>test-jar</type>
+ <groupId>com.mysql</groupId>
+ <artifactId>management</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.mysql</groupId>
+ <artifactId>management-dbfiles</artifactId>
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
@@ -126,10 +133,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <groups>setup,fast</groups>
+ <groups>fast,slow</groups>
</configuration>
</plugin>
- <plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
@@ -144,26 +151,13 @@
</build>
<profiles>
<profile>
- <id>test-sql</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <groups>setup,sql</groups>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
<id>test-stress</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <groups>setup,stress</groups>
+ <groups>stress</groups>
</configuration>
</plugin>
</plugins>
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/billing/TestDefaultEntitlementBillingApi.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/billing/TestDefaultEntitlementBillingApi.java
index 2d99f8d..c62fa07 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/billing/TestDefaultEntitlementBillingApi.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/billing/TestDefaultEntitlementBillingApi.java
@@ -29,6 +29,7 @@ import org.joda.time.DateTimeZone;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.inject.Guice;
@@ -66,7 +67,7 @@ public class TestDefaultEntitlementBillingApi {
private static final UUID zeroId = new UUID(0L,0L);
private static final UUID oneId = new UUID(1L,0L);
private static final UUID twoId = new UUID(2L,0L);
-
+
private CatalogService catalogService;
private ArrayList<SubscriptionBundle> bundles;
private ArrayList<Subscription> subscriptions;
@@ -77,51 +78,55 @@ public class TestDefaultEntitlementBillingApi {
private SubscriptionData subscription;
private DateTime subscriptionStartDate;
- @BeforeClass(groups={"setup"})
+ @BeforeSuite(alwaysRun=true)
public void setup() throws ServiceException {
TestApiBase.loadSystemPropertiesFromClasspath("/entitlement.properties");
final Injector g = Guice.createInjector(Stage.PRODUCTION, new CatalogModule(), new ClockModule());
-
+
catalogService = g.getInstance(CatalogService.class);
clock = g.getInstance(Clock.class);
-
+
((DefaultCatalogService)catalogService).loadCatalog();
}
-
+
@BeforeMethod(alwaysRun=true)
public void setupEveryTime() {
bundles = new ArrayList<SubscriptionBundle>();
final SubscriptionBundle bundle = new SubscriptionBundleData( zeroId,"TestKey", oneId, clock.getUTCNow().minusDays(4));
bundles.add(bundle);
-
-
+
+
transitions = new ArrayList<SubscriptionTransition>();
subscriptions = new ArrayList<Subscription>();
-
+
SubscriptionBuilder builder = new SubscriptionBuilder();
subscriptionStartDate = clock.getUTCNow().minusDays(3);
builder.setStartDate(subscriptionStartDate).setId(oneId);
subscription = new SubscriptionData(builder) {
- public List<SubscriptionTransition> getAllTransitions() {
+ @Override
+ public List<SubscriptionTransition> getAllTransitions() {
return transitions;
}
};
subscriptions.add(subscription);
-
+
dao = new BrainDeadMockEntitlementDao() {
- public List<SubscriptionBundle> getSubscriptionBundleForAccount(
+ @Override
+ public List<SubscriptionBundle> getSubscriptionBundleForAccount(
UUID accountId) {
return bundles;
-
+
}
- public List<Subscription> getSubscriptions(UUID bundleId) {
+ @Override
+ public List<Subscription> getSubscriptions(UUID bundleId) {
return subscriptions;
}
- public Subscription getSubscriptionFromId(UUID subscriptionId) {
+ @Override
+ public Subscription getSubscriptionFromId(UUID subscriptionId) {
return subscription;
}
@@ -139,11 +144,12 @@ public class TestDefaultEntitlementBillingApi {
assertTrue(true);
}
-
+
@Test(enabled=true, groups="fast")
public void testBillingEventsEmpty() {
EntitlementDao dao = new BrainDeadMockEntitlementDao() {
- public List<SubscriptionBundle> getSubscriptionBundleForAccount(
+ @Override
+ public List<SubscriptionBundle> getSubscriptionBundleForAccount(
UUID accountId) {
return new ArrayList<SubscriptionBundle>();
}
@@ -159,7 +165,7 @@ public class TestDefaultEntitlementBillingApi {
SortedSet<BillingEvent> events = api.getBillingEventsForAccount(new UUID(0L,0L));
Assert.assertEquals(events.size(), 0);
}
-
+
@Test(enabled=true, groups="fast")
public void testBillingEventsNoBillingPeriod() throws CatalogApiException {
DateTime now = clock.getUTCNow();
@@ -170,7 +176,7 @@ public class TestDefaultEntitlementBillingApi {
SubscriptionTransition t = new SubscriptionTransitionData(
zeroId, oneId, twoId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList);
transitions.add(t);
-
+
AccountUserApi accountApi = new BrainDeadAccountUserApi(){
@Override
@@ -195,18 +201,18 @@ public class TestDefaultEntitlementBillingApi {
SubscriptionTransition t = new SubscriptionTransitionData(
zeroId, oneId, twoId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList);
transitions.add(t);
-
- Account account = BrainDeadProxyFactory.createBrainDeadProxyFor(Account.class);
+
+ Account account = BrainDeadProxyFactory.createBrainDeadProxyFor(Account.class);
((ZombieControl)account).addResult("getBillCycleDay", 1).addResult("getTimeZone", DateTimeZone.UTC);
-
- AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
+
+ AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
((ZombieControl)accountApi).addResult("getAccountById", account);
-
+
DefaultEntitlementBillingApi api = new DefaultEntitlementBillingApi(dao,accountApi,catalogService);
SortedSet<BillingEvent> events = api.getBillingEventsForAccount(new UUID(0L,0L));
checkFirstEvent(events, nextPlan, subscription.getStartDate().getDayOfMonth(), oneId, now, nextPhase, ApiEventType.CREATE.toString());
}
-
+
@Test(enabled=true, groups="fast")
public void testBillingEventsMonthly() throws CatalogApiException {
DateTime now = clock.getUTCNow();
@@ -217,7 +223,7 @@ public class TestDefaultEntitlementBillingApi {
SubscriptionTransition t = new SubscriptionTransitionData(
zeroId, oneId, twoId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList);
transitions.add(t);
-
+
AccountUserApi accountApi = new BrainDeadAccountUserApi(){
@Override
@@ -231,7 +237,7 @@ public class TestDefaultEntitlementBillingApi {
SortedSet<BillingEvent> events = api.getBillingEventsForAccount(new UUID(0L,0L));
checkFirstEvent(events, nextPlan, 32, oneId, now, nextPhase, ApiEventType.CREATE.toString());
}
-
+
@Test(enabled=true, groups="fast")
public void testBillingEventsAddOn() throws CatalogApiException {
DateTime now = clock.getUTCNow();
@@ -242,13 +248,13 @@ public class TestDefaultEntitlementBillingApi {
SubscriptionTransition t = new SubscriptionTransitionData(
zeroId, oneId, twoId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList);
transitions.add(t);
-
- Account account = BrainDeadProxyFactory.createBrainDeadProxyFor(Account.class);
+
+ Account account = BrainDeadProxyFactory.createBrainDeadProxyFor(Account.class);
((ZombieControl)account).addResult("getBillCycleDay", 1).addResult("getTimeZone", DateTimeZone.UTC);
-
- AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
+
+ AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
((ZombieControl)accountApi).addResult("getAccountById", account);
-
+
DefaultEntitlementBillingApi api = new DefaultEntitlementBillingApi(dao,accountApi,catalogService);
SortedSet<BillingEvent> events = api.getBillingEventsForAccount(new UUID(0L,0L));
checkFirstEvent(events, nextPlan, bundles.get(0).getStartDate().getDayOfMonth(), oneId, now, nextPhase, ApiEventType.CREATE.toString());
@@ -265,7 +271,7 @@ public class TestDefaultEntitlementBillingApi {
if(nextPhase.getRecurringPrice() != null) {
Assert.assertEquals(nextPhase.getRecurringPrice().getPrice(Currency.USD), event.getRecurringPrice().getPrice(Currency.USD));
}
-
+
Assert.assertEquals(BCD, event.getBillCycleDay());
Assert.assertEquals(id, event.getSubscription().getId());
Assert.assertEquals(time, event.getEffectiveDate());
@@ -277,6 +283,6 @@ public class TestDefaultEntitlementBillingApi {
Assert.assertEquals(nextPhase.getFixedPrice(), event.getFixedPrice());
Assert.assertEquals(nextPhase.getRecurringPrice(), event.getRecurringPrice());
}
-
-
+
+
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java
index b7e83bc..84744d8 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java
@@ -31,31 +31,31 @@ public class TestMigrationSql extends TestMigration {
}
@Override
- @Test(enabled=true, groups="sql")
+ @Test(enabled=true, groups="slow")
public void testSingleBasePlan() {
super.testSingleBasePlan();
}
@Override
- @Test(enabled=true, groups="sql")
+ @Test(enabled=true, groups="slow")
public void testPlanWithAddOn() {
super.testPlanWithAddOn();
}
@Override
- @Test(enabled=true, groups="sql")
+ @Test(enabled=true, groups="slow")
public void testSingleBasePlanFutureCancelled() {
super.testSingleBasePlanFutureCancelled();
}
@Override
- @Test(enabled=true, groups="sql")
+ @Test(enabled=true, groups="slow")
public void testSingleBasePlanWithPendingPhase() {
super.testSingleBasePlanWithPendingPhase();
}
@Override
- @Test(enabled=true, groups="sql")
+ @Test(enabled=true, groups="slow")
public void testSingleBasePlanWithPendingChange() {
super.testSingleBasePlanWithPendingChange();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
index da06cb5..094faba 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
@@ -26,6 +26,7 @@ import java.net.URL;
import java.util.List;
import java.util.UUID;
+import org.apache.commons.io.IOUtils;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.slf4j.Logger;
@@ -33,8 +34,10 @@ import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
import com.google.inject.Injector;
import com.ning.billing.account.api.AccountData;
@@ -49,6 +52,7 @@ import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.catalog.api.TimeUnit;
import com.ning.billing.config.EntitlementConfig;
+import com.ning.billing.dbi.MysqlTestingHelper;
import com.ning.billing.entitlement.api.ApiTestListener.NextEvent;
import com.ning.billing.entitlement.api.billing.EntitlementBillingApi;
import com.ning.billing.entitlement.api.migration.EntitlementMigrationApi;
@@ -60,11 +64,11 @@ import com.ning.billing.entitlement.api.user.SubscriptionTransition;
import com.ning.billing.entitlement.engine.core.Engine;
import com.ning.billing.entitlement.engine.dao.EntitlementDao;
import com.ning.billing.entitlement.engine.dao.MockEntitlementDao;
+import com.ning.billing.entitlement.engine.dao.MockEntitlementDaoMemory;
import com.ning.billing.entitlement.events.EntitlementEvent;
import com.ning.billing.entitlement.events.phase.PhaseEvent;
import com.ning.billing.entitlement.events.user.ApiEvent;
import com.ning.billing.entitlement.events.user.ApiEventType;
-import com.ning.billing.lifecycle.KillbillService.ServiceException;
import com.ning.billing.util.clock.Clock;
import com.ning.billing.util.clock.ClockMock;
import com.ning.billing.util.bus.DefaultBusService;
@@ -94,8 +98,9 @@ public abstract class TestApiBase {
protected ApiTestListener testListener;
protected SubscriptionBundle bundle;
- public static void loadSystemPropertiesFromClasspath(final String resource)
- {
+ private MysqlTestingHelper helper;
+
+ public static void loadSystemPropertiesFromClasspath(final String resource) {
final URL url = TestApiBase.class.getResource(resource);
assertNotNull(url);
@@ -106,7 +111,9 @@ public abstract class TestApiBase {
}
}
- @AfterClass(groups={"setup"})
+ protected abstract Injector getInjector();
+
+ @AfterClass(alwaysRun=true)
public void tearDown() {
try {
busService.getBus().register(testListener);
@@ -117,7 +124,7 @@ public abstract class TestApiBase {
}
- @BeforeClass(groups={"setup"})
+ @BeforeClass(alwaysRun=true)
public void setup() {
loadSystemPropertiesFromClasspath("/entitlement.properties");
@@ -129,21 +136,35 @@ public abstract class TestApiBase {
config = g.getInstance(EntitlementConfig.class);
dao = g.getInstance(EntitlementDao.class);
clock = (ClockMock) g.getInstance(Clock.class);
+ helper = (isSqlTest(dao)) ? g.getInstance(MysqlTestingHelper.class) : null;
+
try {
((DefaultCatalogService) catalogService).loadCatalog();
((DefaultBusService) busService).startBus();
((Engine) entitlementService).initialize();
init();
- } catch (EntitlementUserApiException e) {
- Assert.fail(e.getMessage());
- } catch (ServiceException e) {
- Assert.fail(e.getMessage());
+ } catch (Exception e) {
}
}
- protected abstract Injector getInjector();
+ private static boolean isSqlTest(EntitlementDao theDao) {
+ return (! (theDao instanceof MockEntitlementDaoMemory));
+ }
+
+ private void setupMySQL() throws IOException {
+ if (helper != null) {
+ final String entitlementDdl = IOUtils.toString(TestApiBase.class.getResourceAsStream("/com/ning/billing/entitlement/ddl.sql"));
+ final String utilDdl = IOUtils.toString(TestApiBase.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
+ helper.startMysql();
+ helper.initDb(entitlementDdl);
+ helper.initDb(utilDdl);
+ }
+ }
+
+ private void init() throws Exception {
+
+ setupMySQL();
- private void init() throws EntitlementUserApiException {
accountData = getAccountData();
assertNotNull(accountData);
@@ -155,10 +176,9 @@ public abstract class TestApiBase {
entitlementApi = entitlementService.getUserApi();
billingApi = entitlementService.getBillingApi();
migrationApi = entitlementService.getMigrationApi();
-
}
- @BeforeMethod(groups={"setup"})
+ @BeforeMethod(alwaysRun=true)
public void setupTest() {
log.warn("\n");
@@ -180,7 +200,7 @@ public abstract class TestApiBase {
((Engine)entitlementService).start();
}
- @AfterMethod(groups={"setup"})
+ @AfterMethod(alwaysRun=true)
public void cleanupTest() {
((Engine)entitlementService).stop();
log.warn("DONE WITH TEST\n");
@@ -345,12 +365,12 @@ public abstract class TestApiBase {
@Override
public String getAddress1() {
- return null;
+ return null;
}
@Override
public String getAddress2() {
- return null;
+ return null;
}
@Override
@@ -360,22 +380,22 @@ public abstract class TestApiBase {
@Override
public String getCity() {
- return null;
+ return null;
}
@Override
public String getStateOrProvince() {
- return null;
+ return null;
}
@Override
public String getPostalCode() {
- return null;
+ return null;
}
@Override
public String getCountry() {
- return null;
+ return null;
}
};
return accountData;
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java
index 71f2bb9..a5b0142 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java
@@ -53,7 +53,38 @@ public class TestUserApiAddOn extends TestApiBase {
}
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
+ public void testCreateCancelAddon() {
+
+ try {
+ String baseProduct = "Shotgun";
+ BillingPeriod baseTerm = BillingPeriod.MONTHLY;
+ String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
+
+ SubscriptionData baseSubscription = createSubscription(baseProduct, baseTerm, basePriceList);
+
+ String aoProduct = "Telescopic-Scope";
+ BillingPeriod aoTerm = BillingPeriod.MONTHLY;
+ String aoPriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
+
+ SubscriptionData aoSubscription = createSubscription(aoProduct, aoTerm, aoPriceList);
+ assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
+
+ DateTime now = clock.getUTCNow();
+ aoSubscription.cancel(now, false);
+
+ testListener.reset();
+ testListener.pushExpectedEvent(NextEvent.CANCEL);
+ assertTrue(testListener.isCompleted(5000));
+
+ assertEquals(aoSubscription.getState(), SubscriptionState.CANCELLED);
+
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test(enabled=true, groups={"slow"})
public void testCancelBPWthAddon() {
try {
@@ -111,7 +142,7 @@ public class TestUserApiAddOn extends TestApiBase {
}
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testChangeBPWthAddonNonIncluded() {
try {
@@ -164,7 +195,7 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testChangeBPWthAddonNonAvailable() {
try {
@@ -228,7 +259,7 @@ public class TestUserApiAddOn extends TestApiBase {
}
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testAddonCreateWithBundleAlign() {
try {
String aoProduct = "Telescopic-Scope";
@@ -250,7 +281,7 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testAddonCreateWithSubscriptionAlign() {
try {
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java
index 840f357..469d374 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java
@@ -49,25 +49,25 @@ public class TestUserApiCancelSql extends TestUserApiCancel {
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testCancelSubscriptionIMM() {
super.testCancelSubscriptionIMM();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testCancelSubscriptionEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testCancelSubscriptionEOTWithChargeThroughDate();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testCancelSubscriptionEOTWithNoChargeThroughDate() {
super.testCancelSubscriptionEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testUncancel() throws EntitlementBillingApiException {
super.testUncancel();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java
index ad0235f..735099c 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java
@@ -54,44 +54,44 @@ public class TestUserApiChangePlanSql extends TestUserApiChangePlan {
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testCorrectPhaseAlignmentOnChange() {
super.testCorrectPhaseAlignmentOnChange();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
super.testChangePlanBundleAlignEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testChangePlanBundleAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanBundleAlignEOTWithChargeThroughDate();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testChangePlanBundleAlignIMM() {
super.testChangePlanBundleAlignIMM();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testMultipleChangeLastIMM() throws EntitlementBillingApiException {
super.testMultipleChangeLastIMM();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testMultipleChangeLastEOT() throws EntitlementBillingApiException {
super.testMultipleChangeLastEOT();
}
// rescue not implemented yet
@Override
- @Test(enabled=false, groups={"sql"})
+ @Test(enabled=false, groups={"slow"})
public void testChangePlanChangePlanAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanChangePlanAlignEOTWithChargeThroughDate();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java
index 8170b6d..6820fec 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java
@@ -30,31 +30,31 @@ public class TestUserApiCreateSql extends TestUserApiCreate {
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testCreateWithRequestedDate() {
super.testCreateWithRequestedDate();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testCreateWithInitialPhase() {
super.testCreateWithInitialPhase();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
public void testSimpleCreateSubscription() {
super.testSimpleCreateSubscription();
}
@Override
- @Test(enabled=true, groups={"sql"})
+ @Test(enabled=true, groups={"slow"})
protected void testSimpleSubscriptionThroughPhases() {
super.testSimpleSubscriptionThroughPhases();
}
@Override
- @Test(enabled=false, groups={"sql"})
+ @Test(enabled=false, groups={"slow"})
protected void testSubscriptionWithAddOn() {
super.testSubscriptionWithAddOn();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java
index e9e6134..c452c3b 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java
@@ -18,6 +18,7 @@ package com.ning.billing.entitlement.glue;
import com.ning.billing.dbi.DBIProvider;
import com.ning.billing.dbi.DbiConfig;
+import com.ning.billing.dbi.MysqlTestingHelper;
import com.ning.billing.entitlement.engine.dao.EntitlementDao;
import com.ning.billing.entitlement.engine.dao.MockEntitlementDaoSql;
import com.ning.billing.util.clock.Clock;
@@ -36,9 +37,16 @@ public class MockEngineModuleSql extends MockEngineModule {
}
protected void installDBI() {
- bind(IDBI.class).toProvider(DBIProvider.class).asEagerSingleton();
- final DbiConfig config = new ConfigurationObjectFactory(System.getProperties()).build(DbiConfig.class);
- bind(DbiConfig.class).toInstance(config);
+ final MysqlTestingHelper helper = new MysqlTestingHelper();
+ bind(MysqlTestingHelper.class).toInstance(helper);
+ if (helper.isUsingLocalInstance()) {
+ bind(IDBI.class).toProvider(DBIProvider.class).asEagerSingleton();
+ final DbiConfig config = new ConfigurationObjectFactory(System.getProperties()).build(DbiConfig.class);
+ bind(DbiConfig.class).toInstance(config);
+ } else {
+ final IDBI dbi = helper.getDBI();
+ bind(IDBI.class).toInstance(dbi);
+ }
}
@Override