JAMES-2551 Introduce Cassandra RabbitMQ product
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3efce9c8 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3efce9c8 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3efce9c8 Branch: refs/heads/master Commit: 3efce9c878f98b8413369a1ec3179dd0ae50a801 Parents: 937de06 Author: Antoine Duprat <adup...@linagora.com> Authored: Wed Oct 3 15:07:19 2018 +0200 Committer: Antoine Duprat <adup...@linagora.com> Committed: Wed Oct 31 17:56:16 2018 +0100 ---------------------------------------------------------------------- pom.xml | 11 + .../guice/cassandra-rabbitmq-guice/pom.xml | 225 +++++++++++++++++++ .../james/CassandraRabbitMQJamesServerMain.java | 44 ++++ .../james/CassandraRabbitMQJamesServerTest.java | 40 ++++ .../CassandraRabbitMQJmapJamesServerTest.java | 40 ++++ .../james/modules/DockerRabbitMQRule.java | 79 +++++++ .../apache/james/modules/RabbitMQExtension.java | 44 ++++ .../james/modules/TestRabbitMQModule.java | 87 +++++++ .../src/test/resources/batchsizes.properties | 10 + .../src/test/resources/dnsservice.xml | 29 +++ .../src/test/resources/domainlist.xml | 24 ++ .../src/test/resources/imapserver.xml | 54 +++++ .../src/test/resources/keystore | Bin 0 -> 2245 bytes .../src/test/resources/listeners.xml | 28 +++ .../src/test/resources/lmtpserver.xml | 41 ++++ .../src/test/resources/logback-test.xml | 27 +++ .../src/test/resources/mailetcontainer.xml | 146 ++++++++++++ .../src/test/resources/mailrepositorystore.xml | 36 +++ .../src/test/resources/managesieveserver.xml | 65 ++++++ .../src/test/resources/pop3server.xml | 42 ++++ .../src/test/resources/rabbitmq.properties | 2 + .../src/test/resources/smtpserver.xml | 102 +++++++++ .../src/test/resources/spamassassin.properties | 2 + server/container/guice/pom.xml | 1 + .../queue/rabbitmq/RabbitMQManagementApi.java | 14 +- 25 files changed, 1191 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 8d514a1..c34f86f 100644 --- a/pom.xml +++ b/pom.xml @@ -1169,6 +1169,17 @@ </dependency> <dependency> <groupId>${james.groupId}</groupId> + <artifactId>james-server-cassandra-rabbitmq-guice</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-cassandra-rabbitmq-guice</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> <artifactId>james-server-cli</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/pom.xml b/server/container/guice/cassandra-rabbitmq-guice/pom.xml new file mode 100644 index 0000000..47d1112 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/pom.xml @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.james</groupId> + <artifactId>james-server-guice</artifactId> + <version>3.2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>james-server-cassandra-rabbitmq-guice</artifactId> + <packaging>jar</packaging> + + <name>Apache James :: Server :: Cassandra with RabbitMQ - guice injection</name> + <description>An advanced email server - Cassandra backend and RabbitMQ messaging with guice injection</description> + + <properties> + <cassandra.includes>empty</cassandra.includes> + </properties> + + <dependencies> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>apache-james-backends-cassandra</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>apache-james-backends-es</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>apache-james-backends-rabbitmq</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>apache-james-mailbox-cassandra</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>apache-james-mailbox-elasticsearch</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>apache-james-mailbox-scanning-search</artifactId> + <type>test-jar</type> + <scope>test</scope> + </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-guice</artifactId> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-cassandra-guice</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-guice-common</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-guice-jmap</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-jmap-integration-testing</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-testing</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-util</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-webadmin-core</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.pdfbox</groupId> + <artifactId>pdfbox</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-launcher</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <phase>package</phase> + <configuration> + <includeScope>compile</includeScope> + <includeScope>runtime</includeScope> + <outputDirectory>${project.build.directory}/${project.artifactId}.lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>default-jar</id> + <goals> + <goal>jar</goal> + </goals> + <configuration> + <finalName>${project.artifactId}</finalName> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>${project.artifactId}.lib/</classpathPrefix> + <mainClass>org.apache.james.CassandraRabbitMQJamesServerMain</mainClass> + <useUniqueVersions>false</useUniqueVersions> + </manifest> + </archive> + </configuration> + </execution> + <execution> + <id>test-jar</id> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <reuseForks>true</reuseForks> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java new file mode 100644 index 0000000..78cd1a6 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java @@ -0,0 +1,44 @@ +/* + * 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.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE; + +import org.apache.james.modules.rabbitmq.RabbitMQModule; +import org.apache.james.modules.server.JMXServerModule; +import org.apache.james.server.core.configuration.Configuration; + +import com.google.inject.Module; +import com.google.inject.util.Modules; + +public class CassandraRabbitMQJamesServerMain { + public static final Module ALL_BUT_JMX_CASSANDRA_RABBITMQ_MODULE = Modules.override(ALL_BUT_JMX_CASSANDRA_MODULE) + .with(new RabbitMQModule()); + + public static void main(String[] args) throws Exception { + Configuration configuration = Configuration.builder() + .useWorkingDirectoryEnvProperty() + .build(); + + GuiceJamesServer server = GuiceJamesServer.forConfiguration(configuration) + .combineWith(ALL_BUT_JMX_CASSANDRA_RABBITMQ_MODULE, new JMXServerModule()); + server.start(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java new file mode 100644 index 0000000..33f8cc1 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.james.modules.RabbitMQExtension; +import org.apache.james.modules.TestJMAPServerModule; +import org.junit.jupiter.api.extension.RegisterExtension; + +public class CassandraRabbitMQJamesServerTest implements JmapJamesServerContract { + private static final int LIMIT_TO_10_MESSAGES = 10; + + @RegisterExtension + static JamesServerExtension testExtension = new JamesServerExtensionBuilder() + .extension(new EmbeddedElasticSearchExtension()) + .extension(new CassandraExtension()) + .extension(new RabbitMQExtension()) + .server(configuration -> GuiceJamesServer.forConfiguration(configuration) + .combineWith(CassandraRabbitMQJamesServerMain.ALL_BUT_JMX_CASSANDRA_RABBITMQ_MODULE) + .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES)) + .overrideWith(DOMAIN_LIST_CONFIGURATION_MODULE)) + .build(); + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJmapJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJmapJamesServerTest.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJmapJamesServerTest.java new file mode 100644 index 0000000..9bb2ec8 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJmapJamesServerTest.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.james.modules.RabbitMQExtension; +import org.apache.james.modules.TestJMAPServerModule; +import org.junit.jupiter.api.extension.RegisterExtension; + +public class CassandraRabbitMQJmapJamesServerTest implements JmapJamesServerContract { + private static final int LIMIT_TO_10_MESSAGES = 10; + + @RegisterExtension + static JamesServerExtension testExtension = new JamesServerExtensionBuilder() + .extension(new EmbeddedElasticSearchExtension()) + .extension(new CassandraExtension()) + .extension(new RabbitMQExtension()) + .server(configuration -> GuiceJamesServer.forConfiguration(configuration) + .combineWith(CassandraRabbitMQJamesServerMain.ALL_BUT_JMX_CASSANDRA_RABBITMQ_MODULE) + .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES)) + .overrideWith(DOMAIN_LIST_CONFIGURATION_MODULE)) + .build(); + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/DockerRabbitMQRule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/DockerRabbitMQRule.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/DockerRabbitMQRule.java new file mode 100644 index 0000000..5356b6c --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/DockerRabbitMQRule.java @@ -0,0 +1,79 @@ +/* + * 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; + +import static org.apache.james.backend.rabbitmq.RabbitMQFixture.DEFAULT_MANAGEMENT_CREDENTIAL; + +import com.google.inject.Module; +import com.google.inject.multibindings.Multibinder; +import com.google.inject.util.Modules; +import org.apache.james.CleanupTasksPerformer; +import org.apache.james.GuiceModuleTestRule; +import org.apache.james.backend.rabbitmq.DockerRabbitMQ; +import org.apache.james.backend.rabbitmq.RabbitMQConfiguration; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.net.URISyntaxException; + +public class DockerRabbitMQRule implements GuiceModuleTestRule { + + private DockerRabbitMQ rabbitMQ = DockerRabbitMQ.withoutCookie(); + + @Override + public Statement apply(Statement base, Description description) { + return base; + } + + @Override + public void await() { + } + + @Override + public Module getModule() { + return Modules.combine((binder) -> { + try { + binder.bind(RabbitMQConfiguration.class) + .toInstance(RabbitMQConfiguration.builder() + .amqpUri(rabbitMQ.amqpUri()) + .managementUri(rabbitMQ.managementUri()) + .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL) + .build()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + }, + binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class) + .addBinding() + .to(TestRabbitMQModule.QueueCleanUp.class)); + } + + public DockerRabbitMQ dockerRabbitMQ() { + return rabbitMQ; + } + + public void start() { + rabbitMQ.start(); + } + + public void stop() { + rabbitMQ.stop(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/RabbitMQExtension.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/RabbitMQExtension.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/RabbitMQExtension.java new file mode 100644 index 0000000..24decaf --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/RabbitMQExtension.java @@ -0,0 +1,44 @@ +/* + * 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; + +import com.google.inject.Module; +import org.apache.james.GuiceModuleTestExtension; +import org.junit.jupiter.api.extension.ExtensionContext; + +public class RabbitMQExtension implements GuiceModuleTestExtension { + + private final DockerRabbitMQRule rabbitMQRule = new DockerRabbitMQRule(); + + @Override + public void beforeAll(ExtensionContext extensionContext) { + rabbitMQRule.start(); + } + + @Override + public void afterAll(ExtensionContext extensionContext) { + rabbitMQRule.stop(); + } + + @Override + public Module getModule() { + return new TestRabbitMQModule(rabbitMQRule.dockerRabbitMQ()); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/TestRabbitMQModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/TestRabbitMQModule.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/TestRabbitMQModule.java new file mode 100644 index 0000000..c9cda53 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/TestRabbitMQModule.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.modules; + +import static org.apache.james.backend.rabbitmq.RabbitMQFixture.DEFAULT_MANAGEMENT_CREDENTIAL; + +import java.net.URISyntaxException; +import java.time.Duration; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.apache.james.CleanupTasksPerformer; +import org.apache.james.backend.rabbitmq.DockerRabbitMQ; +import org.apache.james.backend.rabbitmq.RabbitMQConfiguration; +import org.apache.james.queue.rabbitmq.RabbitMQManagementApi; +import org.apache.james.queue.rabbitmq.view.cassandra.configuration.CassandraMailQueueViewConfiguration; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.multibindings.Multibinder; + +public class TestRabbitMQModule extends AbstractModule { + + private final DockerRabbitMQ rabbitMQ; + + public TestRabbitMQModule(DockerRabbitMQ rabbitMQ) { + this.rabbitMQ = rabbitMQ; + } + + @Override + protected void configure() { + bind(CassandraMailQueueViewConfiguration.class).toInstance(CassandraMailQueueViewConfiguration + .builder() + .bucketCount(1) + .updateBrowseStartPace(1000) + .sliceWindow(Duration.ofHours(1)) + .build()); + + Multibinder.newSetBinder(binder(), CleanupTasksPerformer.CleanupTask.class) + .addBinding() + .to(QueueCleanUp.class); + } + + @Provides + @Singleton + protected RabbitMQConfiguration provideRabbitMQConfiguration() throws URISyntaxException { + return RabbitMQConfiguration.builder() + .amqpUri(rabbitMQ.amqpUri()) + .managementUri(rabbitMQ.managementUri()) + .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL) + .build(); + } + + public static class QueueCleanUp implements CleanupTasksPerformer.CleanupTask { + private final RabbitMQManagementApi api; + + @Inject + public QueueCleanUp(RabbitMQManagementApi api) { + this.api = api; + } + + @Override + public Result run() { + api.deleteAllQueues(); + + return Result.COMPLETED; + } + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/batchsizes.properties ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/batchsizes.properties b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/batchsizes.properties new file mode 100644 index 0000000..47da2c5 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/batchsizes.properties @@ -0,0 +1,10 @@ +# Those properties let you configure the number of messages queried at the same time. +# IMAP FETCH command +fetch.metadata=200 +fetch.headers=200 +fetch.body=100 +fetch.full=50 +# IMAP COPY command +copy=100 +# IMAP MOVE command +move=100 http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/dnsservice.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/dnsservice.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/dnsservice.xml new file mode 100644 index 0000000..0978a00 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/dnsservice.xml @@ -0,0 +1,29 @@ +<?xml version="1.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. + --> + +<dnsservice> + <servers> + <server>8.8.8.8</server> + <server>62.210.16.6</server> + </servers> + <autodiscover>false</autodiscover> + <authoritative>false</authoritative> + <maxcachesize>50000</maxcachesize> +</dnsservice> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/domainlist.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/domainlist.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/domainlist.xml new file mode 100644 index 0000000..fe17431 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/domainlist.xml @@ -0,0 +1,24 @@ +<?xml version="1.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. + --> + +<domainlist> + <autodetect>false</autodetect> + <autodetectIP>false</autodetectIP> +</domainlist> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/imapserver.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/imapserver.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/imapserver.xml new file mode 100644 index 0000000..509fdb3 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/imapserver.xml @@ -0,0 +1,54 @@ +<?xml version="1.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. +--> + + +<imapservers> + <imapserver enabled="true"> + <jmxName>imapserver</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>classpath://keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + </imapserver> + <imapserver enabled="true"> + <jmxName>imapserver-ssl</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="true"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>classpath://keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + </imapserver> +</imapservers> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/keystore ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/keystore b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/keystore new file mode 100644 index 0000000..536a6c7 Binary files /dev/null and b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/keystore differ http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/listeners.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/listeners.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/listeners.xml new file mode 100644 index 0000000..eabdb5e --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/listeners.xml @@ -0,0 +1,28 @@ +<?xml version="1.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. + --> + +<listeners> + <listener> + <class>org.apache.james.mailbox.spamassassin.SpamAssassinListener</class> + </listener> + <listener> + <class>org.apache.james.mailbox.cassandra.MailboxOperationLoggingListener</class> + </listener> +</listeners> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/lmtpserver.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/lmtpserver.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/lmtpserver.xml new file mode 100644 index 0000000..ffa6eae --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/lmtpserver.xml @@ -0,0 +1,41 @@ +<?xml version="1.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. + --> + +<lmtpservers> + + <lmtpserver enabled="true"> + <jmxName>lmtpserver</jmxName> + <!-- LMTP should not be reachable from outside your network so bind it to loopback--> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <connectiontimeout>1200</connectiontimeout> + <!-- Set the maximum simultaneous incoming connections for this service --> + <connectionLimit>0</connectionLimit> + <!-- Set the maximum simultaneous incoming connections per IP for this service --> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- This sets the maximum allowed message size (in kilobytes) for this --> + <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. --> + <maxmessagesize>0</maxmessagesize> + <handlerchain> + <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </lmtpserver> + +</lmtpservers> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/logback-test.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/logback-test.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/logback-test.xml new file mode 100644 index 0000000..56f9d51 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/logback-test.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + + <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"> + <resetJUL>true</resetJUL> + </contextListener> + + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern> + <immediateFlush>false</immediateFlush> + </encoder> + </appender> + + <root level="WARN"> + <appender-ref ref="CONSOLE" /> + </root> + + <logger name="org.apache.james" level="DEBUG"/> + + <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" /> + + <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" level="WARN" > + <appender-ref ref="CONSOLE" /> + </logger> + +</configuration> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailetcontainer.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailetcontainer.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailetcontainer.xml new file mode 100644 index 0000000..412e6e9 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailetcontainer.xml @@ -0,0 +1,146 @@ +<?xml version="1.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. + --> + +<mailetcontainer enableJmx="false"> + + <context> + <postmaster>postmas...@james.minet.net</postmaster> + </context> + + <spooler> + <threads>20</threads> + </spooler> + + <processors> + <processor state="root" enableJmx="false"> + <mailet match="All" class="PostmasterAlias"/> + <mailet match="RelayLimit=30" class="Null"/> + <mailet match="All" class="ToProcessor"> + <processor>transport</processor> + </mailet> + </processor> + + <processor state="error" enableJmx="false"> + <mailet match="All" class="Bounce"/> + <mailet match="All" class="ToRepository"> + <repositoryPath>file://var/mail/error/</repositoryPath> + </mailet> + </processor> + + + <processor state="transport" enableJmx="false"> + <matcher name="relay-allowed" match="org.apache.james.mailetcontainer.impl.matchers.Or"> + <matcher match="SMTPAuthSuccessful"/> + <matcher match="SMTPIsAuthNetwork"/> + <matcher match="SentByMailet"/> + <matcher match="org.apache.james.jmap.mailet.SentByJmap"/> + </matcher> + <mailet match="SenderIs=den...@other.com" class="ToProcessor"> + <processor>sender-denied</processor> + </mailet> + <mailet match="SMTPAuthSuccessful" class="SetMimeHeader"> + <name>X-UserIsAuth</name> + <value>true</value> + </mailet> + <mailet match="All" class="RemoveMimeHeader"> + <name>bcc</name> + </mailet> + <mailet match="All" class="RecipientRewriteTable"> + <errorProcessor>rrt-error</errorProcessor> + </mailet> + <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/> + <mailet match="RecipientIsLocal" class="SpamAssassin"> + <spamdHost>localhost</spamdHost> + <spamdPort>783</spamdPort> + </mailet> + <mailet match="IsMarkedAsSpam" class="WithStorageDirective"> + <targetFolderName>Spam</targetFolderName> + </mailet> + <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.filter.JMAPFiltering"/> + <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> + </mailet> + <mailet match="relay-allowed" class="RemoteDelivery"> + <outgoingQueue>outgoing</outgoingQueue> + <delayTime>5000, 100000, 500000</delayTime> + <maxRetries>25</maxRetries> + <maxDnsProblemRetries>0</maxDnsProblemRetries> + <deliveryThreads>10</deliveryThreads> + <sendpartial>true</sendpartial> + <bounceProcessor>bounces</bounceProcessor> + </mailet> + <mailet match="All" class="ToProcessor"> + <processor>relay-denied</processor> + </mailet> + </processor> + + <processor state="local-address-error" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + </mailet> + <mailet match="All" class="ToRepository"> + <repositoryPath>file://var/mail/address-error/</repositoryPath> + </mailet> + </processor> + + <processor state="relay-denied" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + </mailet> + <mailet match="All" class="ToRepository"> + <repositoryPath>file://var/mail/relay-denied/</repositoryPath> + <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice> + </mailet> + </processor> + + <processor state="sender-denied" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + <passThrough>true</passThrough> + </mailet> + <mailet match="All" class="ToRepository"> + <repositoryPath>cassandra://var/mail/sender-denied/</repositoryPath> + <notice>Error: You are sending an e-mail by a forbidden sender.</notice> + </mailet> + </processor> + + <processor state="bounces" enableJmx="false"> + <mailet match="All" class="DSNBounce"> + <passThrough>false</passThrough> + </mailet> + </processor> + + <processor state="rrt-error" enableJmx="false"> + <mailet match="All" class="ToRepository"> + <repositoryPath>cassandra://var/mail/rrt-error/</repositoryPath> + <passThrough>true</passThrough> + </mailet> + <mailet match="IsSenderInRRTLoop" class="Null"/> + <mailet match="All" class="Bounce"/> + </processor> + + </processors> + +</mailetcontainer> + + http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailrepositorystore.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailrepositorystore.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailrepositorystore.xml new file mode 100644 index 0000000..3386c33 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/mailrepositorystore.xml @@ -0,0 +1,36 @@ +<?xml version="1.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. + --> + +<mailrepositorystore> + <mailrepositories> + <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository"> + <protocols> + <protocol>file</protocol> + </protocols> + <config FIFO="false" CACHEKEYS="true"/> + </mailrepository> + <mailrepository class="org.apache.james.mailrepository.cassandra.CassandraMailRepository"> + <protocols> + <protocol>cassandra</protocol> + </protocols> + </mailrepository> + </mailrepositories> +</mailrepositorystore> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/managesieveserver.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/managesieveserver.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/managesieveserver.xml new file mode 100644 index 0000000..eee4052 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/managesieveserver.xml @@ -0,0 +1,65 @@ +<?xml version="1.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. + --> + +<!-- + This template file can be used as example for James Server configuration + DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS +--> + +<!-- See http://james.apache.org/server/3/config.html for usage --> + +<managesieveservers> + + <managesieveserver enabled="true"> + + <jmxName>managesieveserver</jmxName> + + <bind>0.0.0.0:0</bind> + + <connectionBacklog>200</connectionBacklog> + + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <!-- The algorithm is optional and only needs to be specified when using something other + than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. --> + <algorithm>SunX509</algorithm> + </tls> + + <!-- connection timeout in secconds --> + <connectiontimeout>360</connectiontimeout> + + <!-- Set the maximum simultaneous incoming connections for this service --> + <connectionLimit>0</connectionLimit> + + <!-- Set the maximum simultaneous incoming connections per IP for this service --> + <connectionLimitPerIP>0</connectionLimitPerIP> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + + </managesieveserver> + +</managesieveservers> + + http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/pop3server.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/pop3server.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/pop3server.xml new file mode 100644 index 0000000..595c313 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/pop3server.xml @@ -0,0 +1,42 @@ +<?xml version="1.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. + --> + + +<pop3servers> + <pop3server enabled="true"> + <jmxName>pop3server</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectiontimeout>1200</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <handlerchain> + <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/> + </handlerchain> + </pop3server> +</pop3servers> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/rabbitmq.properties ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/rabbitmq.properties b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/rabbitmq.properties new file mode 100644 index 0000000..25d0dd6 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/rabbitmq.properties @@ -0,0 +1,2 @@ +uri=amqp://james:james@rabbitmq_host:5672 +management.uri=http://james:james@rabbitmq_host:15672/api/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/smtpserver.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/smtpserver.xml b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/smtpserver.xml new file mode 100644 index 0000000..c348f04 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/smtpserver.xml @@ -0,0 +1,102 @@ +<?xml version="1.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. + --> + +<smtpservers> + <smtpserver enabled="true"> + <jmxName>smtpserver-global</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <authRequired>false</authRequired> + <verifyIdentity>true</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> + <smtpserver enabled="true"> + <jmxName>smtpserver-TLS</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- + Authorize only local users + --> + <authRequired>true</authRequired> + <!-- Trust authenticated users --> + <verifyIdentity>false</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> + <smtpserver enabled="true"> + <jmxName>smtpserver-authenticated</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- + Authorize only local users + --> + <authRequired>true</authRequired> + <!-- Trust authenticated users --> + <verifyIdentity>false</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> +</smtpservers> + + http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/spamassassin.properties ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/spamassassin.properties b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/spamassassin.properties new file mode 100644 index 0000000..134ed31 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/resources/spamassassin.properties @@ -0,0 +1,2 @@ +spamassassin.host=localhost +spamassassin.host=783 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/container/guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml index e57a43f..5c0375f 100644 --- a/server/container/guice/pom.xml +++ b/server/container/guice/pom.xml @@ -37,6 +37,7 @@ <module>blob-objectstorage-guice</module> <module>cassandra-guice</module> <module>cassandra-ldap-guice</module> + <module>cassandra-rabbitmq-guice</module> <module>configuration</module> <module>custom-mailets</module> <module>es-metric-reporter</module> http://git-wip-us.apache.org/repos/asf/james-project/blob/3efce9c8/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java ---------------------------------------------------------------------- diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java index ac3269c..1a992c6 100644 --- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java +++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java @@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import feign.Feign; import feign.Logger; +import feign.Param; import feign.RequestLine; import feign.RetryableException; import feign.Retryer; @@ -41,7 +42,7 @@ import feign.jackson.JacksonDecoder; import feign.jackson.JacksonEncoder; import feign.slf4j.Slf4jLogger; -class RabbitMQManagementApi { +public class RabbitMQManagementApi { private static final ErrorDecoder RETRY_500 = (methodKey, response) -> { if (response.status() == 500) { @@ -55,10 +56,16 @@ class RabbitMQManagementApi { class MessageQueue { @JsonProperty("name") String name; + + @JsonProperty("vhost") + String vhost; } @RequestLine("GET /api/queues") List<MessageQueue> listQueues(); + + @RequestLine(value = "DELETE /api/queues/{vhost}/{name}", decodeSlash = false) + void deleteQueue(@Param("vhost") String vhost, @Param("name") String name); } private final Api api; @@ -75,7 +82,6 @@ class RabbitMQManagementApi { .retryer(new Retryer.Default()) .errorDecoder(RETRY_500) .target(Api.class, configuration.getManagementUri().toString()); - } Stream<MailQueueName> listCreatedMailQueueNames() { @@ -87,4 +93,8 @@ class RabbitMQManagementApi { .distinct(); } + public void deleteAllQueues() { + api.listQueues() + .forEach(queue -> api.deleteQueue("/", queue.name)); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org