JAMES-2341 Provide an integration test for SpamAssassin learning

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

Branch: refs/heads/master
Commit: 37435eeef73afe175df7030aac6292f809dfb6e3
Parents: 697a532
Author: benwa <[email protected]>
Authored: Tue Mar 6 09:35:31 2018 +0700
Committer: Antoine Duprat <[email protected]>
Committed: Thu Mar 8 10:36:34 2018 +0100

----------------------------------------------------------------------
 .../util/scanner/SpamAssassinExtension.java     |  18 +-
 .../src/test/resources/mailetcontainer.xml      |   8 +
 .../jmap-integration-testing-common/pom.xml     |  31 ++-
 .../integration/JamesWithSpamAssassin.java      |  41 ++++
 .../integration/SpamAssassinContract.java       | 218 +++++++++++++++++++
 .../SpamAssassinGuiceMailetLoader.java          |  87 ++++++++
 .../methods/integration/SpamAssassinModule.java |  60 +++++
 .../src/test/resources/spamassassin_db/ham/ham1 | 113 ++++++++++
 .../src/test/resources/spamassassin_db/ham/ham2 |  73 +++++++
 .../src/test/resources/spamassassin_db/ham/ham3 |  82 +++++++
 .../test/resources/spamassassin_db/spam/spam1   | 108 +++++++++
 .../test/resources/spamassassin_db/spam/spam2   | 186 ++++++++++++++++
 .../test/resources/spamassassin_db/spam/spam3   | 211 ++++++++++++++++++
 .../memory-jmap-integration-testing/pom.xml     |  31 ++-
 .../james/jmap/memory/MemoryJmapExtension.java  | 100 +++++++++
 .../jmap/memory/MemorySpamAssassinContract.java |  27 +++
 .../src/test/resources/mailetcontainer.xml      |  10 +-
 .../src/test/resources/spamassassin_db          |   1 +
 18 files changed, 1384 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/container/util/src/test/java/org/apache/james/util/scanner/SpamAssassinExtension.java
----------------------------------------------------------------------
diff --git 
a/server/container/util/src/test/java/org/apache/james/util/scanner/SpamAssassinExtension.java
 
b/server/container/util/src/test/java/org/apache/james/util/scanner/SpamAssassinExtension.java
index e161804..9d5c3f9 100644
--- 
a/server/container/util/src/test/java/org/apache/james/util/scanner/SpamAssassinExtension.java
+++ 
b/server/container/util/src/test/java/org/apache/james/util/scanner/SpamAssassinExtension.java
@@ -43,18 +43,18 @@ public class SpamAssassinExtension implements 
BeforeAllCallback, AfterAllCallbac
     private SpamAssassin spamAssassin;
 
     public SpamAssassinExtension() {
-        spamAssassinContainer = new 
GenericContainer<>("aduprat/spamassassin:latest");
+        spamAssassinContainer = new 
GenericContainer<>("linagora/spamassassin:latest");
         spamAssassinContainer.waitingFor(new SpamAssassinWaitStrategy());
     }
 
     @Override
