killbill-memoizeit

Fix unit tests

12/22/2011 8:11:57 PM

Details

diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java
index ef01b80..1116eed 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java
@@ -54,7 +54,7 @@ import com.ning.billing.entitlement.glue.MockEngineModuleSql;
 public abstract class TestMigration extends TestApiBase {
 
 
-    public void testSingleBasePlanReal() {
+    public void testSingleBasePlan() {
 
         try {
             DateTime beforeMigration = clock.getUTCNow();
@@ -84,7 +84,7 @@ public abstract class TestMigration extends TestApiBase {
     }
 
 
-    public void testSingleBasePlanFutureCancelledReal() {
+    public void testSingleBasePlanFutureCancelled() {
 
         try {
 
@@ -128,7 +128,7 @@ public abstract class TestMigration extends TestApiBase {
         }
     }
 
-    public void testSingleBasePlanWithPendingPhaseReal() {
+    public void testSingleBasePlanWithPendingPhase() {
 
         try {
             DateTime beforeMigration = clock.getUTCNow();
@@ -172,7 +172,7 @@ public abstract class TestMigration extends TestApiBase {
     }
 
 
-    public void testSingleBasePlanWithPendingChangeReal() {
+    public void testSingleBasePlanWithPendingChange() {
 
         try {
             DateTime beforeMigration = clock.getUTCNow();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java
index 28a5ce0..e3fc9be 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java
@@ -29,23 +29,27 @@ public class TestMigrationMemory extends TestMigration {
         return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleMemory());
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlan() {
-        invokeRealMethod(this);
+        super.testSingleBasePlan();
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlanFutureCancelled() {
-        invokeRealMethod(this);
+        super.testSingleBasePlanFutureCancelled();
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlanWithPendingPhase() {
-        invokeRealMethod(this);
+        super.testSingleBasePlanWithPendingPhase();
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlanWithPendingChange() {
-        invokeRealMethod(this);
+        super.testSingleBasePlanWithPendingChange();
     }
 }
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 2329f3d..b3eb168 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
@@ -30,23 +30,27 @@ public class TestMigrationSql extends TestMigration {
         return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlan() {
-        invokeRealMethod(this);
+        super.testSingleBasePlan();
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlanFutureCancelled() {
-        invokeRealMethod(this);
+        super.testSingleBasePlanFutureCancelled();
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlanWithPendingPhase() {
-        invokeRealMethod(this);
+        super.testSingleBasePlanWithPendingPhase();
     }
 
+    @Override
     @Test(enabled=true, groups="sql")
     public void testSingleBasePlanWithPendingChange() {
-        invokeRealMethod(this);
+        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 21bbf77..377204c 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
@@ -177,28 +177,6 @@ public abstract class TestApiBase {
         log.warn("DONE WITH TEST\n");
     }
 
-    // Glue magic to invoke the real test
-    protected void invokeRealMethod(Object invoker)  {
-
-        try {
-            String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
-            String realMethodName= methodName + "Real";
-
-            Class<?> thisClass = invoker.getClass();
-            Class<?> superClass = thisClass.getSuperclass();
-            Method [] methods = superClass.getDeclaredMethods();
-            for (Method cur : methods) {
-                if (cur.getName().equals(realMethodName)) {
-                    cur.invoke(invoker);
-                    return;
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            Assert.fail(e.getMessage());
-        }
-    }
-
     protected SubscriptionData createSubscription(final String productName, final BillingPeriod term, final String planSet) throws EntitlementUserApiException {
         testListener.pushExpectedEvent(NextEvent.CREATE);
         SubscriptionData subscription = (SubscriptionData) entitlementApi.createSubscription(bundle.getId(),
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
index 4691404..6e89835 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
@@ -38,7 +38,7 @@ import com.ning.billing.util.clock.DefaultClock;
 
 public abstract class TestUserApiCancel extends TestApiBase {
 
-    protected void testCancelSubscriptionIMMReal() {
+    protected void testCancelSubscriptionIMM() {
 
         log.info("Starting testCancelSubscriptionIMM");
 
@@ -80,7 +80,7 @@ public abstract class TestUserApiCancel extends TestApiBase {
     }
 
 
-    protected void testCancelSubscriptionEOTWithChargeThroughDateReal() {
+    protected void testCancelSubscriptionEOTWithChargeThroughDate() {
         log.info("Starting testCancelSubscriptionEOTWithChargeThroughDate");
 
         try {
@@ -132,7 +132,7 @@ public abstract class TestUserApiCancel extends TestApiBase {
     }
 
 
-    protected void testCancelSubscriptionEOTWithNoChargeThroughDateReal() {
+    protected void testCancelSubscriptionEOTWithNoChargeThroughDate() {
 
         log.info("Starting testCancelSubscriptionEOTWithNoChargeThroughDate");
 
@@ -176,7 +176,7 @@ public abstract class TestUserApiCancel extends TestApiBase {
     // Similar test to testCancelSubscriptionEOTWithChargeThroughDate except we uncancel and check things
     // are as they used to be and we can move forward without hitting cancellation
     //
-    protected void testUncancelReal() {
+    protected void testUncancel() {
 
         log.info("Starting testUncancel");
 
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
index 66cd35a..0bf4019 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
@@ -31,23 +31,27 @@ public class TestUserApiCancelMemory extends TestUserApiCancel {
         return Guice.createInjector(Stage.PRODUCTION, new MockEngineModuleMemory());
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testCancelSubscriptionIMM() {
-        invokeRealMethod(this);
+        super.testCancelSubscriptionIMM();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testCancelSubscriptionEOTWithChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testCancelSubscriptionEOTWithChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testCancelSubscriptionEOTWithNoChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testCancelSubscriptionEOTWithNoChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testUncancel() {
-        invokeRealMethod(this);
+        super.testUncancel();
     }
 }
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 83d4d8e..0afab7c 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
@@ -48,24 +48,28 @@ public class TestUserApiCancelSql extends TestUserApiCancel {
         }
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testCancelSubscriptionIMM() {
-        invokeRealMethod(this);
+        super.testCancelSubscriptionIMM();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testCancelSubscriptionEOTWithChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testCancelSubscriptionEOTWithChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testCancelSubscriptionEOTWithNoChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testCancelSubscriptionEOTWithNoChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testUncancel() {
-        invokeRealMethod(this);
+        super.testUncancel();
     }
 
 }
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
index dfa2bc7..2ebff8e 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
@@ -60,7 +60,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
 
 
 
-    protected void testChangePlanBundleAlignEOTWithNoChargeThroughDateReal() {
+    protected void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
         tChangePlanBundleAlignEOTWithNoChargeThroughDate("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
     }
 
@@ -99,7 +99,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
     }
 
 
-    protected void testChangePlanBundleAlignEOTWithChargeThroughDateReal() {
+    protected void testChangePlanBundleAlignEOTWithChargeThroughDate() {
         testChangePlanBundleAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, "gunclubDiscount", "Pistol", BillingPeriod.ANNUAL, "gunclubDiscount");
     }
 
@@ -164,7 +164,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
     }
 
 
-    protected void testChangePlanBundleAlignIMMReal() {
+    protected void testChangePlanBundleAlignIMM() {
         tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
     }
 
@@ -206,7 +206,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
     }
 
 
-    protected void testChangePlanChangePlanAlignEOTWithChargeThroughDateReal() {
+    protected void testChangePlanChangePlanAlignEOTWithChargeThroughDate() {
         tChangePlanChangePlanAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.ANNUAL, "rescue");
     }
 
@@ -287,7 +287,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
         }
     }
 
-    protected void testMultipleChangeLastIMMReal() {
+    protected void testMultipleChangeLastIMM() {
 
         try {
             SubscriptionData subscription = createSubscription("Assault-Rifle", BillingPeriod.MONTHLY, "gunclubDiscount");
@@ -334,7 +334,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
         }
     }
 
-    protected void testMultipleChangeLastEOTReal() {
+    protected void testMultipleChangeLastEOT() {
 
         try {
 
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
index 341b9b6..cdbb774 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
@@ -31,35 +31,40 @@ public class TestUserApiChangePlanMemory extends TestUserApiChangePlan {
     }
 
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
-        invokeRealMethod(this);
+         super.testChangePlanBundleAlignEOTWithNoChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testChangePlanBundleAlignEOTWithChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testChangePlanBundleAlignEOTWithChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testChangePlanBundleAlignIMM() {
-        invokeRealMethod(this);
+        super.testChangePlanBundleAlignIMM();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testMultipleChangeLastIMM() {
-        invokeRealMethod(this);
+        super.testMultipleChangeLastIMM();
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testMultipleChangeLastEOT() {
-        invokeRealMethod(this);
+        super.testMultipleChangeLastEOT();
     }
 
     // Set to false until we implement rescue example.
+    @Override
     @Test(enabled=false, groups={"fast"})
     public void testChangePlanChangePlanAlignEOTWithChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testChangePlanChangePlanAlignEOTWithChargeThroughDate();
     }
-
 }
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 2ccf83f..fe64461 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
@@ -53,35 +53,41 @@ public class TestUserApiChangePlanSql extends TestUserApiChangePlan {
         }
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testChangePlanBundleAlignEOTWithNoChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testChangePlanBundleAlignEOTWithChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testChangePlanBundleAlignEOTWithChargeThroughDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testChangePlanBundleAlignIMM() {
-        invokeRealMethod(this);
+        super.testChangePlanBundleAlignIMM();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testMultipleChangeLastIMM() {
-        invokeRealMethod(this);
+        super.testMultipleChangeLastIMM();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testMultipleChangeLastEOT() {
-        invokeRealMethod(this);
+        super.testMultipleChangeLastEOT();
     }
 
     // rescue not implemented yet
+    @Override
     @Test(enabled=false, groups={"sql"})
     public void testChangePlanChangePlanAlignEOTWithChargeThroughDate() {
-        invokeRealMethod(this);
+        super.testChangePlanChangePlanAlignEOTWithChargeThroughDate();
     }
 
 }
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
index de1dbf9..d88f177 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.joda.time.DateTime;
 import org.testng.Assert;
+import org.testng.annotations.Test;
 
 import com.ning.billing.catalog.api.BillingPeriod;
 import com.ning.billing.catalog.api.Plan;
@@ -40,8 +41,7 @@ import com.ning.billing.util.clock.DefaultClock;
 public abstract class TestUserApiCreate extends TestApiBase {
 
 
-
-    protected void testCreateWithRequestedDateReal() {
+    public void testCreateWithRequestedDate() {
         log.info("Starting testCreateWithRequestedDate");
         try {
 
@@ -73,7 +73,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
         }
     }
 
-    protected void testCreateWithInitialPhaseReal() {
+    protected void testCreateWithInitialPhase() {
         log.info("Starting testCreateWithInitialPhase");
         try {
 
@@ -113,7 +113,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
         }
     }
 
-    protected void testSimpleCreateSubscriptionReal() {
+    protected void testSimpleCreateSubscription() {
 
         log.info("Starting testSimpleCreateSubscription");
         try {
@@ -179,7 +179,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
     }
 
 
-    protected void testSimpleSubscriptionThroughPhasesReal() {
+    protected void testSimpleSubscriptionThroughPhases() {
 
         log.info("Starting testSimpleSubscriptionThroughPhases");
         try {
@@ -230,7 +230,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
         }
     }
 
-    protected void testSubscriptionWithAddOnReal() {
+    protected void testSubscriptionWithAddOn() {
 
         log.info("Starting testSubscriptionWithAddOn");
         try {
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
index d8a86c3..7fcbee3 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
@@ -31,29 +31,30 @@ public class TestUserApiCreateMemory extends TestUserApiCreate {
         return Guice.createInjector(Stage.PRODUCTION, new MockEngineModuleMemory());
     }
 
+    @Override
     @Test(enabled=true, groups={"fast"})
     public void testCreateWithRequestedDate() {
-        invokeRealMethod(this);
+        super.testCreateWithRequestedDate();
     }
 
     @Test(enabled=true, groups={"fast"})
     public void testCreateWithInitialPhase() {
-        invokeRealMethod(this);
+        super.testSimpleSubscriptionThroughPhases();
     }
 
     @Test(enabled=true, groups={"fast"})
     public void testSimpleCreateSubscription() {
-        invokeRealMethod(this);
+        super.testSimpleCreateSubscription();
     }
 
     @Test(enabled=true, groups={"fast"})
     protected void testSimpleSubscriptionThroughPhases() {
-        invokeRealMethod(this);
+        super.testSimpleSubscriptionThroughPhases();
     }
 
     @Test(enabled=false, groups={"fast"})
     protected void testSubscriptionWithAddOn() {
-        invokeRealMethod(this);
+        super.testSubscriptionWithAddOn();
     }
 
 }
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 3ff899b..824558d 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,29 +30,34 @@ public class TestUserApiCreateSql extends TestUserApiCreate {
         return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testCreateWithRequestedDate() {
-        invokeRealMethod(this);
+        super.testCreateWithRequestedDate();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testCreateWithInitialPhase() {
-        invokeRealMethod(this);
+        super.testCreateWithInitialPhase();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     public void testSimpleCreateSubscription() {
-        invokeRealMethod(this);
+        super.testSimpleCreateSubscription();
     }
 
+    @Override
     @Test(enabled=true, groups={"sql"})
     protected void testSimpleSubscriptionThroughPhases() {
-        invokeRealMethod(this);
+        super.testSimpleSubscriptionThroughPhases();
     }
 
+    @Override
     @Test(enabled=false, groups={"sql"})
     protected void testSubscriptionWithAddOn() {
-        invokeRealMethod(this);
+        super.testSubscriptionWithAddOn();
     }
 
 }