]> WPIA git - gigi.git/commitdiff
There is a test case that needs cache punging.
authorFelix Dörre <felix@dogcraft.de>
Thu, 4 Sep 2014 12:39:17 +0000 (14:39 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 4 Sep 2014 12:39:17 +0000 (14:39 +0200)
src/org/cacert/gigi/dbObjects/ObjectCache.java
tests/org/cacert/gigi/pages/account/TestMailManagement.java

index 5f44542200458467c535b959266dde527e4a098b..e06f84f84a57fd0fde3bafe5d8066b9d6efc08d0 100644 (file)
@@ -2,11 +2,18 @@ package org.cacert.gigi.dbObjects;
 
 import java.lang.ref.WeakReference;
 import java.util.HashMap;
+import java.util.HashSet;
 
 public class ObjectCache<T extends IdCachable> {
 
     HashMap<Integer, WeakReference<T>> hashmap = new HashMap<>();
 
+    private static HashSet<ObjectCache<?>> caches = new HashSet<>();
+
+    protected ObjectCache() {
+        caches.add(this);
+    }
+
     public void put(T c) {
         hashmap.put(c.getId(), new WeakReference<T>(c));
     }
@@ -18,4 +25,10 @@ public class ObjectCache<T extends IdCachable> {
         }
         return null;
     }
+
+    public static void clearAllCashes() {
+        for (ObjectCache<?> objectCache : caches) {
+            objectCache.hashmap.clear();
+        }
+    }
 }
index 6b213b45c4026051cc9ead129df1f14f1617023f..079b2d0425fb01561324b7b114430fc0f24ed7f4 100644 (file)
@@ -10,6 +10,7 @@ import java.util.Locale;
 
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.EmailAddress;
+import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.testUtils.ManagedTest;
@@ -70,6 +71,7 @@ public class TestMailManagement extends ManagedTest {
 
     @Test
     public void testMailSetDefaultWeb() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
+        ObjectCache.clearAllCashes();
         EmailAddress adrr = createVerifiedEmail(u);
         assertNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId()));
         assertEquals(User.getById(u.getId()).getEmail(), adrr.getAddress());