james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [20/22] james-project git commit: JAMES-2595 clear Spamassasin user afterEach
Date Wed, 21 Nov 2018 10:07:30 GMT
JAMES-2595 clear Spamassasin user afterEach


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/14c91282
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/14c91282
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/14c91282

Branch: refs/heads/master
Commit: 14c9128291999051b96b1b5f17d07f08ff5cc0b9
Parents: 0a6a060
Author: tran tien duc <dtran@linagora.com>
Authored: Tue Nov 20 11:04:14 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Nov 21 16:50:59 2018 +0700

----------------------------------------------------------------------
 .../integration/SpamAssassinContract.java       |  6 ++++++
 .../spamassassin/SpamAssassinExtension.java     | 22 ++++++++------------
 2 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/14c91282/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
index b28044d..321b1dc 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
@@ -44,6 +44,7 @@ import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.IMAPMessageReader;
 import org.apache.james.utils.JmapGuiceProbe;
 import org.awaitility.Duration;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -82,6 +83,11 @@ public interface SpamAssassinContract {
             .addUser(PAUL, PAUL_PASSWORD);
     }
 
+    @AfterEach
+    default void tearDown(SpamAssassinExtension.SpamAssassin spamAssassin) throws Exception
{
+        spamAssassin.clear(ALICE);
+    }
+
     default AccessToken accessTokenFor(GuiceJamesServer james, String user, String password)
{
         return authenticateJamesUser(baseUri(james), user, password);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/14c91282/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
----------------------------------------------------------------------
diff --git a/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
b/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
index fa46e52..e357228 100644
--- a/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
+++ b/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
@@ -61,7 +61,8 @@ public class SpamAssassinExtension implements BeforeAllCallback, AfterEachCallba
 
     @Override
     public void beforeAll(ExtensionContext context) {
-        start();
+        spamAssassinContainer.start();
+        spamAssassin = new SpamAssassin(spamAssassinContainer);
     }
 
     @Override
@@ -71,15 +72,10 @@ public class SpamAssassinExtension implements BeforeAllCallback, AfterEachCallba
 
     @Override
     public void afterAll(ExtensionContext context) {
-        stop();
-    }
-
-    public void start() {
-        spamAssassinContainer.start();
-        spamAssassin = new SpamAssassin(spamAssassinContainer);
+        spamAssassinContainer.close();
     }
 
-    public void clearSpamAssassinDatabase() {
+    private void clearSpamAssassinDatabase() {
         try {
             spamAssassin.clearSpamAssassinDatabase();
         } catch (IOException | InterruptedException e) {
@@ -87,10 +83,6 @@ public class SpamAssassinExtension implements BeforeAllCallback, AfterEachCallba
         }
     }
 
-    public void stop() {
-        spamAssassinContainer.close();
-    }
-
     @Override
     public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext
extensionContext) throws ParameterResolutionException {
         return (parameterContext.getParameter().getType() == SpamAssassin.class);
@@ -169,8 +161,12 @@ public class SpamAssassinExtension implements BeforeAllCallback, AfterEachCallba
             spamAssassinContainer.execInContainer("sa-learn", "--dump", "magic", "-u", user);
         }
 
+        public void clear(String user) throws UnsupportedOperationException, IOException,
InterruptedException {
+            spamAssassinContainer.execInContainer("sa-learn", "--clear", "-u", user);
+        }
+
         public void clearSpamAssassinDatabase() throws UnsupportedOperationException, IOException,
InterruptedException {
-            spamAssassinContainer.execInContainer("sa-learn", "--dump", "magic");
+            spamAssassinContainer.execInContainer("sa-learn", "--clear");
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message