You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2023/12/20 10:09:06 UTC

(james-project) 01/03: JAMES-2586 Add search module chooser for Postgres app

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit bc35746b505f089874408c902aa06e81f426c92f
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue Dec 19 17:28:53 2023 +0700

    JAMES-2586 Add search module chooser for Postgres app
---
 server/apps/postgres-app/pom.xml                   |  34 ++++++
 .../apache/james/PostgresJamesConfiguration.java   |  24 +++-
 .../org/apache/james/PostgresJamesServerMain.java  |   9 +-
 .../apache/james/JamesCapabilitiesServerTest.java  |   2 +
 .../org/apache/james/PostgresJamesServerTest.java  |   2 +
 .../james/PostgresWithLDAPJamesServerTest.java     |   2 +
 .../james/PostgresWithOpenSearchDisabledTest.java  | 128 +++++++++++++++++++++
 ...esServerTest.java => PostgresWithTikaTest.java} |  30 ++---
 .../james/WithScanningSearchImmutableTest.java}    |  30 +++--
 ...est.java => WithScanningSearchMutableTest.java} |  28 +----
 server/container/guice/mailbox-postgres/pom.xml    |   4 -
 .../modules/mailbox/LuceneSearchMailboxModule.java |  58 ----------
 .../modules/mailbox/PostgresMailboxModule.java     |   1 -
 13 files changed, 228 insertions(+), 124 deletions(-)

diff --git a/server/apps/postgres-app/pom.xml b/server/apps/postgres-app/pom.xml
index c49ba04d59..ab53a56738 100644
--- a/server/apps/postgres-app/pom.xml
+++ b/server/apps/postgres-app/pom.xml
@@ -44,12 +44,24 @@
     </dependencyManagement>
 
     <dependencies>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>apache-james-backends-opensearch</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-backends-postgres</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>apache-james-mailbox-opensearch</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-mailbox-postgres</artifactId>
@@ -60,6 +72,18 @@
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-mailbox-quota-search-scanning</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>apache-james-mailbox-tika</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-cassandra-app</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>james-server-cli</artifactId>
@@ -119,6 +143,10 @@
             <groupId>${james.groupId}</groupId>
             <artifactId>james-server-guice-managedsieve</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-guice-opensearch</artifactId>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>james-server-guice-pop</artifactId>
@@ -151,6 +179,12 @@
             <groupId>${james.groupId}</groupId>
             <artifactId>james-server-guice-webadmin-mailrepository</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-jmap-draft-integration-testing</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>james-server-mailbox-adapter</artifactId>
diff --git a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesConfiguration.java b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesConfiguration.java
index 34305a69e3..54554aa3fe 100644
--- a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesConfiguration.java
+++ b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesConfiguration.java
@@ -30,14 +30,19 @@ import org.apache.james.server.core.MissingArgumentException;
 import org.apache.james.server.core.configuration.Configuration;
 import org.apache.james.server.core.configuration.FileConfigurationProvider;
 import org.apache.james.server.core.filesystem.FileSystemImpl;
