killbill-memoizeit

Details

pom.xml 2(+1 -1)

diff --git a/pom.xml b/pom.xml
index 12119d8..03d6a18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
     <parent>
         <artifactId>killbill-oss-parent</artifactId>
         <groupId>org.kill-bill.billing</groupId>
-        <version>0.123</version>
+        <version>0.124-SNAPSHOT</version>
     </parent>
     <artifactId>killbill</artifactId>
     <version>0.17.3-SNAPSHOT</version>
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestCache.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestCache.java
new file mode 100644
index 0000000..ac13ab8
--- /dev/null
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestCache.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 The Billing Project, LLC
+ *
+ * The Billing Project 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 org.killbill.billing.jaxrs;
+
+import org.killbill.billing.util.cache.Cachable.CacheType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.sf.ehcache.Ehcache;
+
+public class TestCache extends TestJaxrsBase {
+
+    @Test(groups = "slow", description = "Can Invalidate (clear) a Cache by name")
+    public void testInvalidateCacheByName() throws Exception {
+        // get Ehcache item with name "record-id"
+        final Ehcache cache = cacheManager.getEhcache(CacheType.RECORD_ID.getCacheName());
+        // verify that it is not null and has one stored key (the default tenant created for all integration tests)
+        Assert.assertNotNull(cache);
+        Assert.assertEquals(cache.getSize(), 1);
+
+        // invalidate the specified cache
+        killBillClient.invalidateCache(cache.getName(), requestOptions);
+
+        // verify that now the cache is empty and has no keys stored
+        Assert.assertEquals(cache.getSize(), 0);
+    }
+}
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java
index 3498ba8..d4ec7bf 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java
@@ -74,6 +74,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
+import net.sf.ehcache.CacheManager;
 
 public class TestJaxrsBase extends KillbillClient {
 
@@ -106,6 +107,9 @@ public class TestJaxrsBase extends KillbillClient {
     @Inject
     protected TenantCacheInvalidation tenantCacheInvalidation;
 
+    @Inject
+    protected CacheManager cacheManager;
+
     protected DaoConfig daoConfig;
     protected KillbillServerConfig serverConfig;