From: Felix Dörre Date: Thu, 4 Sep 2014 12:39:17 +0000 (+0200) Subject: There is a test case that needs cache punging. X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=8989aa1f0dca5ed1b6ef8ba5f786f5192f8bf950 There is a test case that needs cache punging. --- diff --git a/src/org/cacert/gigi/dbObjects/ObjectCache.java b/src/org/cacert/gigi/dbObjects/ObjectCache.java index 5f445422..e06f84f8 100644 --- a/src/org/cacert/gigi/dbObjects/ObjectCache.java +++ b/src/org/cacert/gigi/dbObjects/ObjectCache.java @@ -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 { HashMap> hashmap = new HashMap<>(); + private static HashSet> caches = new HashSet<>(); + + protected ObjectCache() { + caches.add(this); + } + public void put(T c) { hashmap.put(c.getId(), new WeakReference(c)); } @@ -18,4 +25,10 @@ public class ObjectCache { } return null; } + + public static void clearAllCashes() { + for (ObjectCache objectCache : caches) { + objectCache.hashmap.clear(); + } + } } diff --git a/tests/org/cacert/gigi/pages/account/TestMailManagement.java b/tests/org/cacert/gigi/pages/account/TestMailManagement.java index 6b213b45..079b2d04 100644 --- a/tests/org/cacert/gigi/pages/account/TestMailManagement.java +++ b/tests/org/cacert/gigi/pages/account/TestMailManagement.java @@ -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());