-    public void beforeAll(ExtensionContext context) throws Exception {
+    public void beforeAll(ExtensionContext context) {
         spamAssassinContainer.start();
         spamAssassin = new SpamAssassin(spamAssassinContainer);
     }
 
     @Override
-    public void afterAll(ExtensionContext context) throws Exception {
+    public void afterAll(ExtensionContext context) {
         spamAssassinContainer.close();
     }
 
@@ -99,7 +99,7 @@ public class SpamAssassinExtension implements 
BeforeAllCallback, AfterAllCallbac
             train(user, 
Paths.get(ClassLoader.getSystemResource("spamassassin_db/ham").toURI()), 
TrainingKind.HAM);
         }
 
-        private void train(String user, Path folder, TrainingKind 
trainingKind) throws URISyntaxException, IOException {
+        private void train(String user, Path folder, TrainingKind 
trainingKind) throws IOException {
             
spamAssassinContainer.getDockerClient().copyArchiveToContainerCmd(spamAssassinContainer.getContainerId())
                 .withHostResource(folder.toAbsolutePath().toString())
                 .withRemotePath("/root")
@@ -108,15 +108,13 @@ public class SpamAssassinExtension implements 
BeforeAllCallback, AfterAllCallbac
                 paths
                     .filter(Files::isRegularFile)
                     .map(Path::toFile)
-                    .forEach(Throwing.consumer(file -> {
-                            spamAssassinContainer.execInContainer("sa-learn", 
-                                    trainingKind.saLearnExtensionName(), "-u", 
user,
-                                    "/root/" + 
trainingKind.name().toLowerCase(Locale.US) + "/" +  file.getName());
-                    }));
+                    .forEach(Throwing.consumer(file -> 
spamAssassinContainer.execInContainer("sa-learn",
+                        trainingKind.saLearnExtensionName(), "-u", user,
+                        "/root/" + trainingKind.name().toLowerCase(Locale.US) 
+ "/" +  file.getName())));
             }
         }
 
-        private static enum TrainingKind {
+        private enum TrainingKind {
             SPAM("--spam"), HAM("--ham");
 
             private String saLearnExtensionName;

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
index dbcf81b..2c40aa6 100644
--- 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
+++ 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -53,6 +53,14 @@
             <mailet match="All" 
class="org.apache.james.jmap.mailet.TextCalendarBodyToAttachment"/>
             <mailet match="RecipientIsLocal" 
class="org.apache.james.jmap.mailet.VacationMailet"/>
             <mailet match="RecipientIsLocal" class="Sieve"/>
+            <mailet match="RecipientIsLocal" class="SpamAssassin">
+                <spamdHost>localhost</spamdHost>
+                <spamdPort>783</spamdPort>
+            </mailet>
+            <mailet match="IsMarkedAsSpam" class="ToRecipientFolder">
+                <folder>Spam</folder>
+                <consume>true</consume>
+            </mailet>
             <mailet match="RecipientIsLocal" class="LocalDelivery"/>
             <mailet match="HostIsLocal" class="ToProcessor">
                 <processor>local-address-error</processor>

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
index 2cb925f..b7a87ac 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
@@ -35,6 +35,11 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>apache-james-mailbox-spamassassin</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>apache-mailet-base</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
@@ -78,6 +83,12 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-util</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-util-java8</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
@@ -117,11 +128,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-text</artifactId>
         </dependency>
@@ -136,6 +142,21 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>testcontainers</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
new file mode 100644
index 0000000..cedde75
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.jmap.methods.integration;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.util.scanner.SpamAssassinExtension;
+
+public class JamesWithSpamAssassin {
+
+    private final GuiceJamesServer jmapServer;
+    private final SpamAssassinExtension spamAssassinExtension;
+
+    public JamesWithSpamAssassin(GuiceJamesServer jmapServer, 
SpamAssassinExtension spamAssassinExtension) {
+        this.jmapServer = jmapServer;
+        this.spamAssassinExtension = spamAssassinExtension;
+    }
+
+    public GuiceJamesServer getJmapServer() {
+        return jmapServer;
+    }
+
+    public SpamAssassinExtension getSpamAssassinExtension() {
+        return spamAssassinExtension;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/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
new file mode 100644
index 0000000..dc3f7be
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
@@ -0,0 +1,218 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.with;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.HttpJmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.Role;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.JmapGuiceProbe;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.jayway.awaitility.Awaitility;
+import com.jayway.awaitility.Duration;
+import com.jayway.awaitility.core.ConditionFactory;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.parsing.Parser;
+
+public interface SpamAssassinContract {
+
+    String NAME = "[0][0]";
+    String ARGUMENTS = "[0][1]";
+    String BOBS_DOMAIN = "spamer.com";
+    String BOB = "bob@" + BOBS_DOMAIN;
+    String BOB_PASSWORD = "bobPassword";
+    String ALICES_DOMAIN = "angels.org";
+    String ALICE = "alice@" + ALICES_DOMAIN;
+    String ALICE_PASSWORD = "alicePassword";
+
+    @BeforeEach
+    default void setup(JamesWithSpamAssassin james) throws Throwable {
+        james.getJmapServer().start();
+
+        RestAssured.requestSpecification = new RequestSpecBuilder()
+                .setContentType(ContentType.JSON)
+                .setAccept(ContentType.JSON)
+                
.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
+                
.setPort(james.getJmapServer().getProbe(JmapGuiceProbe.class).getJmapPort())
+                .build();
+        RestAssured.defaultParser = Parser.JSON;
+
+        
james.getJmapServer().getProbe(DataProbeImpl.class).addDomain(BOBS_DOMAIN);
+        
james.getJmapServer().getProbe(DataProbeImpl.class).addDomain(ALICES_DOMAIN);
+        james.getJmapServer().getProbe(DataProbeImpl.class).addUser(BOB, 
BOB_PASSWORD);
+        james.getJmapServer().getProbe(DataProbeImpl.class).addUser(ALICE, 
ALICE_PASSWORD);
+    }
+
+    default AccessToken accessTokenFor(GuiceJamesServer james, String user, 
String password) {
+        return HttpJmapAuthentication.authenticateJamesUser(baseUri(james), 
user, password);
+    }
+
+    default URIBuilder baseUri(GuiceJamesServer james) {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(james.getProbe(JmapGuiceProbe.class)
+                .getJmapPort())
+            .setCharset(StandardCharsets.UTF_8);
+    }
+
+    @AfterEach
+    default void teardown(JamesWithSpamAssassin james) {
+        james.getJmapServer().stop();
+    }
+
+    @Test
+    default void 
spamShouldBeDeliveredInSpamMailboxWhenSameMessageHasAlreadyBeenMovedToSpam(JamesWithSpamAssassin
 james) throws Exception {
+        Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
+        ConditionFactory calmlyAwait = 
Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
+
+        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), 
ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), 
BOB, BOB_PASSWORD);
+
+        // Bob is sending a message to Alice
+        given()
+            .header("Authorization", bobAccessToken.serialize())
+            .body(setMessageCreate(bobAccessToken))
+        .when()
+            .post("/jmap");
+        calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> 
areMessagesFoundInMailbox(aliceAccessToken, getInboxId(aliceAccessToken), 1));
+
+        // Alice is moving this message to Spam -> learning in SpamAssassin
+        List<String> messageIds = with()
+            .header("Authorization", aliceAccessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + 
getInboxId(aliceAccessToken) + "\"]}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", hasSize(1))
+            .extract()
+            .path(ARGUMENTS + ".messageIds");
+
+        messageIds
+            .forEach(messageId -> given()
+                .header("Authorization", aliceAccessToken.serialize())
+                .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : 
{ \"mailboxIds\": [\"" + getSpamId(aliceAccessToken) + "\"] } } }, \"#0\"]]", 
messageId))
+            .when()
+                .post("/jmap")
+            .then()
+                .statusCode(200)
+                .body(NAME, equalTo("messagesSet"))
+                .body(ARGUMENTS + ".updated", hasSize(1)));
+        calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> 
areMessagesFoundInMailbox(aliceAccessToken, getSpamId(aliceAccessToken), 1));
+
+        // Bob is sending again the same message to Alice
+        given()
+            .header("Authorization", bobAccessToken.serialize())
+            .body(setMessageCreate(bobAccessToken))
+        .when()
+            .post("/jmap");
+
+        // This message is delivered in Alice Spam mailbox (she now must have 
2 messages in her Spam mailbox)
+        calmlyAwait.atMost(10, TimeUnit.SECONDS).until(() -> 
areMessagesFoundInMailbox(aliceAccessToken, getSpamId(aliceAccessToken), 2));
+    }
+
+    default boolean areMessagesFoundInMailbox(AccessToken accessToken, String 
mailboxId, int expectedNumberOfMessages) {
+        try {
+            with()
+                .header("Authorization", accessToken.serialize())
+                .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" 
+ mailboxId + "\"]}}, \"#0\"]]")
+            .when()
+                .post("/jmap")
+            .then()
+                .statusCode(200)
+                .body(NAME, equalTo("messageList"))
+                .body(ARGUMENTS + ".messageIds", 
hasSize(expectedNumberOfMessages));
+            return true;
+
+        } catch (AssertionError e) {
+            return false;
+        }
+    }
+
+    default String setMessageCreate(AccessToken accessToken) {
+        return "[" +
+            "  [" +
+            "    \"setMessages\"," +
+            "    {" +
+            "      \"create\": { \"creationId1337\" : {" +
+            "        \"from\": { \"email\": \"" + BOB + "\"}," +
+            "        \"to\": [{ \"name\": \"recipient\", \"email\": \"" + 
ALICE + "\"}]," +
+            "        \"subject\": \"Happy News\"," +
+            "        \"textBody\": \"This is a SPAM!!!\r\n\r\n\"," +
+            "        \"mailboxIds\": [\"" + getOutboxId(accessToken) + "\"]" +
+            "      }}" +
+            "    }," +
+            "    \"#0\"" +
+            "  ]" +
+            "]";
+    }
+
+    default String getMailboxId(AccessToken accessToken, Role role) {
+        return getAllMailboxesIds(accessToken).stream()
+            .filter(x -> x.get("role").equalsIgnoreCase(role.serialize()))
+            .map(x -> x.get("id"))
+            .findFirst().get();
+    }
+
+    default List<Map<String, String>> getAllMailboxesIds(AccessToken 
accessToken) {
+        return with()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMailboxes\", {\"properties\": [\"role\", \"id\"]}, 
\"#0\"]]")
+        .post("/jmap")
+            .andReturn()
+            .body()
+            .jsonPath()
+            .getList(ARGUMENTS + ".list");
+    }
+
+    default String getInboxId(AccessToken accessToken) {
+        return getMailboxId(accessToken, Role.INBOX);
+    }
+
+    default String getOutboxId(AccessToken accessToken) {
+        return getMailboxId(accessToken, Role.OUTBOX);
+    }
+
+    default String getSpamId(AccessToken accessToken) {
+        return getMailboxId(accessToken, Role.SPAM);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinGuiceMailetLoader.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinGuiceMailetLoader.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinGuiceMailetLoader.java
new file mode 100644
index 0000000..a504d3e
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinGuiceMailetLoader.java
@@ -0,0 +1,87 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.jmap.methods.integration;
+
+import javax.mail.MessagingException;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.james.mailbox.spamassassin.SpamAssassinConfiguration;
+import org.apache.james.mailetcontainer.api.MailetLoader;
+import org.apache.james.mailetcontainer.impl.MailetConfigImpl;
+import org.apache.james.transport.mailets.SpamAssassin;
+import org.apache.james.util.Host;
+import org.apache.james.utils.ExtendedClassLoader;
+import org.apache.james.utils.GuiceGenericLoader;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+public class SpamAssassinGuiceMailetLoader implements MailetLoader {
+
+    private static final String STANDARD_PACKAGE = 
"org.apache.james.transport.mailets.";
+
+    private final GuiceGenericLoader<Mailet> genericLoader;
+    private final SpamAssassinConfiguration spamAssassinConfiguration;
+
+    @Inject
+    public SpamAssassinGuiceMailetLoader(Injector injector, 
ExtendedClassLoader extendedClassLoader, SpamAssassinConfiguration 
spamAssassinConfiguration) {
+        this.genericLoader = new GuiceGenericLoader<>(injector, 
extendedClassLoader, STANDARD_PACKAGE);
+        this.spamAssassinConfiguration = spamAssassinConfiguration;
+    }
+
+    @Override
+    public Mailet getMailet(MailetConfig config) throws MessagingException {
+        String mailetName = config.getMailetName();
+        try {
+            if (mailetName.equals(SpamAssassin.class.getSimpleName())) {
+                return configureSpamAssassinMailet(mailetName);
+            }
+            Mailet result = genericLoader.instanciate(mailetName);
+            result.init(config);
+            return result;
+        } catch (Exception e) {
+            throw new MessagingException("Can not load mailet " + mailetName, 
e);
+        }
+    }
+
+    private Mailet configureSpamAssassinMailet(String mailetName) throws 
Exception, MessagingException {
+        Mailet mailet = genericLoader.instanciate(mailetName);
+        mailet.init(spamAssassinMailetConfig());
+        return mailet;
+    }
+
+    private MailetConfigImpl spamAssassinMailetConfig() throws 
MessagingException {
+        BaseConfiguration baseConfiguration = new BaseConfiguration();
+        Host host = getHostOrThrow(spamAssassinConfiguration);
+        baseConfiguration.addProperty(SpamAssassin.SPAMD_HOST, 
host.getHostName());
+        baseConfiguration.addProperty(SpamAssassin.SPAMD_PORT, host.getPort());
+
+        MailetConfigImpl mailetConfig = new MailetConfigImpl();
+        mailetConfig.setConfiguration(baseConfiguration);
+        return mailetConfig;
+    }
+
+    private Host getHostOrThrow(SpamAssassinConfiguration 
spamAssassinConfiguration) throws MessagingException {
+        return spamAssassinConfiguration.getHost()
+                .orElseThrow(() -> new MessagingException("SpamAssassin 
configuration missing"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
new file mode 100644
index 0000000..88a5a79
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
@@ -0,0 +1,60 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.jmap.methods.integration;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.Optional;
+
+import javax.inject.Singleton;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.mailbox.spamassassin.SpamAssassinConfiguration;
+import org.apache.james.mailetcontainer.api.MailetLoader;
+import org.apache.james.util.Host;
+import org.apache.james.util.scanner.SpamAssassinExtension;
+import org.apache.james.util.scanner.SpamAssassinExtension.SpamAssassin;
+import org.apache.james.utils.PropertiesProvider;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
+
+public class SpamAssassinModule extends AbstractModule {
+
+    private final SpamAssassinExtension spamAssassinExtension;
+
+    public SpamAssassinModule(SpamAssassinExtension spamAssassinExtension) {
+        this.spamAssassinExtension = spamAssassinExtension;
+    }
+
+    @Override
+    protected void configure() {
+        bind(SpamAssassinGuiceMailetLoader.class).in(Scopes.SINGLETON);
+        bind(MailetLoader.class).to(SpamAssassinGuiceMailetLoader.class);
+    }
+
+    @Provides
+    @Singleton
+    private SpamAssassinConfiguration 
getSpamAssassinConfiguration(PropertiesProvider propertiesProvider) throws 
ConfigurationException, IOException, URISyntaxException {
+        SpamAssassin spamAssassin = spamAssassinExtension.getSpamAssassin();
+        return new 
SpamAssassinConfiguration(Optional.of(Host.from(spamAssassin.getIp(), 
spamAssassin.getBindingPort())));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham1
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham1
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham1
new file mode 100644
index 0000000..c50bb11
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham1
@@ -0,0 +1,113 @@
+From [email protected]  Thu Aug 22 12:36:23 2002
+Return-Path: <[email protected]>
+Delivered-To: [email protected]
+Received: from localhost (localhost [127.0.0.1])
+       by phobos.labs.netnoteinc.com (Postfix) with ESMTP id D03E543C36
+       for <zzzz@localhost>; Thu, 22 Aug 2002 07:36:16 -0400 (EDT)
+Received: from phobos [127.0.0.1]
+       by localhost with IMAP (fetchmail-5.9.0)
+       for zzzz@localhost (single-drop); Thu, 22 Aug 2002 12:36:16 +0100 (IST)
+Received: from listman.spamassassin.taint.org (listman.spamassassin.taint.org 
[66.187.233.211]) by
+    dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id g7MBYrZ04811 for
+    <[email protected]>; Thu, 22 Aug 2002 12:34:53 +0100
+Received: from listman.spamassassin.taint.org (localhost.localdomain 
[127.0.0.1]) by
+    listman.redhat.com (Postfix) with ESMTP id 8386540858; Thu, 22 Aug 2002
+    07:35:02 -0400 (EDT)
+Delivered-To: [email protected]
+Received: from int-mx1.corp.spamassassin.taint.org 
(int-mx1.corp.spamassassin.taint.org
+    [172.16.52.254]) by listman.redhat.com (Postfix) with ESMTP id 10CF8406D7
+    for <[email protected]>; Thu, 22 Aug 2002 07:34:10 -0400
+    (EDT)
+Received: (from mail@localhost) by int-mx1.corp.spamassassin.taint.org 
(8.11.6/8.11.6)
+    id g7MBY7g11259 for [email protected]; Thu, 22 Aug 2002
+    07:34:07 -0400
+Received: from mx1.spamassassin.taint.org (mx1.spamassassin.taint.org 
[172.16.48.31]) by
+    int-mx1.corp.redhat.com (8.11.6/8.11.6) with SMTP id g7MBY7Y11255 for
+    <[email protected]>; Thu, 22 Aug 2002 07:34:07 -0400
+Received: from ratree.psu.ac.th ([202.28.97.6]) by mx1.spamassassin.taint.org
+    (8.11.6/8.11.6) with SMTP id g7MBIhl25223 for <[email protected]>;
+    Thu, 22 Aug 2002 07:18:55 -0400
+Received: from delta.cs.mu.OZ.AU (delta.coe.psu.ac.th [172.30.0.98]) by
+    ratree.psu.ac.th (8.11.6/8.11.6) with ESMTP id g7MBWel29762;
+    Thu, 22 Aug 2002 18:32:40 +0700 (ICT)
+Received: from munnari.OZ.AU (localhost [127.0.0.1]) by delta.cs.mu.OZ.AU
+    (8.11.6/8.11.6) with ESMTP id g7MBQPW13260; Thu, 22 Aug 2002 18:26:25
+    +0700 (ICT)
+From: Robert Elz <[email protected]>
+To: Chris Garrigues <[email protected]>
+Cc: [email protected]
+Subject: Re: New Sequences Window
+In-Reply-To: <[email protected]>
+References: <[email protected]>
+    <[email protected]> <[email protected]>
+    <[email protected]>
+    <[email protected]>
+MIME-Version: 1.0
+Content-Type: text/plain; charset=us-ascii
+Message-Id: <[email protected]>
+X-Loop: [email protected]
+Sender: [email protected]
+Errors-To: [email protected]
+X-Beenthere: [email protected]
+X-Mailman-Version: 2.0.1
+Precedence: bulk
+List-Help: <mailto:[email protected]?subject=help>
+List-Post: <mailto:[email protected]>
+List-Subscribe: 
<https://listman.spamassassin.taint.org/mailman/listinfo/exmh-workers>,
+    <mailto:[email protected]?subject=subscribe>
+List-Id: Discussion list for EXMH developers 
<exmh-workers.spamassassin.taint.org>
+List-Unsubscribe: 
<https://listman.spamassassin.taint.org/mailman/listinfo/exmh-workers>,
+    <mailto:[email protected]?subject=unsubscribe>
+List-Archive: 
<https://listman.spamassassin.taint.org/mailman/private/exmh-workers/>
+Date: Thu, 22 Aug 2002 18:26:25 +0700
+
+    Date:        Wed, 21 Aug 2002 10:54:46 -0500
+    From:        Chris Garrigues <[email protected]>
+    Message-ID:  <[email protected]>
+
+
+  | I can't reproduce this error.
+
+For me it is very repeatable... (like every time, without fail).
+
+This is the debug log of the pick happening ...
+
+18:19:03 Pick_It {exec pick +inbox -list -lbrace -lbrace -subject ftp -rbrace 
-rbrace} {4852-4852 -sequence mercury}
+18:19:03 exec pick +inbox -list -lbrace -lbrace -subject ftp -rbrace -rbrace 
4852-4852 -sequence mercury
+18:19:04 Ftoc_PickMsgs {{1 hit}}
+18:19:04 Marking 1 hits
+18:19:04 tkerror: syntax error in expression "int ...
+
+Note, if I run the pick command by hand ...
+
+delta$ pick +inbox -list -lbrace -lbrace -subject ftp -rbrace -rbrace  
4852-4852 -sequence mercury
+1 hit
+
+That's where the "1 hit" comes from (obviously).  The version of nmh I'm
+using is ...
+
+delta$ pick -version
+pick -- nmh-1.0.4 [compiled on fuchsia.cs.mu.OZ.AU at Sun Mar 17 14:55:56 ICT 
2002]
+
+And the relevant part of my .mh_profile ...
+
+delta$ mhparam pick
+-seq sel -list
+
+
+Since the pick command works, the sequence (actually, both of them, the
+one that's explicit on the command line, from the search popup, and the
+one that comes from .mh_profile) do get created.
+
+kre
+
+ps: this is still using the version of the code form a day ago, I haven't
+been able to reach the cvs repository today (local routing issue I think).
+
+
+
+_______________________________________________
+Exmh-workers mailing list
[email protected]
+https://listman.redhat.com/mailman/listinfo/exmh-workers
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham2
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham2
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham2
new file mode 100644
index 0000000..7a5b23a
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham2
@@ -0,0 +1,73 @@
+From [email protected]  Thu Aug 22 12:46:39 2002
+Return-Path: <[email protected]>
+Delivered-To: [email protected]
+Received: from localhost (localhost [127.0.0.1])
+       by phobos.labs.netnoteinc.com (Postfix) with ESMTP id BE12E43C34
+       for <zzzz@localhost>; Thu, 22 Aug 2002 07:46:38 -0400 (EDT)
+Received: from phobos [127.0.0.1]
+       by localhost with IMAP (fetchmail-5.9.0)
+       for zzzz@localhost (single-drop); Thu, 22 Aug 2002 12:46:38 +0100 (IST)
+Received: from n20.grp.scd.yahoo.com (n20.grp.scd.yahoo.com
+    [66.218.66.76]) by dogma.slashnull.org (8.11.6/8.11.6) with SMTP id
+    g7MBkTZ05087 for <[email protected]>; Thu, 22 Aug 2002 12:46:29 
+0100
+X-Egroups-Return: 
sentto-2242572-52726-1030016790-zzzz=spamassassin.taint....@returns.groups.yahoo.com
+Received: from [66.218.67.196] by n20.grp.scd.yahoo.com with NNFMP;
+    22 Aug 2002 11:46:30 -0000
+X-Sender: [email protected]
+X-Apparently-To: [email protected]
+Received: (EGP: mail-8_1_0_1); 22 Aug 2002 11:46:29 -0000
+Received: (qmail 11764 invoked from network); 22 Aug 2002 11:46:29 -0000
+Received: from unknown (66.218.66.217) by m3.grp.scd.yahoo.com with QMQP;
+    22 Aug 2002 11:46:29 -0000
+Received: from unknown (HELO mailgateway.cursor-system.com) (62.189.7.27)
+    by mta2.grp.scd.yahoo.com with SMTP; 22 Aug 2002 11:46:29 -0000
+Received: from exchange1.cps.local (unverified) by
+    mailgateway.cursor-system.com (Content Technologies SMTPRS 4.2.10) with
+    ESMTP id <[email protected]> for
+    <[email protected]>; Thu, 22 Aug 2002 13:14:10 +0100
+Received: by exchange1.cps.local with Internet Mail Service (5.5.2653.19)
+    id <PXX6AT23>; Thu, 22 Aug 2002 12:46:27 +0100
+Message-Id: <[email protected]>
+To: "'[email protected]'" <[email protected]>
+X-Mailer: Internet Mail Service (5.5.2653.19)
+X-Egroups-From: Steve Burt <[email protected]>
+From: Steve Burt <[email protected]>
+X-Yahoo-Profile: pyruse
+MIME-Version: 1.0
+Mailing-List: list [email protected]; contact
+    [email protected]
+Delivered-To: mailing list [email protected]
+Precedence: bulk
+List-Unsubscribe: <mailto:[email protected]>
+Date: Thu, 22 Aug 2002 12:46:18 +0100
+Subject: [zzzzteana] RE: Alexander
+Reply-To: [email protected]
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+
+Martin A posted:
+Tassos Papadopoulos, the Greek sculptor behind the plan, judged that the
+ limestone of Mount Kerdylio, 70 miles east of Salonika and not far from the
+ Mount Athos monastic community, was ideal for the patriotic sculpture. 
+ 
+ As well as Alexander's granite features, 240 ft high and 170 ft wide, a
+ museum, a restored amphitheatre and car park for admiring crowds are
+planned
+---------------------
+So is this mountain limestone or granite?
+If it's limestone, it'll weather pretty fast.
+
+------------------------ Yahoo! Groups Sponsor ---------------------~-->
+4 DVDs Free +s&p Join Now
+http://us.click.yahoo.com/pt6YBB/NXiEAA/mG3HAA/7gSolB/TM
+---------------------------------------------------------------------~->
+
+To unsubscribe from this group, send an email to:
[email protected]
+
+ 
+
+Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
+
+
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham3
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham3
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham3
new file mode 100644
index 0000000..c7cfbc8
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/ham/ham3
@@ -0,0 +1,82 @@
+From [email protected]  Thu Aug 22 13:52:59 2002
+Return-Path: <[email protected]>
+Delivered-To: [email protected]
+Received: from localhost (localhost [127.0.0.1])
+       by phobos.labs.netnoteinc.com (Postfix) with ESMTP id 0314547C66
+       for <zzzz@localhost>; Thu, 22 Aug 2002 08:52:58 -0400 (EDT)
+Received: from phobos [127.0.0.1]
+       by localhost with IMAP (fetchmail-5.9.0)
+       for zzzz@localhost (single-drop); Thu, 22 Aug 2002 13:52:59 +0100 (IST)
+Received: from n16.grp.scd.yahoo.com (n16.grp.scd.yahoo.com
+    [66.218.66.71]) by dogma.slashnull.org (8.11.6/8.11.6) with SMTP id
+    g7MCrdZ07070 for <[email protected]>; Thu, 22 Aug 2002 13:53:39 
+0100
+X-Egroups-Return: 
sentto-2242572-52733-1030020820-zzzz=spamassassin.taint....@returns.groups.yahoo.com
+Received: from [66.218.67.198] by n16.grp.scd.yahoo.com with NNFMP;
+    22 Aug 2002 12:53:40 -0000
+X-Sender: [email protected]
+X-Apparently-To: [email protected]
+Received: (EGP: mail-8_1_0_1); 22 Aug 2002 12:53:39 -0000
+Received: (qmail 76099 invoked from network); 22 Aug 2002 12:53:39 -0000
+Received: from unknown (66.218.66.218) by m5.grp.scd.yahoo.com with QMQP;
+    22 Aug 2002 12:53:39 -0000
+Received: from unknown (HELO rhenium.btinternet.com) (194.73.73.93) by
+    mta3.grp.scd.yahoo.com with SMTP; 22 Aug 2002 12:53:39 -0000
+Received: from host217-36-23-185.in-addr.btopenworld.com ([217.36.23.185])
+    by rhenium.btinternet.com with esmtp (Exim 3.22 #8) id 17hrT0-0004gj-00
+    for [email protected]; Thu, 22 Aug 2002 13:53:38 +0100
+X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
+To: zzzzteana <[email protected]>
+X-Priority: 3
+Message-Id: <[email protected]>
+From: "Tim Chapman" <[email protected]>
+X-Yahoo-Profile: tim2ubh
+MIME-Version: 1.0
+Mailing-List: list [email protected]; contact
+    [email protected]
+Delivered-To: mailing list [email protected]
+Precedence: bulk
+List-Unsubscribe: <mailto:[email protected]>
+Date: Thu, 22 Aug 2002 13:52:38 +0100
+Subject: [zzzzteana] Moscow bomber
+Reply-To: [email protected]
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+
+Man Threatens Explosion In Moscow 
+
+Thursday August 22, 2002 1:40 PM
+MOSCOW (AP) - Security officers on Thursday seized an unidentified man who
+said he was armed with explosives and threatened to blow up his truck in
+front of Russia's Federal Security Services headquarters in Moscow, NTV
+television reported.
+The officers seized an automatic rifle the man was carrying, then the man
+got out of the truck and was taken into custody, NTV said. No other details
+were immediately available.
+The man had demanded talks with high government officials, the Interfax and
+ITAR-Tass news agencies said. Ekho Moskvy radio reported that he wanted to
+talk with Russian President Vladimir Putin.
+Police and security forces rushed to the Security Service building, within
+blocks of the Kremlin, Red Square and the Bolshoi Ballet, and surrounded the
+man, who claimed to have one and a half tons of explosives, the news
+agencies said. Negotiations continued for about one and a half hours outside
+the building, ITAR-Tass and Interfax reported, citing witnesses.
+The man later drove away from the building, under police escort, and drove
+to a street near Moscow's Olympic Penta Hotel, where authorities held
+further negotiations with him, the Moscow police press service said. The
+move appeared to be an attempt by security services to get him to a more
+secure location. 
+
+------------------------ Yahoo! Groups Sponsor ---------------------~-->
+4 DVDs Free +s&p Join Now
+http://us.click.yahoo.com/pt6YBB/NXiEAA/mG3HAA/7gSolB/TM
+---------------------------------------------------------------------~->
+
+To unsubscribe from this group, send an email to:
[email protected]
+
+ 
+
+Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
+
+
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam1
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam1
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam1
new file mode 100644
index 0000000..8bad787
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam1
@@ -0,0 +1,108 @@
+From [email protected]  Tue Aug  6 11:51:02 2002
+Return-Path: <[email protected]>
+Delivered-To: [email protected]
+Received: from localhost (localhost [127.0.0.1])
+       by phobos.labs.netnoteinc.com (Postfix) with ESMTP id 9E1F5441DD
+       for <jm@localhost>; Tue,  6 Aug 2002 06:48:09 -0400 (EDT)
+Received: from phobos [127.0.0.1]
+       by localhost with IMAP (fetchmail-5.9.0)
+       for jm@localhost (single-drop); Tue, 06 Aug 2002 11:48:09 +0100 (IST)
+Received: from lugh.tuatha.org ([email protected] [194.125.145.45]) by
+    dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id g72LqWv13294 for
+    <[email protected]>; Fri, 2 Aug 2002 22:52:32 +0100
+Received: from lugh (root@localhost [127.0.0.1]) by lugh.tuatha.org
+    (8.9.3/8.9.3) with ESMTP id WAA31224; Fri, 2 Aug 2002 22:50:17 +0100
+Received: from bettyjagessar.com (w142.z064000057.nyc-ny.dsl.cnc.net
+    [64.0.57.142]) by lugh.tuatha.org (8.9.3/8.9.3) with ESMTP id WAA31201 for
+    <[email protected]>; Fri, 2 Aug 2002 22:50:11 +0100
+X-Authentication-Warning: lugh.tuatha.org: Host 
w142.z064000057.nyc-ny.dsl.cnc.net
+    [64.0.57.142] claimed to be bettyjagessar.com
+Received: from 64.0.57.142 [202.63.165.34] by bettyjagessar.com
+    (SMTPD32-7.06 EVAL) id A42A7FC01F2; Fri, 02 Aug 2002 02:18:18 -0400
+Message-Id: <[email protected]>
+Date: Fri, 02 Aug 2002 23:37:59 0530
+To: [email protected]
+From: "Start Now" <[email protected]>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="US-ASCII"; format=flowed
+Subject: [ILUG] STOP THE MLM INSANITY
+Sender: [email protected]
+Errors-To: [email protected]
+X-Mailman-Version: 1.1
+Precedence: bulk
+List-Id: Irish Linux Users' Group <ilug.linux.ie>
+X-Beenthere: [email protected]
+
+Greetings!
+
+You are receiving this letter because you have expressed an interest in 
+receiving information about online business opportunities. If this is 
+erroneous then please accept my most sincere apology. This is a one-time 
+mailing, so no removal is necessary.
+
+If you've been burned, betrayed, and back-stabbed by multi-level marketing, 
+MLM, then please read this letter. It could be the most important one that 
+has ever landed in your Inbox.
+
+MULTI-LEVEL MARKETING IS A HUGE MISTAKE FOR MOST PEOPLE
+
+MLM has failed to deliver on its promises for the past 50 years. The pursuit 
+of the "MLM Dream" has cost hundreds of thousands of people their friends, 
+their fortunes and their sacred honor. The fact is that MLM is fatally 
+flawed, meaning that it CANNOT work for most people.
+
+The companies and the few who earn the big money in MLM are NOT going to 
+tell you the real story. FINALLY, there is someone who has the courage to 
+cut through the hype and lies and tell the TRUTH about MLM.
+
+HERE'S GOOD NEWS
+
+There IS an alternative to MLM that WORKS, and works BIG! If you haven't yet 
+abandoned your dreams, then you need to see this. Earning the kind of income 
+you've dreamed about is easier than you think!
+
+With your permission, I'd like to send you a brief letter that will tell you 
+WHY MLM doesn't work for most people and will then introduce you to 
+something so new and refreshing that you'll wonder why you haven't heard of 
+this before.
+
+I promise that there will be NO unwanted follow up, NO sales pitch, no one 
+will call you, and your email address will only be used to send you the 
+information. Period.
+
+To receive this free, life-changing information, simply click Reply, type 
+"Send Info" in the Subject box and hit Send. I'll get the information to you 
+within 24 hours. Just look for the words MLM WALL OF SHAME in your Inbox.
+
+Cordially,
+
+Siddhi
+
+P.S. Someone recently sent the letter to me and it has been the most 
+eye-opening, financially beneficial information I have ever received. I 
+honestly believe that you will feel the same way once you've read it. And 
+it's FREE!
+
+
+------------------------------------------------------------
+This email is NEVER sent unsolicited.  THIS IS NOT "SPAM". You are receiving 
+this email because you EXPLICITLY signed yourself up to our list with our 
+online signup form or through use of our FFA Links Page and E-MailDOM 
+systems, which have EXPLICIT terms of use which state that through its use 
+you agree to receive our emailings.  You may also be a member of a Altra 
+Computer Systems list or one of many numerous FREE Marketing Services and as 
+such you agreed when you signed up for such list that you would also be 
+receiving this emailing.
+Due to the above, this email message cannot be considered unsolicitated, or 
+spam.
+-----------------------------------------------------------
+
+
+
+
+-- 
+Irish Linux Users' Group: [email protected]
+http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
+List maintainer: [email protected]
+
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam2
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam2
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam2
new file mode 100644
index 0000000..88a809e
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam2
@@ -0,0 +1,186 @@
+From [email protected]  Mon Jun 24 17:03:24 2002
+Return-Path: [email protected]
+Delivery-Date: Mon May 13 04:46:13 2002
+Received: from mandark.labs.netnoteinc.com ([213.105.180.140]) by
+    dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id g4D3kCe15097 for
+    <[email protected]>; Mon, 13 May 2002 04:46:12 +0100
+Received: from 203.129.205.5.205.129.203.in-addr.arpa ([203.129.205.5]) by
+    mandark.labs.netnoteinc.com (8.11.2/8.11.2) with SMTP id g4D3k2D12605 for
+    <[email protected]>; Mon, 13 May 2002 04:46:04 +0100
+Received: from html (unverified [207.95.174.49]) by
+    203.129.205.5.205.129.203.in-addr.arpa (EMWAC SMTPRS 0.83) with SMTP id
+    <[email protected]>; Mon, 13 May 2002
+    09:04:46 +0530
+Message-Id: <[email protected]>
+From: [email protected]
+To: [email protected]
+Subject: Real Protection, Stun Guns!  Free Shipping! Time:2:01:35 PM
+Date: Mon, 28 Jul 1980 14:01:35
+MIME-Version: 1.0
+X-Keywords: 
+Content-Type: text/html; charset="DEFAULT"
+
+<html>
+<body>
+<center>
+<h3>
+<font color="blue">
+<b>
+The Need For Safety Is Real In 2002, You Might Only Get One Chance - Be Ready!
+<p>
+Free Shipping & Handling Within The (USA) If You Order Before May 25, 2002! 
+<p>
+3 Day Super Sale, Now Until May 7, 2002!  Save Up To $30.00 On Some Items!
+
+</b>
+</font>
+</h3>
+</center>
+<p>
+IT'S GETTING TO BE SPRING AGAIN, PROTECT YOURSELF AS YOU WALK,<br>
+JOG AND EXERCISE OUTSIDE.  ALSO PROTECT YOUR LOVED ONES AS<br>
+THEY RETURN HOME FROM COLLEGE!<br>
+<p>
+*     LEGAL PROTECTION FOR COLLEGE STUDENTS!<br>
+*     GREAT UP'COMING OUTDOOR PROTECTION GIFTS!<br>
+*     THERE IS NOTHING WORTH MORE PROTECTING THAN LIFE!<br>
+*     OUR STUN DEVICES & PEPPER PRODUCTS ARE LEGAL PROTECTION!
+<p>
+<b>
+<font color="red">
+JOIN THE WAR ON CRIME!
+</b>
+</font>
+<p>
+
+STUN GUNS AND BATONS 
+<p>
+EFFECTIVE - SAFE - NONLETHAL
+<p>
+PROTECT YOUR LOVED ONES AND YOURSELF
+<p>
+No matter who you are, no matter what City or Town you live in,<br>
+if you live in America, you will be touched by crime.
+<p>
+You hear about it on TV.  You read about it in the newspaper.<br>
+It's no secret that crime is a major problem in the U.S. today.<br>
+Criminals are finding it easier to commit crimes all the time.
+<p>
+Weapons are readily available.  Our cities' police forces have<br>
+more work than they can handle.  Even if these criminal are<br>
+caught, they won't be spending long in our nation's overcrowded<br>
+jails.  And while lawmakers are well aware of the crime problem,<br>
+they don't seem to have any effective answers.
+<p>
+Our Email Address:  <a
+href="mailto:[email protected]";>[email protected]</a>
+<p>
+INTERESTED:
+<p>
+You will be protecting yourself within 7 days!  Don't Wait,<br>
+visit our web page below, and join The War On Crime!
+<p>
+*****************<br>
+<a
+href="http://www.geocities.com/realprotection_20022003/";>http://www.geocities.com/realprotection_20022003/</a><br>
+*****************
+<p>
+Well, there is an effective answer.  Take responsibility for<br>
+your own security.  Our site has a variety of quality personal<br>
+security products.  Visit our site, choose the personal security<br>
+products that are right for you.  Use them, and join the war on
+crime!
+<p>
+FREE PEPPER SPRAY WITH ANY STUN UNIT PURCHASE.<br>
+(A Value of $15.95)
+<p>
+We Ship Orders Within 5 To 7 Days, To Every State In The U.S.A.<br>
+by UPS, FEDEX, or U.S. POSTAL SERVICE.  Visa, MasterCard, American<br>
+Express & Debt Card Gladly Accepted.
+<p>
+Ask yourself this question, if you don't help your loved ones,
+who will?
+<p>
+INTERESTED:
+<p>
+*****************<br>
+<a
+href="http://www.geocities.com/realprotection_20022003/";>http://www.geocities.com/realprotection_20022003/</a><br>
+*****************
+<p>
+___The Stun Monster 625,000 Volts ($86.95)<br>
+___The Z-Force Slim Style 300,000 Volts ($64.95)<br>
+___The StunMaster 300,000 Volts Straight ($59.95)<br>
+___The StunMaster 300,000 Volts Curb ($59.95)<br>
+___The StunMaster 200,000 Volts Straight ($49.95)<br>
+___The StunMaster 200,000 Volts Curb ($49.95)<br>
+___The StunBaton 500,000 Volts ($89.95)<br>
+___The StunBaton 300,000 Volts ($79.95)<br>
+___Pen Knife (One $12.50, Two Or More $9.00)<br>
+___Wildfire Pepper Spray  (One $15.95, Two Or More $11.75)
+<p>
+___Add $5.75 For Shipping & Handling Charge.
+<p>
+
+To Order by postal mail, please send to the below address.<br>
+Make payable to Mega Safety Technology.
+<p>
+Mega Safety Technology<br>
+3215 Merrimac Ave.<br>
+Dayton, Ohio  45405<br>
+Our Email Address:  <a
+href="mailto:[email protected]";>[email protected]</a>
+<p>
+Order by 24 Hour Fax!!!  775-257-6657.
+<p>
+*****<br>
+<b><font color="red">Important Credit Card Information! Please Read 
Below!</b></font>
+ <br><br>
+*     Credit Card Address, City, State and Zip Code, must match
+      billing address to be processed. 
+<br><br>
+
+CHECK____  MONEYORDER____  VISA____ MASTERCARD____ AmericanExpress___
+Debt Card___
+<br><br>
+Name_______________________________________________________<br>
+(As it appears on Check or Credit Card)
+<br><br>
+Address____________________________________________________<br>
+(As it appears on Check or Credit Card)
+<br><br>
+___________________________________________________<br>
+City,State,Zip(As it appears on Check or Credit Card)
+<br><br>
+___________________________________________________<br>
+Country
+<br><br>
+___________________________________________________<br>
+(Credit Card Number)
+<br><br>
+Expiration Month_____  Year_____
+<br><br>
+___________________________________________________<br>
+Authorized Signature
+<br><br>
+<b>
+*****IMPORTANT NOTE*****
+</b>
+<br><br>
+If Shipping Address Is Different From The Billing Address Above,
+Please Fill Out Information Below.
+<br><br>
+Shipping Name______________________________________________
+<br><br>
+Shipping Address___________________________________________
+<br><br>
+___________________________________________________________<br>
+Shipping City,State,Zip
+<br><br>
+___________________________________________________________<br>
+Country
+<br><br>
+___________________________________________________________<br>
+Email Address & Phone Number(Please Write Neat)
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam3
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam3
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam3
new file mode 100644
index 0000000..e828804
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/spamassassin_db/spam/spam3
@@ -0,0 +1,211 @@
+From [email protected]  Mon Jun 24 17:03:49 2002
+Return-Path: [email protected]
+Delivery-Date: Wed May 15 08:58:23 2002
+Received: from mandark.labs.netnoteinc.com ([213.105.180.140]) by
+    dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id g4F7wIe23864 for
+    <[email protected]>; Wed, 15 May 2002 08:58:18 +0100
+Received: from webcust2.hightowertech.com (webcust2.hightowertech.com
+    [216.41.166.100]) by mandark.labs.netnoteinc.com (8.11.2/8.11.2) with
+    ESMTP id g4F7wGD24120 for <[email protected]>; Wed, 15 May 2002 08:58:17
+    +0100
+Received: from html ([206.216.197.214]) by webcust2.hightowertech.com with
+    Microsoft SMTPSVC(5.5.1877.197.19); Wed, 15 May 2002 00:55:53 -0700
+From: [email protected]
+To: [email protected]
+Subject: New Improved Fat Burners, Now With TV Fat Absorbers! Time:6:25:49 PM
+Date: Wed, 30 Jul 1980 18:25:49
+MIME-Version: 1.0
+Message-Id: <[email protected]>
+X-Keywords: 
+Content-Type: text/html; charset="DEFAULT"
+
+<html>
+<body>
+<center>
+<b>
+<font color="blue">
+*****Bonus Fat Absorbers As Seen On TV, Included Free With Purchase Of 2 Or 
More Bottle, $24.95 Value*****
+</font>
+<br>
+<br>
+***TAKE $10.00 OFF 2 & 3 MONTH SUPPLY ORDERS, $5.00 OFF 1 MONTH SUPPLY!
+***AND STILL GET YOUR BONUS!  PRICE WILL BE DEDUCTED DURING PROCESSING.
+<br>
+<br>
+***FAT ABSORBERS ARE GREAT FOR THOSE WHO WANT TO LOSE WEIGHT,  BUT CAN'T STAY 
ON A DIET***
+<br>
+<br>
+***OFFER GOOD UNTIL MAY 27, 2002!  FOREIGN ORDERS INCLUDED!
+<br>
+<br>
+
+<font color="blue">
+
+LOSE 30 POUNDS  IN 30 DAYS... GUARANTEED!!!
+<br>
+<br>
+
+All Natural Weight-Loss Program, Speeds Up The Metabolism Safely
+Rated #1 In Both Categories of SAFETY & EFFECTIVENESS In<br>
+(THE United States Today)
+<br><br>
+WE'LL HELP YOU GET THINNER!
+WE'RE GOING TO HELP YOU LOOK GOOD, FEEL GOOD AND TAKE CONTROL IN
+2002
+<br>
+<br>
+</b>
+</font color="blue">
+</center>
+
+Why Use Our Amazing Weight Loss Capsules?
+<br><br>
+*  They act like a natural magnet to attract fat.<br>
+*  Stimulates the body's natural metabolism. <br>
+*  Controls appetite naturally and makes it easier to
+   eat the right foods consistently.<br>
+*  Reduces craving for sweets.<br>
+*  Aids in the absorption of fat and in overall digestion.<br>
+*  Inhibits bad cholesterol and boosts good cholesterol.<br>
+*  Aids in the process of weight loss and long-term weight management.<br>
+*  Completely safe, UltraTrim New Century contains no banned
+   substances and has no known side effects.<br>
+<br>
+What Makes UltraTrim New Century Unique?
+<br><br>
+A scientifically designed combination of natural ingredients that
+provide long-term weight management in a safe and effective manner.
+<br><br>
+*****<br>
+Receive A Bonus Supply Of Ultra Trim New Century & A Bottle Of Fat Absorbers 
Listed Above, 
+With Every Order Of 2 Or More Bottles. Offer Good Until May. 27, 2002! <br>
+*****
+<br><br>
+WE GLADLY SHIP TO ALL FOREIGN COUNTRIES! 
+<br><br>
+You will be losing by tomorrow!  Don't Wait, visit our web
+page below, and order now!
+<br><br>
+Email Address:   <a
+href="mailto:[email protected]";>[email protected]</a>
+<br><br>
+Order by 24 Hour Fax!!!  775-257-6657.<br>
+<br>
+*****************<br>
+<a
+href="http://www.geocities.com/ultra_weightloss_2002/";>http://www.geocities.com/ultra_weightloss_2002/</a><br>
+*****************
+<br><br>
+This is the easiest, fastest, and most effective way to lose both
+pounds and inches permanently!!!  This weight loss program is
+designed specifically to "boost" weight-loss efforts by assisting
+body metabolism, and helping the body's ability to manage weight.
+A powerful, safe, 30 Day Program.  This is one program you won't
+feel starved on.  Complete program for one amazing low price!
+Program includes: <b>BONUS AMAZING FAT ABSORBER CAPSULES, 30 DAY -
+WEIGHT
+REDUCTION PLAN, PROGRESS REPORT!</b>
+<br><br>
+SPECIAL BONUS..."FAT ABSORBERS", AS SEEN ON TV
+With every order...AMAZING MELT AWAY FAT ABSORBER CAPSULES with
+directions ( Absolutely Free ) ...With these capsules
+you can eat what you enjoy, without the worry of fat in your diet.
+2 to 3 capsules 15 minutes before eating or snack, and the fat will be
+absorbed and passed through the body without the digestion of fat into
+the body. 
+<br><br>
+You will be losing by tomorrow!  Don't Wait, visit our web
+page below, and order now!
+<br><br>
+Email Address:  <a 
href="mailto:[email protected]";>[email protected]</a>
+<br><br>
+
+Order by 24 Hour Fax!!!  775-257-6657.<br>
+<br>
+*****************<br>
+<a
+href="http://www.geocities.com/ultra_weightloss_2002/";>http://www.geocities.com/ultra_weightloss_2002/</a><br>
+*****************
+<br><br>
+___1 Month Supply $32.95 plus $4.75 S & H, 100 Amazing MegaTrim
+     Capsules.
+<br><br>
+___2 Month Supply $54.95 plus $4.75 S & H, 200 Amazing MegaTrim
+     Capsules.  (A $10.95 Savings, Free Bottle)!
+<br><br>
+___3 Month Supply $69.95,  Plus $4.75 S & H, 300 Amazing MegaTrim
+     Capsules.  (A $28.90 Savings, Free Bottle)!
+<br><br>
+To Order by postal mail, please send to the below address.
+Make payable to UltraTrim 2002.
+<br><br>
+Ultra Trim 2002<br>
+4132 Pompton Ct.<br>
+Dayton, Ohio  45405<br>
+(937) 567-9807<br>
+<br>
+Order by 24 Hour Voice/Fax!!!  775-257-6657.<br>
+<br>
+*****<br>
+<b><font color="red">Important Credit Card Information! Please Read 
Below!</b></font>
+ <br><br>
+*     Credit Card Address, City, State and Zip Code, must match
+      billing address to be processed. 
+<br><br>
+
+___Check<br>
+___MoneyOrder<br>
+___Visa<br>
+___MasterCard<br>
+___AmericanExpress<br>
+___Debt Card
+<br><br>
+Name_______________________________________________________<br>
+(As it appears on Check or Credit Card)
+<br><br>
+Address____________________________________________________<br>
+(As it appears on Check or Credit Card)
+<br><br>
+___________________________________________________<br>
+City,State,Zip(As it appears on Check or Credit Card)
+<br><br>
+___________________________________________________<br>
+Country
+<br><br>
+___________________________________________________<br>
+(Credit Card Number)
+<br><br>
+Expiration Month_____  Year_____
+<br><br>
+___________________________________________________<br>
+Authorized Signature
+<br><br>
+<b>
+*****IMPORTANT NOTE*****
+</b>
+<br><br>
+If Shipping Address Is Different From The Billing Address Above,
+Please Fill Out Information Below.
+<br><br>
+Shipping Name______________________________________________
+<br><br>
+Shipping Address___________________________________________
+<br><br>
+___________________________________________________________<br>
+Shipping City,State,Zip
+<br><br>
+___________________________________________________________<br>
+Country
+<br><br>
+___________________________________________________________<br>
+Email Address & Phone Number(Please Write Neat)
+<br>
+<br>
+<center>
+<a
+href="mailto:[email protected]";>To Be Removed From Our Mail 
List, Click Here And Put The Word Remove In The Subject Line.</a>
+</center>
+<br>
+<br>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
index 890e138..7e21553 100644
--- 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -35,6 +35,11 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>apache-james-mailbox-spamassassin</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>apache-mailet-base</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
@@ -80,6 +85,12 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-util</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-util-java8</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
@@ -116,11 +127,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>
@@ -130,6 +136,21 @@
             <artifactId>java-hamcrest</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>testcontainers</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
new file mode 100644
index 0000000..4c0bb01
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
@@ -0,0 +1,100 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.jmap.memory;
+
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.JamesWithSpamAssassin;
+import org.apache.james.jmap.methods.integration.SpamAssassinModule;
+import org.apache.james.mailbox.extractor.TextExtractor;
+import org.apache.james.mailbox.store.search.MessageSearchIndex;
+import org.apache.james.mailbox.store.search.PDFTextExtractor;
+import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.util.scanner.SpamAssassinExtension;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+import org.junit.rules.TemporaryFolder;
+
+public class MemoryJmapExtension implements BeforeAllCallback, 
AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+
+    private static final int LIMIT_TO_20_MESSAGES = 20;
+
+    private final TemporaryFolder temporaryFolder;
+    private final SpamAssassinExtension spamAssassinExtension;
+    private final JamesWithSpamAssassin james;
+
+    public MemoryJmapExtension() {
+        this.temporaryFolder = new TemporaryFolder();
+        this.spamAssassinExtension = new SpamAssassinExtension();
+        this.james = james();
+    }
+
+    private JamesWithSpamAssassin james() {
+        return new JamesWithSpamAssassin(
+            new GuiceJamesServer()
+                
.combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
+                .overrideWith(new TestFilesystemModule(temporaryFolder),
+                    new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
+                .overrideWith(binder -> 
binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
+                .overrideWith(binder -> 
binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
+                .overrideWith(binder -> 
binder.bind(MessageSearchIndex.class).to(SimpleMessageSearchIndex.class))
+                .overrideWith(new SpamAssassinModule(spamAssassinExtension)),
+            spamAssassinExtension);
+    }
+
+    @Override
+    public void beforeAll(ExtensionContext context) throws Exception {
+        spamAssassinExtension.beforeAll(context);
+    }
+
+    @Override
+    public void afterAll(ExtensionContext context) throws Exception {
+        spamAssassinExtension.afterAll(context);
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext context) throws Exception {
+        temporaryFolder.create();
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context) throws Exception {
+        temporaryFolder.delete();
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, 
ExtensionContext extensionContext) throws ParameterResolutionException {
+        return parameterContext.getParameter().getType() == 
JamesWithSpamAssassin.class;
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, 
ExtensionContext extensionContext) throws ParameterResolutionException {
+        return james;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContract.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContract.java
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContract.java
new file mode 100644
index 0000000..29b1ea7
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContract.java
@@ -0,0 +1,27 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.jmap.memory;
+
+import org.apache.james.jmap.methods.integration.SpamAssassinContract;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(MemoryJmapExtension.class)
+public class MemorySpamAssassinContract implements SpamAssassinContract {
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
index fe07346..8027b3e 100644
--- 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -53,7 +53,15 @@
             <mailet match="All" 
class="org.apache.james.jmap.mailet.TextCalendarBodyToAttachment"/>
             <mailet match="RecipientIsLocal" 
class="org.apache.james.jmap.mailet.VacationMailet"/>
             <mailet match="RecipientIsLocal" class="Sieve"/>
-            <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+            <mailet match="RecipientIsLocal" class="SpamAssassin">
+                <spamdHost>localhost</spamdHost>
+                <spamdPort>783</spamdPort>
+            </mailet>
+            <mailet match="IsMarkedAsSpam" class="ToRecipientFolder">
+                <folder>Spam</folder>
+                <consume>true</consume>
+            </mailet>
+             <mailet match="RecipientIsLocal" class="LocalDelivery"/>
             <mailet match="HostIsLocal" class="ToProcessor">
                 <processor>local-address-error</processor>
                 <notice>550 - Requested action not taken: no such user 
here</notice>

http://git-wip-us.apache.org/repos/asf/james-project/blob/37435eee/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/spamassassin_db
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/spamassassin_db
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/spamassassin_db
new file mode 120000
index 0000000..de1933d
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/spamassassin_db
@@ -0,0 +1 @@
+../../../../jmap-integration-testing-common/src/test/resources/spamassassin_db
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to