+import org.apache.james.utils.PropertiesProvider;
+
+import com.github.fge.lambdas.Throwing;
 
 public class PostgresJamesConfiguration implements Configuration {
     public static class Builder {
         private Optional<String> rootDirectory;
         private Optional<ConfigurationPath> configurationPath;
         private Optional<UsersRepositoryModuleChooser.Implementation> usersRepositoryImplementation;
+        private Optional<SearchConfiguration> searchConfiguration;
 
         private Builder() {
+            searchConfiguration = Optional.empty();
             rootDirectory = Optional.empty();
             configurationPath = Optional.empty();
             usersRepositoryImplementation = Optional.empty();
@@ -76,12 +81,21 @@ public class PostgresJamesConfiguration implements Configuration {
             return this;
         }
 
+        public Builder searchConfiguration(SearchConfiguration searchConfiguration) {
+            this.searchConfiguration = Optional.of(searchConfiguration);
+            return this;
+        }
+
         public PostgresJamesConfiguration build() {
             ConfigurationPath configurationPath = this.configurationPath.orElse(new ConfigurationPath(FileSystem.FILE_PROTOCOL_AND_CONF));
             JamesServerResourceLoader directories = new JamesServerResourceLoader(rootDirectory
                 .orElseThrow(() -> new MissingArgumentException("Server needs a working.directory env entry")));
 
             FileSystemImpl fileSystem = new FileSystemImpl(directories);
+            PropertiesProvider propertiesProvider = new PropertiesProvider(fileSystem, configurationPath);
+
+            SearchConfiguration searchConfiguration = this.searchConfiguration.orElseGet(Throwing.supplier(
+                () -> SearchConfiguration.parse(propertiesProvider)));
 
             FileConfigurationProvider configurationProvider = new FileConfigurationProvider(fileSystem, Basic.builder()
                 .configurationPath(configurationPath)
@@ -93,6 +107,7 @@ public class PostgresJamesConfiguration implements Configuration {
             return new PostgresJamesConfiguration(
                 configurationPath,
                 directories,
+                searchConfiguration,
                 usersRepositoryChoice);
         }
     }
@@ -103,11 +118,14 @@ public class PostgresJamesConfiguration implements Configuration {
 
     private final ConfigurationPath configurationPath;
     private final JamesDirectoriesProvider directories;
+    private final SearchConfiguration searchConfiguration;
     private final UsersRepositoryModuleChooser.Implementation usersRepositoryImplementation;
 
-    public PostgresJamesConfiguration(ConfigurationPath configurationPath, JamesDirectoriesProvider directories, UsersRepositoryModuleChooser.Implementation usersRepositoryImplementation) {
+    public PostgresJamesConfiguration(ConfigurationPath configurationPath, JamesDirectoriesProvider directories,
+                                      SearchConfiguration searchConfiguration, UsersRepositoryModuleChooser.Implementation usersRepositoryImplementation) {
         this.configurationPath = configurationPath;
         this.directories = directories;
+        this.searchConfiguration = searchConfiguration;
         this.usersRepositoryImplementation = usersRepositoryImplementation;
     }
 
@@ -121,6 +139,10 @@ public class PostgresJamesConfiguration implements Configuration {
         return directories;
     }
 
+    public SearchConfiguration searchConfiguration() {
+        return searchConfiguration;
+    }
+
     public UsersRepositoryModuleChooser.Implementation getUsersRepositoryImplementation() {
         return usersRepositoryImplementation;
     }
diff --git a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java
index 24cfa7d1cd..d346debd37 100644
--- a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java
+++ b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java
@@ -28,9 +28,9 @@ import org.apache.james.modules.data.PostgresDelegationStoreModule;
 import org.apache.james.modules.data.PostgresUsersRepositoryModule;
 import org.apache.james.modules.data.SievePostgresRepositoryModules;
 import org.apache.james.modules.mailbox.DefaultEventModule;
-import org.apache.james.modules.mailbox.LuceneSearchMailboxModule;
 import org.apache.james.modules.mailbox.MemoryDeadLetterModule;
 import org.apache.james.modules.mailbox.PostgresMailboxModule;
+import org.apache.james.modules.mailbox.TikaMailboxModule;
 import org.apache.james.modules.protocols.IMAPServerModule;
 import org.apache.james.modules.protocols.LMTPServerModule;
 import org.apache.james.modules.protocols.ManageSieveServerModule;
@@ -85,13 +85,13 @@ public class PostgresJamesServerMain implements JamesServerMain {
         new PostgresMailboxModule(),
         new PostgresDataModule(),
         new MailboxModule(),
-        new LuceneSearchMailboxModule(),
         new NoJwtModule(),
         new RawPostDequeueDecoratorModule(),
         new SievePostgresRepositoryModules(),
         new DefaultEventModule(),
         new TaskManagerModule(),
-        new MemoryDeadLetterModule());
+        new MemoryDeadLetterModule(),
+        new TikaMailboxModule());
 
     private static final Module POSTGRES_MODULE_AGGREGATE = Modules.combine(
         new MailetProcessingModule(), POSTGRES_SERVER_MODULE, PROTOCOLS);
@@ -112,7 +112,10 @@ public class PostgresJamesServerMain implements JamesServerMain {
     }
 
     static GuiceJamesServer createServer(PostgresJamesConfiguration configuration) {
+        SearchConfiguration searchConfiguration = configuration.searchConfiguration();
+
         return GuiceJamesServer.forConfiguration(configuration)
+            .combineWith(SearchModuleChooser.chooseModules(searchConfiguration))
             .combineWith(new UsersRepositoryModuleChooser(new PostgresUsersRepositoryModule())
                 .chooseModules(configuration.getUsersRepositoryImplementation()))
             .combineWith(POSTGRES_MODULE_AGGREGATE);
diff --git a/server/apps/postgres-app/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java b/server/apps/postgres-app/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index b59e3d2ff9..b40620638a 100644
--- a/server/apps/postgres-app/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -48,10 +48,12 @@ class JamesCapabilitiesServerTest {
         PostgresJamesConfiguration.builder()
             .workingDirectory(tmpDir)
             .configurationFromClasspath()
+            .searchConfiguration(SearchConfiguration.openSearch())
             .usersRepository(DEFAULT)
             .build())
         .server(configuration -> PostgresJamesServerMain.createServer(configuration)
             .overrideWith(binder -> binder.bind(MailboxManager.class).toInstance(mailboxManager())))
+        .extension(new DockerOpenSearchExtension())
         .extension(postgresExtension)
         .build();
     
diff --git a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresJamesServerTest.java b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresJamesServerTest.java
index cf63a63718..cdadef140b 100644
--- a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresJamesServerTest.java
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresJamesServerTest.java
@@ -48,9 +48,11 @@ class PostgresJamesServerTest implements JamesServerConcreteContract {
         PostgresJamesConfiguration.builder()
             .workingDirectory(tmpDir)
             .configurationFromClasspath()
+            .searchConfiguration(SearchConfiguration.openSearch())
             .usersRepository(DEFAULT)
             .build())
         .server(PostgresJamesServerMain::createServer)
+        .extension(new DockerOpenSearchExtension())
         .extension(postgresExtension)
         .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
         .build();
diff --git a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
index 288e26d9b3..b5add8f9af 100644
--- a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
@@ -41,11 +41,13 @@ class PostgresWithLDAPJamesServerTest {
         PostgresJamesConfiguration.builder()
             .workingDirectory(tmpDir)
             .configurationFromClasspath()
+            .searchConfiguration(SearchConfiguration.openSearch())
             .usersRepository(LDAP)
             .build())
         .server(PostgresJamesServerMain::createServer)
         .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
         .extension(new LdapTestExtension())
+        .extension(new DockerOpenSearchExtension())
         .extension(postgresExtension)
         .build();
 
diff --git a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithOpenSearchDisabledTest.java b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithOpenSearchDisabledTest.java
new file mode 100644
index 0000000000..4412dc39d9
--- /dev/null
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithOpenSearchDisabledTest.java
@@ -0,0 +1,128 @@
+/****************************************************************
+ * 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;
+
+import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.nio.charset.StandardCharsets;
+
+import org.apache.james.backends.opensearch.OpenSearchConfiguration;
+import org.apache.james.backends.postgres.PostgresExtension;
+import org.apache.james.core.Domain;
+import org.apache.james.mailbox.DefaultMailboxes;
+import org.apache.james.mailbox.opensearch.events.OpenSearchListeningMessageSearchIndex;
+import org.apache.james.modules.EventDeadLettersProbe;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.util.Host;
+import org.apache.james.util.Port;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.TestIMAPClient;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import com.google.common.io.Resources;
+
+public class PostgresWithOpenSearchDisabledTest implements MailsShouldBeWellReceivedConcreteContract {
+    static PostgresExtension postgresExtension = PostgresExtension.empty();
+
+    @RegisterExtension
+    static JamesServerExtension jamesServerExtension = new JamesServerBuilder<PostgresJamesConfiguration>(tmpDir ->
+        PostgresJamesConfiguration.builder()
+            .workingDirectory(tmpDir)
+            .configurationFromClasspath()
+            .searchConfiguration(SearchConfiguration.openSearchDisabled())
+            .usersRepository(DEFAULT)
+            .build())
+        .server(configuration -> PostgresJamesServerMain.createServer(configuration)
+            .overrideWith(binder -> binder.bind(OpenSearchConfiguration.class)
+            .toInstance(OpenSearchConfiguration.builder()
+                .addHost(Host.from("127.0.0.1", 9042))
+                .build())))
+        .extension(postgresExtension)
+        .build();
+
+    @Test
+    void mailsShouldBeKeptInDeadLetterForLaterIndexing(GuiceJamesServer server) throws Exception {
+        server.getProbe(DataProbeImpl.class).fluent()
+            .addDomain(DOMAIN)
+            .addUser(JAMES_USER, PASSWORD)
+            .addUser(SENDER, PASSWORD);
+
+        MailboxProbeImpl mailboxProbe = server.getProbe(MailboxProbeImpl.class);
+        mailboxProbe.createMailbox("#private", JAMES_USER, DefaultMailboxes.INBOX);
+
+        Port smtpPort = Port.of(smtpPort(server));
+        String message = Resources.toString(Resources.getResource("eml/htmlMail.eml"), StandardCharsets.UTF_8);
+
+        try (SMTPMessageSender sender = new SMTPMessageSender(Domain.LOCALHOST.asString())) {
+            sender.connect(JAMES_SERVER_HOST, smtpPort).authenticate(SENDER, PASSWORD);
+            sendUniqueMessage(sender, message);
+        }
+
+        CALMLY_AWAIT.until(() -> server.getProbe(EventDeadLettersProbe.class).getEventDeadLetters()
+            .groupsWithFailedEvents().collectList().block().contains(new OpenSearchListeningMessageSearchIndex.OpenSearchListeningMessageSearchIndexGroup()));
+    }
+
+    @Test
+    void searchShouldFail(GuiceJamesServer server) throws Exception {
+        server.getProbe(DataProbeImpl.class).fluent()
+            .addDomain(DOMAIN)
+            .addUser(JAMES_USER, PASSWORD)
+            .addUser(SENDER, PASSWORD);
+
+        MailboxProbeImpl mailboxProbe = server.getProbe(MailboxProbeImpl.class);
+        mailboxProbe.createMailbox("#private", JAMES_USER, DefaultMailboxes.INBOX);
+
+        try (TestIMAPClient reader = new TestIMAPClient()) {
+            int imapPort = imapPort(server);
+            reader.connect(JAMES_SERVER_HOST, imapPort)
+                .login(JAMES_USER, PASSWORD)
+                .select(TestIMAPClient.INBOX);
+
+            assertThat(reader.sendCommand("SEARCH SUBJECT thy"))
+                .contains("NO SEARCH processing failed");
+        }
+    }
+
+    @Test
+    @Disabled("Overrides not implemented yet for Postgresql")
+    void searchShouldSucceedOnSearchOverrides(GuiceJamesServer server) throws Exception {
+        server.getProbe(DataProbeImpl.class).fluent()
+            .addDomain(DOMAIN)
+            .addUser(JAMES_USER, PASSWORD)
+            .addUser(SENDER, PASSWORD);
+
+        MailboxProbeImpl mailboxProbe = server.getProbe(MailboxProbeImpl.class);
+        mailboxProbe.createMailbox("#private", JAMES_USER, DefaultMailboxes.INBOX);
+
+        try (TestIMAPClient reader = new TestIMAPClient()) {
+            int imapPort = imapPort(server);
+            reader.connect(JAMES_SERVER_HOST, imapPort)
+                .login(JAMES_USER, PASSWORD)
+                .select(TestIMAPClient.INBOX);
+
+            assertThat(reader.sendCommand("SEARCH UNSEEN"))
+                .contains("OK SEARCH");
+        }
+    }
+}
diff --git a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithTikaTest.java
similarity index 67%
copy from server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
copy to server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithTikaTest.java
index 288e26d9b3..12e5577d74 100644
--- a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithTikaTest.java
@@ -19,21 +19,12 @@
 
 package org.apache.james;
 
-import static org.apache.james.MailsShouldBeWellReceived.JAMES_SERVER_HOST;
-import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.LDAP;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT;
 
-import java.io.IOException;
-
-import org.apache.commons.net.imap.IMAPClient;
 import org.apache.james.backends.postgres.PostgresExtension;
-import org.apache.james.data.LdapTestExtension;
-import org.apache.james.modules.protocols.ImapGuiceProbe;
-import org.apache.james.user.ldap.DockerLdapSingleton;
-import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-class PostgresWithLDAPJamesServerTest {
+public class PostgresWithTikaTest implements JamesServerConcreteContract {
     static PostgresExtension postgresExtension = PostgresExtension.empty();
 
     @RegisterExtension
@@ -41,20 +32,13 @@ class PostgresWithLDAPJamesServerTest {
         PostgresJamesConfiguration.builder()
             .workingDirectory(tmpDir)
             .configurationFromClasspath()
-            .usersRepository(LDAP)
+            .searchConfiguration(SearchConfiguration.openSearch())
+            .usersRepository(DEFAULT)
             .build())
         .server(PostgresJamesServerMain::createServer)
-        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
-        .extension(new LdapTestExtension())
+        .extension(new DockerOpenSearchExtension())
+        .extension(new TikaExtension())
         .extension(postgresExtension)
+        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
         .build();
-
-
-    @Test
-    void userFromLdapShouldLoginViaImapProtocol(GuiceJamesServer server) throws IOException {
-        IMAPClient imapClient = new IMAPClient();
-        imapClient.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort());
-
-        assertThat(imapClient.login(DockerLdapSingleton.JAMES_USER.asString(), DockerLdapSingleton.PASSWORD)).isTrue();
-    }
 }
diff --git a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresQuotaSearchModule.java b/server/apps/postgres-app/src/test/java/org/apache/james/WithScanningSearchImmutableTest.java
similarity index 55%
rename from server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresQuotaSearchModule.java
rename to server/apps/postgres-app/src/test/java/org/apache/james/WithScanningSearchImmutableTest.java
index 5cd9108f93..51fbd2f023 100644
--- a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresQuotaSearchModule.java
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/WithScanningSearchImmutableTest.java
@@ -17,18 +17,26 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.modules.mailbox;
+package org.apache.james;
 
-import org.apache.james.quota.search.QuotaSearcher;
-import org.apache.james.quota.search.scanning.ScanningQuotaSearcher;
+import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT;
 
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+import org.apache.james.backends.postgres.PostgresExtension;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class PostgresQuotaSearchModule extends AbstractModule {
-    @Override
-    protected void configure() {
-        bind(ScanningQuotaSearcher.class).in(Scopes.SINGLETON);
-        bind(QuotaSearcher.class).to(ScanningQuotaSearcher.class);
-    }
+public class WithScanningSearchImmutableTest implements JamesServerConcreteContract {
+    static PostgresExtension postgresExtension = PostgresExtension.empty();
+
+    @RegisterExtension
+    static JamesServerExtension jamesServerExtension = new JamesServerBuilder<PostgresJamesConfiguration>(tmpDir ->
+        PostgresJamesConfiguration.builder()
+            .workingDirectory(tmpDir)
+            .configurationFromClasspath()
+            .searchConfiguration(SearchConfiguration.scanning())
+            .usersRepository(DEFAULT)
+            .build())
+        .server(PostgresJamesServerMain::createServer)
+        .extension(postgresExtension)
+        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
+        .build();
 }
diff --git a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java b/server/apps/postgres-app/src/test/java/org/apache/james/WithScanningSearchMutableTest.java
similarity index 65%
copy from server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
copy to server/apps/postgres-app/src/test/java/org/apache/james/WithScanningSearchMutableTest.java
index 288e26d9b3..7f1e84a3cc 100644
--- a/server/apps/postgres-app/src/test/java/org/apache/james/PostgresWithLDAPJamesServerTest.java
+++ b/server/apps/postgres-app/src/test/java/org/apache/james/WithScanningSearchMutableTest.java
@@ -19,21 +19,12 @@
 
 package org.apache.james;
 
-import static org.apache.james.MailsShouldBeWellReceived.JAMES_SERVER_HOST;
-import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.LDAP;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT;
 
-import java.io.IOException;
-
-import org.apache.commons.net.imap.IMAPClient;
 import org.apache.james.backends.postgres.PostgresExtension;
-import org.apache.james.data.LdapTestExtension;
-import org.apache.james.modules.protocols.ImapGuiceProbe;
-import org.apache.james.user.ldap.DockerLdapSingleton;
-import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-class PostgresWithLDAPJamesServerTest {
+public class WithScanningSearchMutableTest implements MailsShouldBeWellReceivedConcreteContract {
     static PostgresExtension postgresExtension = PostgresExtension.empty();
 
     @RegisterExtension
@@ -41,20 +32,11 @@ class PostgresWithLDAPJamesServerTest {
         PostgresJamesConfiguration.builder()
             .workingDirectory(tmpDir)
             .configurationFromClasspath()
-            .usersRepository(LDAP)
+            .searchConfiguration(SearchConfiguration.scanning())
+            .usersRepository(DEFAULT)
             .build())
         .server(PostgresJamesServerMain::createServer)
-        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
-        .extension(new LdapTestExtension())
         .extension(postgresExtension)
+        .lifeCycle(JamesServerExtension.Lifecycle.PER_TEST)
         .build();
-
-
-    @Test
-    void userFromLdapShouldLoginViaImapProtocol(GuiceJamesServer server) throws IOException {
-        IMAPClient imapClient = new IMAPClient();
-        imapClient.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort());
-
-        assertThat(imapClient.login(DockerLdapSingleton.JAMES_USER.asString(), DockerLdapSingleton.PASSWORD)).isTrue();
-    }
 }
diff --git a/server/container/guice/mailbox-postgres/pom.xml b/server/container/guice/mailbox-postgres/pom.xml
index 6aa052c041..3f345720af 100644
--- a/server/container/guice/mailbox-postgres/pom.xml
+++ b/server/container/guice/mailbox-postgres/pom.xml
@@ -33,10 +33,6 @@
     <name>Apache James :: Server :: Postgres - Guice injection</name>
 
     <dependencies>
-        <dependency>
-            <groupId>${james.groupId}</groupId>
-            <artifactId>apache-james-mailbox-lucene</artifactId>
-        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-mailbox-postgres</artifactId>
diff --git a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java
deleted file mode 100644
index 71a2bc741e..0000000000
--- a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************
- * 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.modules.mailbox;
-
-import java.io.IOException;
-
-import org.apache.james.events.EventListener;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
-import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
-import org.apache.james.mailbox.store.search.MessageSearchIndex;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.FSDirectory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Scopes;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class LuceneSearchMailboxModule extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        install(new ReIndexingTaskSerializationModule());
-
-        bind(LuceneMessageSearchIndex.class).in(Scopes.SINGLETON);
-        bind(MessageSearchIndex.class).to(LuceneMessageSearchIndex.class);
-        bind(ListeningMessageSearchIndex.class).to(LuceneMessageSearchIndex.class);
-
-        Multibinder.newSetBinder(binder(), EventListener.ReactiveGroupEventListener.class)
-            .addBinding()
-            .to(LuceneMessageSearchIndex.class);
-    }
-
-    @Provides
-    @Singleton
-    Directory provideDirectory(FileSystem fileSystem) throws IOException {
-        return FSDirectory.open(fileSystem.getBasedir());
-    }
-}
diff --git a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java
index 6e0be1b617..c0fc44a29f 100644
--- a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java
+++ b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java
@@ -85,7 +85,6 @@ public class PostgresMailboxModule extends AbstractModule {
         postgresDataDefinitions.addBinding().toInstance(PostgresMailboxAggregateModule.MODULE);
 
         install(new PostgresQuotaModule());
-        install(new PostgresQuotaSearchModule());
 
         bind(PostgresMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
         bind(PostgresMailboxManager.class).in(Scopes.SINGLETON);


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