You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2018/06/06 07:00:55 UTC
[01/15] james-project git commit: JAMES-2409 JMAP download should
position Content-Length header before download starts
Repository: james-project
Updated Branches:
refs/heads/master 088870ebb -> f9bcbf907
JAMES-2409 JMAP download should position Content-Length header before download starts
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/52413375
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/52413375
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/52413375
Branch: refs/heads/master
Commit: 52413375164589fa02276762fa3835d42d82157c
Parents: 8b422da
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 11:47:46 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 5 11:48:55 2018 +0700
----------------------------------------------------------------------
.../integration/cucumber/DownloadStepdefs.java | 14 ++++++++++++++
.../src/test/resources/cucumber/DownloadGet.feature | 5 +++++
.../java/org/apache/james/jmap/DownloadServlet.java | 5 ++---
3 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/52413375/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java
index 2abf00b..a2aedfc 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java
@@ -22,6 +22,7 @@ package org.apache.james.jmap.methods.integration.cucumber;
import static org.apache.james.jmap.JmapURIBuilder.baseUri;
import static org.assertj.core.api.Assertions.assertThat;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -52,6 +53,7 @@ import org.apache.james.mime4j.codec.DecoderUtil;
import com.google.common.base.CharMatcher;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
+import com.google.common.base.Strings;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@@ -102,6 +104,18 @@ public class DownloadStepdefs {
inputToMessageId.put(messageId, composedMessageId.getMessageId());
}
+ @Given("^\"([^\"]*)\" mailbox \"([^\"]*)\" contains a big message \"([^\"]*)\"$")
+ public void appendBigMessageToMailbox(String user, String mailbox, String messageId) throws Throwable {
+ MailboxPath mailboxPath = MailboxPath.forUser(user, mailbox);
+
+ ComposedMessageId composedMessageId = mainStepdefs.mailboxProbe.appendMessage(user, mailboxPath,
+ AppendCommand.from(new ByteArrayInputStream(
+ Strings.repeat("header: 0123456789\r\n", 1024 * 1024)
+ .getBytes(StandardCharsets.UTF_8))));
+
+ inputToMessageId.put(messageId, composedMessageId.getMessageId());
+ }
+
@Given("^\"([^\"]*)\" mailbox \"([^\"]*)\" contains a message \"([^\"]*)\" with an attachment \"([^\"]*)\"$")
public void appendMessageWithAttachmentToMailbox(String user, String mailbox, String messageId, String attachmentId) throws Throwable {
MailboxPath mailboxPath = MailboxPath.forUser(user, mailbox);
http://git-wip-us.apache.org/repos/asf/james-project/blob/52413375/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
index 6b8155f..6a11038 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
@@ -55,6 +55,11 @@ Feature: Download GET
Then she can read that blob
And the blob size is 4963
+ Scenario: Getting a message blob previously stored
+ Given "alice@domain.tld" mailbox "INBOX" contains a big message "1"
+ When "alice@domain.tld" downloads "1"
+ Then the blob size is 20971520
+
Scenario: Getting a message then getting its blob
Given "alice@domain.tld" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail"
And "alice@domain.tld" ask for messages "m1"
http://git-wip-us.apache.org/repos/asf/james-project/blob/52413375/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java
index d9a6296..0c7f085 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java
@@ -123,13 +123,12 @@ public class DownloadServlet extends HttpServlet {
@VisibleForTesting void download(MailboxSession mailboxSession, DownloadPath downloadPath, HttpServletResponse resp) {
String blobId = downloadPath.getBlobId();
try {
- addContentDispositionHeader(downloadPath.getName(), resp);
-
Blob blob = blobManager.retrieve(BlobId.fromString(blobId), mailboxSession);
- IOUtils.copy(blob.getStream(), resp.getOutputStream());
+ addContentDispositionHeader(downloadPath.getName(), resp);
resp.setHeader("Content-Length", String.valueOf(blob.getSize()));
resp.setStatus(SC_OK);
+ IOUtils.copy(blob.getStream(), resp.getOutputStream());
} catch (BlobNotFoundException e) {
LOGGER.info("Attachment '{}' not found", blobId, e);
resp.setStatus(SC_NOT_FOUND);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[15/15] james-project git commit: JAMES-2406 Allow running a James
server that only does SMTP
Posted by ma...@apache.org.
JAMES-2406 Allow running a James server that only does SMTP
We should use this server as part of MPT SMTP tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d7d6070e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d7d6070e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d7d6070e
Branch: refs/heads/master
Commit: d7d6070ea837ad3c562c8ae5fe50322ab40f4657
Parents: 825ca96
Author: benwa <bt...@linagora.com>
Authored: Thu May 31 12:01:30 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 09:00:10 2018 +0200
----------------------------------------------------------------------
mpt/impl/smtp/cassandra/pom.xml | 12 ----
.../smtp/host/CassandraJamesSmtpHostSystem.java | 28 ++++++---
.../cassandra/src/test/resources/imapserver.xml | 54 ----------------
.../cassandra/src/test/resources/lmtpserver.xml | 41 ------------
.../src/test/resources/mailetcontainer.xml | 12 ----
.../src/test/resources/managesieveserver.xml | 65 --------------------
.../cassandra/src/test/resources/pop3server.xml | 42 -------------
.../apache/james/CassandraJamesServerMain.java | 15 +++--
.../modules/mailbox/CassandraMailboxModule.java | 2 -
.../mailbox/CassandraObjectStoreModule.java | 5 ++
.../modules/CassandraJmapServerModule.java | 17 +----
.../james/modules/CassandraTestModule.java | 55 +++++++++++++++++
12 files changed, 92 insertions(+), 256 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/mpt/impl/smtp/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/pom.xml b/mpt/impl/smtp/cassandra/pom.xml
index e9d82fd..be11a48 100644
--- a/mpt/impl/smtp/cassandra/pom.xml
+++ b/mpt/impl/smtp/cassandra/pom.xml
@@ -39,18 +39,6 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>apache-james-backends-es</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-tika</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mpt-core</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index 26a68fc..e4cd9fa 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -21,28 +21,36 @@ package org.apache.james.mpt.smtp.host;
import java.util.Iterator;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.james.CassandraJamesServerMain;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
import org.apache.james.dnsservice.api.DNSService;
import org.apache.james.dnsservice.api.InMemoryDNSService;
-import org.apache.james.mailbox.elasticsearch.MailboxElasticSearchConstants;
-import org.apache.james.modules.CassandraJmapServerModule;
+import org.apache.james.modules.CassandraTestModule;
import org.apache.james.modules.protocols.ProtocolHandlerModule;
+import org.apache.james.modules.protocols.SMTPServerModule;
+import org.apache.james.modules.server.CamelMailetContainerModule;
import org.apache.james.mpt.monitor.SystemLoggingMonitor;
import org.apache.james.mpt.session.ExternalSessionFactory;
import org.apache.james.mpt.smtp.SmtpHostSystem;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
import org.apache.james.server.core.configuration.Configuration;
import org.apache.james.utils.DataProbeImpl;
import org.junit.rules.TemporaryFolder;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory implements SmtpHostSystem {
+ private static final Module SMTP_PROTOCOL_MODULE = Modules.combine(
+ new ProtocolHandlerModule(),
+ new SMTPServerModule());
+
private TemporaryFolder folder;
- private EmbeddedElasticSearch embeddedElasticSearch;
private GuiceJamesServer jamesServer;
private InMemoryDNSService inMemoryDNSService;
@@ -84,8 +92,6 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
inMemoryDNSService = new InMemoryDNSService();
folder = new TemporaryFolder();
folder.create();
- embeddedElasticSearch = new EmbeddedElasticSearch(folder.getRoot().toPath(), MailboxElasticSearchConstants.DEFAULT_MAILBOX_INDEX);
- embeddedElasticSearch.before();
jamesServer = createJamesServer();
jamesServer.start();
}
@@ -93,7 +99,6 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
@Override
public void afterTest() {
jamesServer.stop();
- embeddedElasticSearch.after();
folder.delete();
}
@@ -109,8 +114,13 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
.build();
return new GuiceJamesServer(configuration)
- .combineWith(CassandraJamesServerMain.CASSANDRA_SERVER_MODULE, CassandraJamesServerMain.PROTOCOLS, new ProtocolHandlerModule())
- .overrideWith(new CassandraJmapServerModule(embeddedElasticSearch, cassandraHost, cassandraPort),
+ .combineWith(
+ CassandraJamesServerMain.CASSANDRA_SERVER_CORE_MODULE,
+ SMTP_PROTOCOL_MODULE,
+ binder -> binder.bind(MailQueueItemDecoratorFactory.class).to(RawMailQueueItemDecoratorFactory.class),
+ binder -> binder.bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
+ .toInstance(DefaultConfigurationBuilder::new))
+ .overrideWith(new CassandraTestModule(cassandraHost, cassandraPort),
(binder) -> binder.bind(DNSService.class).toInstance(inMemoryDNSService));
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/mpt/impl/smtp/cassandra/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/imapserver.xml b/mpt/impl/smtp/cassandra/src/test/resources/imapserver.xml
deleted file mode 100644
index 28ce44c..0000000
--- a/mpt/impl/smtp/cassandra/src/test/resources/imapserver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?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:1143</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>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
- <imapserver enabled="true">
- <jmxName>imapserver-ssl</jmxName>
- <bind>0.0.0.0:1993</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>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
-</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/mpt/impl/smtp/cassandra/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/lmtpserver.xml b/mpt/impl/smtp/cassandra/src/test/resources/lmtpserver.xml
deleted file mode 100644
index 5c4a9c7..0000000
--- a/mpt/impl/smtp/cassandra/src/test/resources/lmtpserver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?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>127.0.0.1:1024</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/d7d6070e/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml b/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
index 5aa2982..1a86820 100644
--- a/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
+++ b/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
@@ -63,7 +63,6 @@
<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
</mailet>
- <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/>
<mailet match="All" class="RecipientRewriteTable">
<errorProcessor>rrt-error</errorProcessor>
</mailet>
@@ -83,17 +82,6 @@
</mailet>
</processor>
- <processor state="local-address-error" enableJmx="true">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- <passThrough>true</passThrough>
- <debug>true</debug>
- </mailet>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/address-error/</repositoryPath>
- </mailet>
- </processor>
-
<processor state="relay-denied" enableJmx="true">
<mailet match="All" class="Bounce">
<attachment>none</attachment>
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/mpt/impl/smtp/cassandra/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/managesieveserver.xml b/mpt/impl/smtp/cassandra/src/test/resources/managesieveserver.xml
deleted file mode 100644
index ec57e09..0000000
--- a/mpt/impl/smtp/cassandra/src/test/resources/managesieveserver.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?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:4190</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/d7d6070e/mpt/impl/smtp/cassandra/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/pop3server.xml b/mpt/impl/smtp/cassandra/src/test/resources/pop3server.xml
deleted file mode 100644
index e4187da..0000000
--- a/mpt/impl/smtp/cassandra/src/test/resources/pop3server.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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:1110</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/d7d6070e/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index eac26ac..762ad8a 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -28,6 +28,7 @@ import org.apache.james.modules.data.CassandraSieveRepositoryModule;
import org.apache.james.modules.data.CassandraUsersRepositoryModule;
import org.apache.james.modules.eventstore.CassandraEventStoreModule;
import org.apache.james.modules.mailbox.CassandraMailboxModule;
+import org.apache.james.modules.mailbox.CassandraObjectStoreModule;
import org.apache.james.modules.mailbox.CassandraQuotaMailingModule;
import org.apache.james.modules.mailbox.CassandraSessionModule;
import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
@@ -68,6 +69,7 @@ public class CassandraJamesServerMain {
new WebAdminServerModule());
public static final Module PROTOCOLS = Modules.combine(
+ new CassandraJmapModule(),
new IMAPServerModule(),
new LMTPServerModule(),
new ManageSieveServerModule(),
@@ -80,18 +82,20 @@ public class CassandraJamesServerMain {
public static final Module PLUGINS = Modules.combine(
new CassandraQuotaMailingModule());
- public static final Module CASSANDRA_SERVER_MODULE = Modules.combine(
+ public static final Module CASSANDRA_SERVER_CORE_MODULE = Modules.combine(
new ActiveMQQueueModule(),
new CassandraDomainListModule(),
new CassandraEventStoreModule(),
- new CassandraJmapModule(),
- new CassandraMailboxModule(),
new CassandraMailRepositoryModule(),
new CassandraMetricsModule(),
+ new CassandraObjectStoreModule(),
new CassandraRecipientRewriteTableModule(),
new CassandraSessionModule(),
new CassandraSieveRepositoryModule(),
- new CassandraUsersRepositoryModule(),
+ new CassandraUsersRepositoryModule());
+
+ public static final Module CASSANDRA_MAILBOX_MODULE = Modules.combine(
+ new CassandraMailboxModule(),
new ElasticSearchMailboxModule(),
new ElasticSearchMetricReporterModule(),
new MailboxModule(),
@@ -99,7 +103,8 @@ public class CassandraJamesServerMain {
new SpamAssassinListenerModule());
public static Module ALL_BUT_JMX_CASSANDRA_MODULE = Modules.combine(
- CASSANDRA_SERVER_MODULE,
+ CASSANDRA_SERVER_CORE_MODULE,
+ CASSANDRA_MAILBOX_MODULE,
PROTOCOLS,
PLUGINS);
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 80db393..c742c38 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -93,7 +93,6 @@ public class CassandraMailboxModule extends AbstractModule {
protected void configure() {
install(new DefaultEventModule());
install(new CassandraQuotaModule());
- install(new CassandraObjectStoreModule());
bind(CassandraApplicableFlagDAO.class).in(Scopes.SINGLETON);
bind(CassandraAttachmentDAO.class).in(Scopes.SINGLETON);
@@ -157,7 +156,6 @@ public class CassandraMailboxModule extends AbstractModule {
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule.class);
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule.class);
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.blob.cassandra.CassandraBlobModule.class);
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule.class);
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule.class);
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule.class);
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraObjectStoreModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraObjectStoreModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraObjectStoreModule.java
index 4fad8e3..0e6d6fd 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraObjectStoreModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraObjectStoreModule.java
@@ -19,6 +19,7 @@
package org.apache.james.modules.mailbox;
+import org.apache.james.backends.cassandra.components.CassandraModule;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.ObjectStore;
import org.apache.james.blob.cassandra.CassandraBlobId;
@@ -26,6 +27,7 @@ import org.apache.james.blob.cassandra.CassandraBlobsDAO;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
public class CassandraObjectStoreModule extends AbstractModule {
@Override
@@ -35,5 +37,8 @@ public class CassandraObjectStoreModule extends AbstractModule {
bind(ObjectStore.class).to(CassandraBlobsDAO.class);
bind(BlobId.Factory.class).to(CassandraBlobId.Factory.class);
+
+ Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.blob.cassandra.CassandraBlobModule.class);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
index ee72ccd..1a21ca0 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
@@ -19,17 +19,11 @@
package org.apache.james.modules;
-import javax.inject.Singleton;
-
-import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.backends.es.EmbeddedElasticSearch;
import org.apache.james.mailbox.extractor.TextExtractor;
import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import com.datastax.driver.core.Session;
import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
public class CassandraJmapServerModule extends AbstractModule {
@@ -46,16 +40,11 @@ public class CassandraJmapServerModule extends AbstractModule {
@Override
protected void configure() {
+ install(new CassandraTestModule(cassandraHost, cassandraPort));
install(new TestElasticSearchModule(embeddedElasticSearch));
install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
+
install(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class));
- install(binder -> binder.bindConstant().annotatedWith(Names.named("cassandraHost")).to(cassandraHost));
- install(binder -> binder.bindConstant().annotatedWith(Names.named("cassandraPort")).to(cassandraPort));
- }
-
- @Provides
- @Singleton
- Session provideSession(CassandraCluster initializedCassandra) {
- return initializedCassandra.getConf();
}
+
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d7d6070e/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
new file mode 100644
index 0000000..6047b85
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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 javax.inject.Singleton;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+
+import com.datastax.driver.core.Session;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.name.Names;
+
+public class CassandraTestModule extends AbstractModule {
+ private final String cassandraHost;
+ private final int cassandraPort;
+
+ public CassandraTestModule(String cassandraHost, int cassandraPort) {
+ this.cassandraHost = cassandraHost;
+ this.cassandraPort = cassandraPort;
+ }
+
+ @Override
+ protected void configure() {
+ install(binder -> binder.bindConstant()
+ .annotatedWith(Names.named("cassandraHost"))
+ .to(cassandraHost));
+ install(binder -> binder.bindConstant()
+ .annotatedWith(Names.named("cassandraPort"))
+ .to(cassandraPort));
+ }
+
+ @Provides
+ @Singleton
+ Session provideSession(CassandraCluster initializedCassandra) {
+ return initializedCassandra.getConf();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[12/15] james-project git commit: JAMES-2406 Re-enable some manage
sieve tests
Posted by ma...@apache.org.
JAMES-2406 Re-enable some manage sieve tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9df48705
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9df48705
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9df48705
Branch: refs/heads/master
Commit: 9df48705dd6c1e188b98a59e7e3169d831ef4b7e
Parents: d7d6070
Author: benwa <bt...@linagora.com>
Authored: Thu May 31 12:03:58 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 09:00:10 2018 +0200
----------------------------------------------------------------------
mpt/impl/managesieve/cassandra/pom.xml | 14 --------------
mpt/impl/managesieve/file/pom.xml | 14 --------------
2 files changed, 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/9df48705/mpt/impl/managesieve/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/managesieve/cassandra/pom.xml b/mpt/impl/managesieve/cassandra/pom.xml
index bdefdac..521da37 100644
--- a/mpt/impl/managesieve/cassandra/pom.xml
+++ b/mpt/impl/managesieve/cassandra/pom.xml
@@ -51,18 +51,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/suite/*.java</exclude>
- <exclude>**/suite/**/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9df48705/mpt/impl/managesieve/file/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/managesieve/file/pom.xml b/mpt/impl/managesieve/file/pom.xml
index a0d633d..339e6a2 100644
--- a/mpt/impl/managesieve/file/pom.xml
+++ b/mpt/impl/managesieve/file/pom.xml
@@ -45,18 +45,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/suite/*.java</exclude>
- <exclude>**/suite/**/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[08/15] james-project git commit: JAMES-2408 DeleteByQueryPerformer:
remove uneeded constructor
Posted by ma...@apache.org.
JAMES-2408 DeleteByQueryPerformer: remove uneeded constructor
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6033c3f7
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6033c3f7
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6033c3f7
Branch: refs/heads/master
Commit: 6033c3f761f4bb45ac3e66866b63d226318613cb
Parents: 7ce70f5
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 14:40:58 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../org/apache/james/backends/es/DeleteByQueryPerformer.java | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/6033c3f7/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
index b5923aa..5fbd7b3 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
@@ -35,7 +35,6 @@ import org.elasticsearch.search.SearchHit;
import com.google.common.annotations.VisibleForTesting;
public class DeleteByQueryPerformer {
- public static final int DEFAULT_BATCH_SIZE = 100;
public static final TimeValue TIMEOUT = new TimeValue(60000);
private final Client client;
@@ -44,11 +43,6 @@ public class DeleteByQueryPerformer {
private final AliasName aliasName;
private final TypeName typeName;
- public DeleteByQueryPerformer(Client client, ExecutorService executor,
- AliasName aliasName, TypeName typeName) {
- this(client, executor, DEFAULT_BATCH_SIZE, aliasName, typeName);
- }
-
@VisibleForTesting
public DeleteByQueryPerformer(Client client, ExecutorService executor, int batchSize, AliasName aliasName, TypeName typeName) {
this.client = client;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[04/15] james-project git commit: JAMES-2408 A static variable was
not final in ElasticSearchIndexer
Posted by ma...@apache.org.
JAMES-2408 A static variable was not final in ElasticSearchIndexer
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c260053f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c260053f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c260053f
Branch: refs/heads/master
Commit: c260053f3661625def5a100098729c5fa9073e41
Parents: 86a4395
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 14:42:51 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/james/backends/es/ElasticSearchIndexer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c260053f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
index 3f62e0c..b5caad1 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -37,7 +37,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
public class ElasticSearchIndexer {
- private static int DEBUG_MAX_LENGTH_CONTENT = 1000;
+ private static final int DEBUG_MAX_LENGTH_CONTENT = 1000;
private static final int DEFAULT_BATCH_SIZE = 100;
private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchIndexer.class);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[02/15] james-project git commit: Merge remote-tracking branch
'linagora/pr/1453'
Posted by ma...@apache.org.
Merge remote-tracking branch 'linagora/pr/1453'
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/056bf993
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/056bf993
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/056bf993
Branch: refs/heads/master
Commit: 056bf993e503d65203801d05902cc767927e753b
Parents: 088870e 5241337
Author: Matthieu Baechler <ma...@apache.org>
Authored: Wed Jun 6 08:57:24 2018 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:57:24 2018 +0200
----------------------------------------------------------------------
.../integration/cucumber/DownloadStepdefs.java | 14 ++++++++++++++
.../src/test/resources/cucumber/DownloadGet.feature | 5 +++++
.../java/org/apache/james/jmap/DownloadServlet.java | 5 ++---
3 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[05/15] james-project git commit: JAMES-2408 DeleteByQueryPerformer:
should rely on a Write Alias
Posted by ma...@apache.org.
JAMES-2408 DeleteByQueryPerformer: should rely on a Write Alias
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/86a4395b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/86a4395b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/86a4395b
Branch: refs/heads/master
Commit: 86a4395bd3dd5e390be5376ca09a4d0245bafd75
Parents: 6033c3f
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 14:41:39 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../org/apache/james/backends/es/DeleteByQueryPerformer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/86a4395b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
index 5fbd7b3..b465f96 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
@@ -40,11 +40,11 @@ public class DeleteByQueryPerformer {
private final Client client;
private final ExecutorService executor;
private final int batchSize;
- private final AliasName aliasName;
+ private final WriteAliasName aliasName;
private final TypeName typeName;
@VisibleForTesting
- public DeleteByQueryPerformer(Client client, ExecutorService executor, int batchSize, AliasName aliasName, TypeName typeName) {
+ public DeleteByQueryPerformer(Client client, ExecutorService executor, int batchSize, WriteAliasName aliasName, TypeName typeName) {
this.client = client;
this.executor = executor;
this.batchSize = batchSize;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[09/15] james-project git commit: JAMES-2408 AliasName constructor
should be protected
Posted by ma...@apache.org.
JAMES-2408 AliasName constructor should be protected
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f41382e9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f41382e9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f41382e9
Branch: refs/heads/master
Commit: f41382e934bed874d17d42beabed61c206d69e67
Parents: 92829a2
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 11:16:34 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/james/backends/es/AliasName.java | 2 +-
.../james/backends/es/IndexCreationFactoryTest.java | 2 +-
.../james/backends/es/NodeMappingFactoryTest.java | 2 +-
.../james/backends/es/search/ScrollIterableTest.java | 3 ++-
.../mailbox/ElasticSearchConfigurationTest.java | 13 ++++++-------
5 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f41382e9/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/AliasName.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/AliasName.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/AliasName.java
index 80e934a..3f1438d 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/AliasName.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/AliasName.java
@@ -24,7 +24,7 @@ import java.util.Objects;
public class AliasName {
private final String value;
- public AliasName(String value) {
+ protected AliasName(String value) {
this.value = value;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f41382e9/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
index e0b3271..012914e 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
@@ -30,7 +30,7 @@ import org.junit.rules.TemporaryFolder;
public class IndexCreationFactoryTest {
public static final IndexName INDEX_NAME = new IndexName("index");
- public static final AliasName ALIAS_NAME = new AliasName("alias");
+ public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
private TemporaryFolder temporaryFolder = new TemporaryFolder();
private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f41382e9/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
index da93d0e..d6920af 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
@@ -32,7 +32,7 @@ import org.junit.rules.TemporaryFolder;
public class NodeMappingFactoryTest {
public static final String MESSAGE = "message";
public static final IndexName INDEX_NAME = new IndexName("index");
- public static final AliasName ALIAS_NAME = new AliasName("alias");
+ public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
public static final TypeName TYPE_NAME = new TypeName("type");
private TemporaryFolder temporaryFolder = new TemporaryFolder();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f41382e9/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
index f23a059..cd99e90 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
@@ -34,6 +34,7 @@ import org.apache.james.backends.es.EmbeddedElasticSearch;
import org.apache.james.backends.es.IndexCreationFactory;
import org.apache.james.backends.es.IndexName;
import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.ReadAliasName;
import org.apache.james.backends.es.TypeName;
import org.apache.james.backends.es.utils.TestingClientProvider;
import org.elasticsearch.action.search.SearchRequestBuilder;
@@ -53,7 +54,7 @@ public class ScrollIterableTest {
public static final int SIZE = 2;
public static final String MESSAGE = "message";
public static final IndexName INDEX_NAME = new IndexName("index");
- public static final AliasName ALIAS_NAME = new AliasName("alias");
+ public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
public static final TypeName TYPE_NAME = new TypeName("messages");
private TemporaryFolder temporaryFolder = new TemporaryFolder();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f41382e9/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchConfigurationTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchConfigurationTest.java
index bcaae13..dd03104 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchConfigurationTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchConfigurationTest.java
@@ -26,7 +26,6 @@ import java.util.Optional;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.backends.es.AliasName;
import org.apache.james.backends.es.IndexName;
import org.apache.james.backends.es.ReadAliasName;
import org.apache.james.backends.es.WriteAliasName;
@@ -197,7 +196,7 @@ public class ElasticSearchConfigurationTest {
ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration);
assertThat(elasticSearchConfiguration.getReadAliasMailboxName())
- .isEqualTo(new AliasName(name));
+ .isEqualTo(new ReadAliasName(name));
}
@Test
@@ -210,7 +209,7 @@ public class ElasticSearchConfigurationTest {
ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration);
assertThat(elasticSearchConfiguration.getReadAliasMailboxName())
- .isEqualTo(new AliasName(name));
+ .isEqualTo(new ReadAliasName(name));
}
@Test
@@ -224,7 +223,7 @@ public class ElasticSearchConfigurationTest {
ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration);
assertThat(elasticSearchConfiguration.getReadAliasMailboxName())
- .isEqualTo(new AliasName(name));
+ .isEqualTo(new ReadAliasName(name));
}
@Test
@@ -248,7 +247,7 @@ public class ElasticSearchConfigurationTest {
ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration);
assertThat(elasticSearchConfiguration.getWriteAliasMailboxName())
- .isEqualTo(new AliasName(name));
+ .isEqualTo(new WriteAliasName(name));
}
@Test
@@ -261,7 +260,7 @@ public class ElasticSearchConfigurationTest {
ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration);
assertThat(elasticSearchConfiguration.getWriteAliasMailboxName())
- .isEqualTo(new AliasName(name));
+ .isEqualTo(new WriteAliasName(name));
}
@Test
@@ -275,7 +274,7 @@ public class ElasticSearchConfigurationTest {
ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration);
assertThat(elasticSearchConfiguration.getWriteAliasMailboxName())
- .isEqualTo(new AliasName(name));
+ .isEqualTo(new WriteAliasName(name));
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[10/15] james-project git commit: JAMES-2408 DeleteByQueryPerformer
should return a Void
Posted by ma...@apache.org.
JAMES-2408 DeleteByQueryPerformer should return a Void
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7ce70f52
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7ce70f52
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7ce70f52
Branch: refs/heads/master
Commit: 7ce70f52cc5db72d5c03e2a5fc962bded2be2b49
Parents: f41382e
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 14:40:22 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../org/apache/james/backends/es/DeleteByQueryPerformer.java | 5 +++--
.../java/org/apache/james/backends/es/ElasticSearchIndexer.java | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/7ce70f52/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
index f78d80f..b5923aa 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
@@ -58,11 +58,11 @@ public class DeleteByQueryPerformer {
this.typeName = typeName;
}
- public Future<?> perform(QueryBuilder queryBuilder) {
+ public Future<Void> perform(QueryBuilder queryBuilder) {
return executor.submit(() -> doDeleteByQuery(queryBuilder));
}
- protected void doDeleteByQuery(QueryBuilder queryBuilder) {
+ protected Void doDeleteByQuery(QueryBuilder queryBuilder) {
new ScrollIterable(client,
client.prepareSearch(aliasName.getValue())
.setTypes(typeName.getValue())
@@ -73,6 +73,7 @@ public class DeleteByQueryPerformer {
.stream()
.map(searchResponse -> deleteRetrievedIds(client, searchResponse))
.forEach(ListenableActionFuture::actionGet);
+ return null;
}
private ListenableActionFuture<BulkResponse> deleteRetrievedIds(Client client, SearchResponse searchResponse) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/7ce70f52/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
index ae61a9f..3f62e0c 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -106,7 +106,7 @@ public class ElasticSearchIndexer {
}
}
- public Future<?> deleteAllMatchingQuery(QueryBuilder queryBuilder) {
+ public Future<Void> deleteAllMatchingQuery(QueryBuilder queryBuilder) {
return deleteByQueryPerformer.perform(queryBuilder);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[07/15] james-project git commit: JAMES-2408 Allow one to await the
execution of ElasticSearchIndexer::deleteAll
Posted by ma...@apache.org.
JAMES-2408 Allow one to await the execution of ElasticSearchIndexer::deleteAll
Note that this is used in case of mailbox deletions to delete messages that are anyway not accessible anymore, as a background task.
However, we might have an embedded ElasticSearch not being active while the deleteByQuery is not finished yet, leading to test failures. Awaiting the task solves this issue.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/92829a20
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/92829a20
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/92829a20
Branch: refs/heads/master
Commit: 92829a20cac4c7133da48ed8d6d98e8c1cb48a70
Parents: b902c20
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 11:09:13 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../org/apache/james/backends/es/DeleteByQueryPerformer.java | 5 +++--
.../org/apache/james/backends/es/ElasticSearchIndexer.java | 5 +++--
.../apache/james/backends/es/ElasticSearchIndexerTest.java | 8 ++++----
3 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/92829a20/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
index 024511b..f78d80f 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
@@ -20,6 +20,7 @@
package org.apache.james.backends.es;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
import org.apache.james.backends.es.search.ScrollIterable;
import org.elasticsearch.action.ListenableActionFuture;
@@ -57,8 +58,8 @@ public class DeleteByQueryPerformer {
this.typeName = typeName;
}
- public void perform(QueryBuilder queryBuilder) {
- executor.execute(() -> doDeleteByQuery(queryBuilder));
+ public Future<?> perform(QueryBuilder queryBuilder) {
+ return executor.submit(() -> doDeleteByQuery(queryBuilder));
}
protected void doDeleteByQuery(QueryBuilder queryBuilder) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/92829a20/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
index 009e331..ae61a9f 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -21,6 +21,7 @@ package org.apache.james.backends.es;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
@@ -105,8 +106,8 @@ public class ElasticSearchIndexer {
}
}
- public void deleteAllMatchingQuery(QueryBuilder queryBuilder) {
- deleteByQueryPerformer.perform(queryBuilder);
+ public Future<?> deleteAllMatchingQuery(QueryBuilder queryBuilder) {
+ return deleteByQueryPerformer.perform(queryBuilder);
}
private void checkArgument(String content) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/92829a20/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index d5121e0..544389d 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -140,14 +140,14 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void deleteByQueryShouldWorkOnSingleMessage() {
+ public void deleteByQueryShouldWorkOnSingleMessage() throws Exception {
String messageId = "1:2";
String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
testee.index(messageId, content);
embeddedElasticSearch.awaitForElasticSearch();
- testee.deleteAllMatchingQuery(termQuery("property", "1"));
+ testee.deleteAllMatchingQuery(termQuery("property", "1")).get();
embeddedElasticSearch.awaitForElasticSearch();
try (Client client = node.client()) {
@@ -160,7 +160,7 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void deleteByQueryShouldWorkWhenMultipleMessages() {
+ public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception {
String messageId = "1:1";
String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
@@ -177,7 +177,7 @@ public class ElasticSearchIndexerTest {
testee.index(messageId3, content3);
embeddedElasticSearch.awaitForElasticSearch();
- testee.deleteAllMatchingQuery(termQuery("property", "1"));
+ testee.deleteAllMatchingQuery(termQuery("property", "1")).get();
embeddedElasticSearch.awaitForElasticSearch();
try (Client client = node.client()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[06/15] james-project git commit: JAMES-2408 Enforce strong typing on
all constructor of ElasticSearchIndexer
Posted by ma...@apache.org.
JAMES-2408 Enforce strong typing on all constructor of ElasticSearchIndexer
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b902c20e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b902c20e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b902c20e
Branch: refs/heads/master
Commit: b902c20e3f2155766a6fc8de777098d5a43d9baa
Parents: 84b7b75
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 11:01:27 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:57 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/james/backends/es/ElasticSearchIndexer.java | 2 +-
.../org/apache/james/backends/es/ElasticSearchIndexerTest.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b902c20e/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
index 039b109..009e331 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -54,7 +54,7 @@ public class ElasticSearchIndexer {
@VisibleForTesting
public ElasticSearchIndexer(Client client, ExecutorService executor,
- AliasName aliasName,
+ WriteAliasName aliasName,
TypeName typeName,
int batchSize) {
this.client = client;
http://git-wip-us.apache.org/repos/asf/james-project/blob/b902c20e/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index 539272b..d5121e0 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -42,7 +42,7 @@ public class ElasticSearchIndexerTest {
private static final int MINIMUM_BATCH_SIZE = 1;
private static final IndexName INDEX_NAME = new IndexName("index_name");
- private static final AliasName ALIAS_NAME = new AliasName("alias_name");
+ private static final WriteAliasName ALIAS_NAME = new WriteAliasName("alias_name");
private static final TypeName TYPE_NAME = new TypeName("type_name");
private TemporaryFolder temporaryFolder = new TemporaryFolder();
private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[13/15] james-project git commit: JAMES-2406 Use Host instead of
Cassandra IP and port
Posted by ma...@apache.org.
JAMES-2406 Use Host instead of Cassandra IP and port
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a1c8bfc2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a1c8bfc2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a1c8bfc2
Branch: refs/heads/master
Commit: a1c8bfc209dc473af7c1c0d85a47cc5f68f081c8
Parents: 9df4870
Author: benwa <bt...@linagora.com>
Authored: Thu May 31 16:52:59 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 09:00:10 2018 +0200
----------------------------------------------------------------------
.../james/backends/cassandra/DockerCassandraRule.java | 7 +++++++
.../apache/james/mpt/smtp/CassandraForwardSmtpTest.java | 2 +-
.../james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java | 2 +-
.../java/org/apache/james/mpt/smtp/SmtpTestModule.java | 11 +++++------
.../mpt/smtp/host/CassandraJamesSmtpHostSystem.java | 9 ++++-----
.../apache/james/modules/CassandraJmapServerModule.java | 9 ++++-----
.../org/apache/james/modules/CassandraTestModule.java | 11 +++++------
.../james/jmap/cassandra/cucumber/CassandraStepdefs.java | 2 +-
8 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
index 327fa78..a612e86 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
@@ -20,6 +20,7 @@
package org.apache.james.backends.cassandra;
import org.apache.commons.text.RandomStringGenerator;
+import org.apache.james.util.Host;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -125,6 +126,12 @@ public class DockerCassandraRule implements TestRule {
deleteTmpsFsCmd.exec();
}
}
+
+ public Host getHost() {
+ return Host.from(
+ getIp(),
+ getBindingPort());
+ }
public String getIp() {
return cassandraContainer.getContainerIpAddress();
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
index fdadf26..6f82b82 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
@@ -37,7 +37,7 @@ public class CassandraForwardSmtpTest extends ForwardSmtpTest {
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(
- new SmtpTestModule(SmtpTestModule.Port.SMTP, cassandraServer.getIp(), cassandraServer.getBindingPort()));
+ new SmtpTestModule(SmtpTestModule.Port.SMTP, cassandraServer.getHost()));
system = injector.getInstance(SmtpHostSystem.class);
system.beforeTest();
super.setUp();
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
index d448f42..e76ff05 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
@@ -37,7 +37,7 @@ public class CassandraSmtpStarttlsCommandTest extends SmtpStarttlsCommandTest {
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(
- new SmtpTestModule(SmtpTestModule.Port.SMTP_START_TTLS, cassandraServer.getIp(), cassandraServer.getBindingPort()));
+ new SmtpTestModule(SmtpTestModule.Port.SMTP_START_TTLS, cassandraServer.getHost()));
system = injector.getInstance(SmtpHostSystem.class);
system.beforeTest();
super.setUp();
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
index d383838..eea9106 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
@@ -19,6 +19,7 @@
package org.apache.james.mpt.smtp;
import org.apache.james.mpt.smtp.host.CassandraJamesSmtpHostSystem;
+import org.apache.james.util.Host;
import com.google.inject.AbstractModule;
@@ -34,20 +35,18 @@ public class SmtpTestModule extends AbstractModule {
this.port = port;
}
}
-
+
private final Port smtpPort;
- private final String cassandraHost;
- private final int cassandraPort;
+ private final Host cassandraHost;
- public SmtpTestModule(Port smtpPort, String cassandraHost, int cassandraPort) {
+ public SmtpTestModule(Port smtpPort, Host cassandraHost) {
this.smtpPort = smtpPort;
this.cassandraHost = cassandraHost;
- this.cassandraPort = cassandraPort;
}
@Override
protected void configure() {
- bind(SmtpHostSystem.class).toInstance(new CassandraJamesSmtpHostSystem(smtpPort.port, cassandraHost, cassandraPort));
+ bind(SmtpHostSystem.class).toInstance(new CassandraJamesSmtpHostSystem(smtpPort.port, cassandraHost));
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index e4cd9fa..86dcd33 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -36,6 +36,7 @@ import org.apache.james.mpt.smtp.SmtpHostSystem;
import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
import org.apache.james.server.core.configuration.Configuration;
+import org.apache.james.util.Host;
import org.apache.james.utils.DataProbeImpl;
import org.junit.rules.TemporaryFolder;
@@ -54,14 +55,12 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
private GuiceJamesServer jamesServer;
private InMemoryDNSService inMemoryDNSService;
- private final String cassandraHost;
- private final int cassandraPort;
+ private final Host cassandraHost;
- public CassandraJamesSmtpHostSystem(int smtpPort, String cassandraHost, int cassandraPort) {
+ public CassandraJamesSmtpHostSystem(int smtpPort, Host cassandraHost) {
super("localhost", smtpPort, new SystemLoggingMonitor(), "220 mydomain.tld smtp");
this.cassandraHost = cassandraHost;
- this.cassandraPort = cassandraPort;
}
@Override
@@ -120,7 +119,7 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
binder -> binder.bind(MailQueueItemDecoratorFactory.class).to(RawMailQueueItemDecoratorFactory.class),
binder -> binder.bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
.toInstance(DefaultConfigurationBuilder::new))
- .overrideWith(new CassandraTestModule(cassandraHost, cassandraPort),
+ .overrideWith(new CassandraTestModule(cassandraHost),
(binder) -> binder.bind(DNSService.class).toInstance(inMemoryDNSService));
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
index 1a21ca0..23cebc4 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
@@ -22,6 +22,7 @@ package org.apache.james.modules;
import org.apache.james.backends.es.EmbeddedElasticSearch;
import org.apache.james.mailbox.extractor.TextExtractor;
import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
+import org.apache.james.util.Host;
import com.google.inject.AbstractModule;
@@ -29,18 +30,16 @@ public class CassandraJmapServerModule extends AbstractModule {
private static final int LIMIT_TO_3_MESSAGES = 3;
private final EmbeddedElasticSearch embeddedElasticSearch;
- private final String cassandraHost;
- private final int cassandraPort;
+ private final Host cassandraHost;
- public CassandraJmapServerModule(EmbeddedElasticSearch embeddedElasticSearch, String cassandraHost, int cassandraPort) {
+ public CassandraJmapServerModule(EmbeddedElasticSearch embeddedElasticSearch, Host cassandraHost) {
this.embeddedElasticSearch = embeddedElasticSearch;
this.cassandraHost = cassandraHost;
- this.cassandraPort = cassandraPort;
}
@Override
protected void configure() {
- install(new CassandraTestModule(cassandraHost, cassandraPort));
+ install(new CassandraTestModule(cassandraHost));
install(new TestElasticSearchModule(embeddedElasticSearch));
install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
index 6047b85..d2a1415 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
@@ -22,6 +22,7 @@ package org.apache.james.modules;
import javax.inject.Singleton;
import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.util.Host;
import com.datastax.driver.core.Session;
import com.google.inject.AbstractModule;
@@ -29,22 +30,20 @@ import com.google.inject.Provides;
import com.google.inject.name.Names;
public class CassandraTestModule extends AbstractModule {
- private final String cassandraHost;
- private final int cassandraPort;
+ private final Host cassandraHost;
- public CassandraTestModule(String cassandraHost, int cassandraPort) {
+ public CassandraTestModule(Host cassandraHost) {
this.cassandraHost = cassandraHost;
- this.cassandraPort = cassandraPort;
}
@Override
protected void configure() {
install(binder -> binder.bindConstant()
.annotatedWith(Names.named("cassandraHost"))
- .to(cassandraHost));
+ .to(cassandraHost.getHostName()));
install(binder -> binder.bindConstant()
.annotatedWith(Names.named("cassandraPort"))
- .to(cassandraPort));
+ .to(cassandraHost.getPort()));
}
@Provides
http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
index 0b17454..cc6f34d 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
@@ -71,7 +71,7 @@ public class CassandraStepdefs {
mainStepdefs.jmapServer = new GuiceJamesServer(configuration)
.combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
- .overrideWith(new CassandraJmapServerModule(embeddedElasticSearch, cassandraServer.getIp(), cassandraServer.getBindingPort()))
+ .overrideWith(new CassandraJmapServerModule(embeddedElasticSearch, cassandraServer.getHost()))
.overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class));
mainStepdefs.awaitMethod = () -> embeddedElasticSearch.awaitForElasticSearch();
mainStepdefs.init();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[11/15] james-project git commit: JAMES-2406 Maven should run
Cassandra SMTP MPT tests
Posted by ma...@apache.org.
JAMES-2406 Maven should run Cassandra SMTP MPT tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/825ca96d
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/825ca96d
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/825ca96d
Branch: refs/heads/master
Commit: 825ca96db2ed33adea2026934380ead05e4c651e
Parents: c260053
Author: benwa <bt...@linagora.com>
Authored: Thu May 31 11:59:25 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 09:00:03 2018 +0200
----------------------------------------------------------------------
mpt/impl/smtp/cassandra/pom.xml | 37 ++++++++++--------------------------
1 file changed, 10 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/825ca96d/mpt/impl/smtp/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/pom.xml b/mpt/impl/smtp/cassandra/pom.xml
index b2c534c..e9d82fd 100644
--- a/mpt/impl/smtp/cassandra/pom.xml
+++ b/mpt/impl/smtp/cassandra/pom.xml
@@ -30,10 +30,6 @@
<name>Apache James MPT SMTP Cassandra</name>
- <properties>
- <cassandra.includes>empty</cassandra.includes>
- </properties>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -94,32 +90,19 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</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-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/suite/*.java</exclude>
- <exclude>**/suite/**/*.java</exclude>
- </excludes>
- <includes>
- <include>${cassandra.includes}</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[03/15] james-project git commit: JAMES-2408 Enhance
ElasticSearchIndexerTest
Posted by ma...@apache.org.
JAMES-2408 Enhance ElasticSearchIndexerTest
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/84b7b75e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/84b7b75e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/84b7b75e
Branch: refs/heads/master
Commit: 84b7b75e734af8551ba87e5acb2edd54c2d30104
Parents: 056bf99
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 5 10:59:56 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 08:58:56 2018 +0200
----------------------------------------------------------------------
.../backends/es/ElasticSearchIndexerTest.java | 64 +++++++++++---------
1 file changed, 35 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/84b7b75e/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index e05b35c..539272b 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -20,6 +20,7 @@
package org.apache.james.backends.es;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import java.util.concurrent.Executors;
@@ -35,7 +36,7 @@ import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TemporaryFolder;
-import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableList;
public class ElasticSearchIndexerTest {
@@ -64,7 +65,7 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void indexMessageShouldWork() throws Exception {
+ public void indexMessageShouldWork() {
String messageId = "1";
String content = "{\"message\": \"trying out Elasticsearch\"}";
@@ -80,20 +81,21 @@ public class ElasticSearchIndexerTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void indexMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
- testee.index("1", null);
+ @Test
+ public void indexMessageShouldThrowWhenJsonIsNull() {
+ assertThatThrownBy(() -> testee.index("1", null))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void updateMessages() throws Exception {
+ public void updateMessages() {
String messageId = "1";
String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}";
testee.index(messageId, content);
embeddedElasticSearch.awaitForElasticSearch();
- testee.update(Lists.newArrayList(new UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
+ testee.update(ImmutableList.of(new UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
embeddedElasticSearch.awaitForElasticSearch();
try (Client client = node.client()) {
@@ -113,28 +115,32 @@ public class ElasticSearchIndexerTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void updateMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
- testee.update(Lists.newArrayList(new UpdatedRepresentation("1", null)));
+ @Test
+ public void updateMessageShouldThrowWhenJsonIsNull() {
+ assertThatThrownBy(() -> testee.update(ImmutableList.of(new UpdatedRepresentation("1", null))))
+ .isInstanceOf(IllegalArgumentException.class);
}
- @Test(expected = IllegalArgumentException.class)
- public void updateMessageShouldThrowWhenIdIsNull() throws InterruptedException {
- testee.update(Lists.newArrayList(new UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}")));
+ @Test
+ public void updateMessageShouldThrowWhenIdIsNull() {
+ assertThatThrownBy(() -> testee.update(ImmutableList.of(new UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}"))))
+ .isInstanceOf(IllegalArgumentException.class);
}
- @Test(expected = IllegalArgumentException.class)
- public void updateMessageShouldThrowWhenJsonIsEmpty() throws InterruptedException {
- testee.update(Lists.newArrayList(new UpdatedRepresentation("1", "")));
+ @Test
+ public void updateMessageShouldThrowWhenJsonIsEmpty() {
+ assertThatThrownBy(() -> testee.update(ImmutableList.of(new UpdatedRepresentation("1", ""))))
+ .isInstanceOf(IllegalArgumentException.class);
}
- @Test(expected = IllegalArgumentException.class)
- public void updateMessageShouldThrowWhenIdIsEmpty() throws InterruptedException {
- testee.update(Lists.newArrayList(new UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}")));
+ @Test
+ public void updateMessageShouldThrowWhenIdIsEmpty() {
+ assertThatThrownBy(() -> testee.update(ImmutableList.of(new UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}"))))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void deleteByQueryShouldWorkOnSingleMessage() throws Exception {
+ public void deleteByQueryShouldWorkOnSingleMessage() {
String messageId = "1:2";
String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
@@ -154,7 +160,7 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception {
+ public void deleteByQueryShouldWorkWhenMultipleMessages() {
String messageId = "1:1";
String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
@@ -184,14 +190,14 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void deleteMessage() throws Exception {
+ public void deleteMessage() {
String messageId = "1:2";
String content = "{\"message\": \"trying out Elasticsearch\"}";
testee.index(messageId, content);
embeddedElasticSearch.awaitForElasticSearch();
- testee.delete(Lists.newArrayList(messageId));
+ testee.delete(ImmutableList.of(messageId));
embeddedElasticSearch.awaitForElasticSearch();
try (Client client = node.client()) {
@@ -204,7 +210,7 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void deleteShouldWorkWhenMultipleMessages() throws Exception {
+ public void deleteShouldWorkWhenMultipleMessages() {
String messageId = "1:1";
String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
@@ -221,7 +227,7 @@ public class ElasticSearchIndexerTest {
testee.index(messageId3, content3);
embeddedElasticSearch.awaitForElasticSearch();
- testee.delete(Lists.newArrayList(messageId, messageId3));
+ testee.delete(ImmutableList.of(messageId, messageId3));
embeddedElasticSearch.awaitForElasticSearch();
try (Client client = node.client()) {
@@ -234,12 +240,12 @@ public class ElasticSearchIndexerTest {
}
@Test
- public void updateMessagesShouldNotThrowWhenEmptyList() throws Exception {
- testee.update(Lists.newArrayList());
+ public void updateMessagesShouldNotThrowWhenEmptyList() {
+ testee.update(ImmutableList.of());
}
@Test
- public void deleteMessagesShouldNotThrowWhenEmptyList() throws Exception {
- testee.delete(Lists.newArrayList());
+ public void deleteMessagesShouldNotThrowWhenEmptyList() {
+ testee.delete(ImmutableList.of());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[14/15] james-project git commit: JAMES-2406 String typing for SMTP
port
Posted by ma...@apache.org.
JAMES-2406 String typing for SMTP port
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f9bcbf90
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f9bcbf90
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f9bcbf90
Branch: refs/heads/master
Commit: f9bcbf9070a02e6c90f6f6d88710192c585d09b7
Parents: a1c8bfc
Author: benwa <bt...@linagora.com>
Authored: Thu May 31 17:30:43 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Wed Jun 6 09:00:10 2018 +0200
----------------------------------------------------------------------
.../james/mpt/ant/MailProtocolTestTask.java | 26 +++++++++++---------
.../org/apache/james/mpt/ant/TestAddUser.java | 4 +--
.../apache/james/mpt/ant/TestRunScripts.java | 2 +-
.../java/org/apache/james/mpt/app/Main.java | 3 ++-
.../org/apache/james/mpt/app/RunScript.java | 7 +++---
.../james/mpt/host/ExternalHostSystem.java | 3 ++-
.../mpt/session/ExternalSessionFactory.java | 5 ++--
.../james/mpt/user/ScriptedUserAdder.java | 11 +++++----
.../org/apache/james/mpt/DiscardProtocol.java | 7 +++---
.../apache/james/mpt/TestDiscardProtocol.java | 2 +-
.../mpt/smtp/CassandraForwardSmtpTest.java | 2 +-
.../smtp/CassandraSmtpStarttlsCommandTest.java | 2 +-
.../apache/james/mpt/smtp/SmtpTestModule.java | 15 +++--------
.../smtp/host/CassandraJamesSmtpHostSystem.java | 3 ++-
.../org/apache/james/mpt/maven/AddUser.java | 11 ++++++---
.../james/mpt/maven/MailProtocolTest.java | 7 +++---
16 files changed, 59 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java
----------------------------------------------------------------------
diff --git a/mpt/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java b/mpt/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java
index 04acf3c..6d3a08b 100644
--- a/mpt/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java
+++ b/mpt/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java
@@ -28,6 +28,7 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.Optional;
import org.apache.james.mpt.Runner;
import org.apache.james.mpt.api.ImapFeatures;
@@ -36,6 +37,7 @@ import org.apache.james.mpt.api.Monitor;
import org.apache.james.mpt.host.ExternalHostSystem;
import org.apache.james.mpt.protocol.ProtocolSessionBuilder;
import org.apache.james.mpt.user.ScriptedUserAdder;
+import org.apache.james.util.Port;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -55,7 +57,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
private boolean quiet = false;
private File script;
private Union scripts;
- private int port = 0;
+ private Optional<Port> port = Optional.empty();
private String host = "127.0.0.1";
private boolean skip = false;
private String shabang = null;
@@ -139,7 +141,9 @@ public class MailProtocolTestTask extends Task implements Monitor {
* @return port number
*/
public int getPort() {
- return port;
+ return port
+ .map(Port::getValue)
+ .orElseThrow(() -> new RuntimeException("Port must be set"));
}
/**
@@ -147,7 +151,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
* @param port port number
*/
public void setPort(int port) {
- this.port = port;
+ this.port = Optional.of(new Port(port));
}
/**
@@ -189,8 +193,8 @@ public class MailProtocolTestTask extends Task implements Monitor {
@Override
public void execute() throws BuildException {
- if (port <= 0) {
- throw new BuildException("Port must be set to a positive integer");
+ if (! port.isPresent()) {
+ throw new BuildException("Port must be set");
}
if (scripts == null && script == null) {
@@ -232,7 +236,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
userAdder.execute();
}
- final ExternalHostSystem host = new ExternalHostSystem(SUPPORTED_FEATURES, getHost(), getPort(), this, getShabang(), null);
+ final ExternalHostSystem host = new ExternalHostSystem(SUPPORTED_FEATURES, getHost(), port.get(), this, getShabang(), null);
final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
if (scripts == null) {
@@ -277,7 +281,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
*/
public class AddUser {
- private int port;
+ private Port port;
private String user;
private String passwd;
private File script;
@@ -289,7 +293,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
* @return port number
*/
public int getPort() {
- return port;
+ return port.getValue();
}
/**
@@ -298,7 +302,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
* @param port port number
*/
public void setPort(int port) {
- this.port = port;
+ this.port = new Port(port);
}
/**
@@ -370,7 +374,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
throw new BuildException("Choose either script text or script attribute but not both.");
}
- if (port <= 0) {
+ if (port == null) {
throw new BuildException("'port' attribute must be set on AddUser to the port against which the script should run.");
}
}
@@ -389,7 +393,7 @@ public class MailProtocolTestTask extends Task implements Monitor {
} else {
reader = new FileReader(scriptFile);
}
- final ScriptedUserAdder adder = new ScriptedUserAdder(getHost(), getPort(), MailProtocolTestTask.this);
+ final ScriptedUserAdder adder = new ScriptedUserAdder(getHost(), port, MailProtocolTestTask.this);
adder.addUser(getUser(), getPasswd(), reader);
} catch (Exception e) {
log(e.getMessage(), Project.MSG_ERR);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestAddUser.java
----------------------------------------------------------------------
diff --git a/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestAddUser.java b/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestAddUser.java
index 7eba9e99..aabc2e1 100644
--- a/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestAddUser.java
+++ b/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestAddUser.java
@@ -42,7 +42,7 @@ public class TestAddUser extends TestCase {
subject = new MailProtocolTestTask();
subject.setHost("127.0.0.1");
- subject.setPort(fakeServer.getPort());
+ subject.setPort(fakeServer.getPort().getValue());
subject.add(new Union());
subject.setProject(new Project());
}
@@ -55,7 +55,7 @@ public class TestAddUser extends TestCase {
public void testShouldExecuteScriptAgainstPort() throws Exception {
MailProtocolTestTask.AddUser user = subject.createAddUser();
- user.setPort(fakeServer.getPort());
+ user.setPort(fakeServer.getPort().getValue());
user.setPasswd("PASSWORD");
user.setUser("USER");
final String script = "This script adds a user";
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestRunScripts.java
----------------------------------------------------------------------
diff --git a/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestRunScripts.java b/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestRunScripts.java
index 5c5e92d..9472f1d 100644
--- a/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestRunScripts.java
+++ b/mpt/antlib/src/test/java/org/apache/james/mpt/ant/TestRunScripts.java
@@ -56,7 +56,7 @@ public class TestRunScripts extends TestCase {
subject = new MailProtocolTestTask();
subject.setHost("127.0.0.1");
- subject.setPort(fakeServer.getPort());
+ subject.setPort(fakeServer.getPort().getValue());
subject.setProject(new Project());
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/app/src/main/java/org/apache/james/mpt/app/Main.java
----------------------------------------------------------------------
diff --git a/mpt/app/src/main/java/org/apache/james/mpt/app/Main.java b/mpt/app/src/main/java/org/apache/james/mpt/app/Main.java
index 63d243c..4e3f3ea 100644
--- a/mpt/app/src/main/java/org/apache/james/mpt/app/Main.java
+++ b/mpt/app/src/main/java/org/apache/james/mpt/app/Main.java
@@ -28,6 +28,7 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
+import org.apache.james.util.Port;
/**
* <p>Runs MPT application.</p>
@@ -73,7 +74,7 @@ public class Main {
File file = new File(cmd.getOptionValue(FILE_OPTION));
if (file.exists()) {
try {
- int port = Integer.parseInt(cmd.getOptionValue(PORT_OPTION));
+ Port port = new Port(Integer.parseInt(cmd.getOptionValue(PORT_OPTION)));
String host = cmd.getOptionValue(HOST_OPTION, "localhost");
String shabang = cmd.getOptionValue(SHABANG_OPTION, null);
RunScript runner = new RunScript(file, port, host, shabang, verbose);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/app/src/main/java/org/apache/james/mpt/app/RunScript.java
----------------------------------------------------------------------
diff --git a/mpt/app/src/main/java/org/apache/james/mpt/app/RunScript.java b/mpt/app/src/main/java/org/apache/james/mpt/app/RunScript.java
index 707718c..9621ccb 100644
--- a/mpt/app/src/main/java/org/apache/james/mpt/app/RunScript.java
+++ b/mpt/app/src/main/java/org/apache/james/mpt/app/RunScript.java
@@ -28,6 +28,7 @@ import org.apache.james.mpt.api.ImapFeatures.Feature;
import org.apache.james.mpt.host.ExternalHostSystem;
import org.apache.james.mpt.monitor.SystemLoggingMonitor;
import org.apache.james.mpt.protocol.ProtocolSessionBuilder;
+import org.apache.james.util.Port;
/**
* Runs a single script.
@@ -37,12 +38,12 @@ class RunScript {
private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT);
private final File file;
- private final int port;
+ private final Port port;
private final String host;
private final String shabang;
private final SystemLoggingMonitor monitor;
- public RunScript(File file, int port, String host, String shabang, boolean verbose) {
+ public RunScript(File file, Port port, String host, String shabang, boolean verbose) {
super();
this.file = file;
this.port = port;
@@ -55,7 +56,7 @@ class RunScript {
* Runs the script.
*/
public void run() throws Exception {
- System.out.println("Running " + file + " against " + host + ":" + port + "...");
+ System.out.println("Running " + file + " against " + host + ":" + port.getValue() + "...");
final ExternalHostSystem host = new ExternalHostSystem(SUPPORTED_FEATURES, this.host, port, monitor, shabang, null);
final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java b/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
index ffbbafe..53a1972 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
@@ -30,6 +30,7 @@ import org.apache.james.mpt.api.ImapHostSystem;
import org.apache.james.mpt.api.Monitor;
import org.apache.james.mpt.api.UserAdder;
import org.apache.james.mpt.session.ExternalSessionFactory;
+import org.apache.james.util.Port;
/**
* <p>
@@ -67,7 +68,7 @@ public class ExternalHostSystem extends ExternalSessionFactory implements ImapHo
* @param userAdder
* null when test system has appropriate users already set
*/
- public ExternalHostSystem(ImapFeatures features, String host, int port,
+ public ExternalHostSystem(ImapFeatures features, String host, Port port,
Monitor monitor, String shabang, UserAdder userAdder) {
super(host, port, monitor, shabang);
this.features = features;
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSessionFactory.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSessionFactory.java b/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSessionFactory.java
index f1fbaf0..0abcdfb 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSessionFactory.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSessionFactory.java
@@ -26,6 +26,7 @@ import org.apache.james.mpt.api.Continuation;
import org.apache.james.mpt.api.Monitor;
import org.apache.james.mpt.api.Session;
import org.apache.james.mpt.api.SessionFactory;
+import org.apache.james.util.Port;
/**
* Session factory creates session which connection to a server port.
@@ -41,8 +42,8 @@ public class ExternalSessionFactory implements SessionFactory {
this(null, monitor, shabang);
}
- public ExternalSessionFactory(String host, int port, Monitor monitor, String shabang) {
- this(new InetSocketAddress(host, port), monitor, shabang);
+ public ExternalSessionFactory(String host, Port port, Monitor monitor, String shabang) {
+ this(new InetSocketAddress(host, port.getValue()), monitor, shabang);
}
public ExternalSessionFactory(InetSocketAddress address, Monitor monitor, String shabang) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/core/src/main/java/org/apache/james/mpt/user/ScriptedUserAdder.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/user/ScriptedUserAdder.java b/mpt/core/src/main/java/org/apache/james/mpt/user/ScriptedUserAdder.java
index 5f6eeca..51c0485 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/user/ScriptedUserAdder.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/user/ScriptedUserAdder.java
@@ -28,6 +28,7 @@ import org.apache.james.mpt.api.UserAdder;
import org.apache.james.mpt.monitor.NullMonitor;
import org.apache.james.mpt.protocol.ProtocolSessionBuilder;
import org.apache.james.mpt.session.ExternalSessionFactory;
+import org.apache.james.util.Port;
/**
* Adds a user by executing a script at a port.
@@ -41,7 +42,7 @@ public class ScriptedUserAdder implements UserAdder {
private static final String USER_VARIABLE_NAME = "user";
private final String host;
- private final int port;
+ private final Port port;
private final String script;
private final Monitor monitor;
@@ -51,11 +52,11 @@ public class ScriptedUserAdder implements UserAdder {
* @param host connect to this host
* @param port connect to this port
*/
- public ScriptedUserAdder(String host, int port) {
+ public ScriptedUserAdder(String host, Port port) {
this(host, port, (String) null);
}
- public ScriptedUserAdder(String host, int port, String script) {
+ public ScriptedUserAdder(String host, Port port, String script) {
this(host, port, script, new NullMonitor());
}
@@ -65,11 +66,11 @@ public class ScriptedUserAdder implements UserAdder {
* @param port connect to this port
* @param monitor not null
*/
- public ScriptedUserAdder(String host, int port, Monitor monitor) {
+ public ScriptedUserAdder(String host, Port port, Monitor monitor) {
this(host, port, null, monitor);
}
- public ScriptedUserAdder(String host, int port, String script, Monitor monitor) {
+ public ScriptedUserAdder(String host, Port port, String script, Monitor monitor) {
this.host = host;
this.port = port;
this.script = script;
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java b/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
index 53dfd5d..d27bacc 100644
--- a/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
+++ b/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
@@ -32,6 +32,7 @@ import java.util.Queue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.james.util.Port;
/**
* Simple <a href='http://tools.ietf.org/html/rfc863'>RFC 863</a> implementation.
@@ -47,7 +48,7 @@ public class DiscardProtocol {
private static final Log LOG = LogFactory.getLog(DiscardProtocol.class);
/** Serve on this port */
- private int port;
+ private Port port;
/**
* Queues requests for recordings.
@@ -80,7 +81,7 @@ public class DiscardProtocol {
if (socket == null) {
socket = ServerSocketChannel.open();
socket.socket().bind(new InetSocketAddress(0));
- port = socket.socket().getLocalPort();
+ port = new Port(socket.socket().getLocalPort());
// only going to record a single conversation
socket.configureBlocking(false);
@@ -93,7 +94,7 @@ public class DiscardProtocol {
}
}
- public int getPort() {
+ public Port getPort() {
return port;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/core/src/test/java/org/apache/james/mpt/TestDiscardProtocol.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/test/java/org/apache/james/mpt/TestDiscardProtocol.java b/mpt/core/src/test/java/org/apache/james/mpt/TestDiscardProtocol.java
index 787a426..bc30917 100644
--- a/mpt/core/src/test/java/org/apache/james/mpt/TestDiscardProtocol.java
+++ b/mpt/core/src/test/java/org/apache/james/mpt/TestDiscardProtocol.java
@@ -63,7 +63,7 @@ public class TestDiscardProtocol extends TestCase {
super.setUp();
protocol = new DiscardProtocol();
protocol.start();
- socket = SocketFactory.getDefault().createSocket("127.0.0.1", protocol.getPort());
+ socket = SocketFactory.getDefault().createSocket("127.0.0.1", protocol.getPort().getValue());
record = protocol.recordNext();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
index 6f82b82..abc50df 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
@@ -37,7 +37,7 @@ public class CassandraForwardSmtpTest extends ForwardSmtpTest {
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(
- new SmtpTestModule(SmtpTestModule.Port.SMTP, cassandraServer.getHost()));
+ new SmtpTestModule(SmtpTestModule.SMTP_PORT, cassandraServer.getHost()));
system = injector.getInstance(SmtpHostSystem.class);
system.beforeTest();
super.setUp();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
index e76ff05..18f052c 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
@@ -37,7 +37,7 @@ public class CassandraSmtpStarttlsCommandTest extends SmtpStarttlsCommandTest {
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(
- new SmtpTestModule(SmtpTestModule.Port.SMTP_START_TTLS, cassandraServer.getHost()));
+ new SmtpTestModule(SmtpTestModule.SMTP_START_TLS_PORT, cassandraServer.getHost()));
system = injector.getInstance(SmtpHostSystem.class);
system.beforeTest();
super.setUp();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
index eea9106..fa87b4b 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
@@ -20,21 +20,14 @@ package org.apache.james.mpt.smtp;
import org.apache.james.mpt.smtp.host.CassandraJamesSmtpHostSystem;
import org.apache.james.util.Host;
+import org.apache.james.util.Port;
import com.google.inject.AbstractModule;
public class SmtpTestModule extends AbstractModule {
- enum Port {
- SMTP(1025),
- SMTP_START_TTLS(1587);
-
- private int port;
-
- Port(int port) {
- this.port = port;
- }
- }
+ public static Port SMTP_PORT = new Port(1025);
+ public static Port SMTP_START_TLS_PORT = new Port(1587);
private final Port smtpPort;
private final Host cassandraHost;
@@ -46,7 +39,7 @@ public class SmtpTestModule extends AbstractModule {
@Override
protected void configure() {
- bind(SmtpHostSystem.class).toInstance(new CassandraJamesSmtpHostSystem(smtpPort.port, cassandraHost));
+ bind(SmtpHostSystem.class).toInstance(new CassandraJamesSmtpHostSystem(smtpPort, cassandraHost));
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index 86dcd33..3d2d65b 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -37,6 +37,7 @@ import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
import org.apache.james.server.core.configuration.Configuration;
import org.apache.james.util.Host;
+import org.apache.james.util.Port;
import org.apache.james.utils.DataProbeImpl;
import org.junit.rules.TemporaryFolder;
@@ -58,7 +59,7 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
private final Host cassandraHost;
- public CassandraJamesSmtpHostSystem(int smtpPort, Host cassandraHost) {
+ public CassandraJamesSmtpHostSystem(Port smtpPort, Host cassandraHost) {
super("localhost", smtpPort, new SystemLoggingMonitor(), "220 mydomain.tld smtp");
this.cassandraHost = cassandraHost;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java
----------------------------------------------------------------------
diff --git a/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java b/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java
index 1bfa1de..e8c2e2c 100644
--- a/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java
+++ b/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java
@@ -20,6 +20,9 @@
package org.apache.james.mpt.maven;
import java.io.File;
+import java.util.Optional;
+
+import org.apache.james.util.Port;
/**
@@ -27,7 +30,7 @@ import java.io.File;
*/
public class AddUser {
- private int port;
+ private Optional<Port> port = Optional.empty();
private String user;
private String passwd;
private String scriptText;
@@ -52,7 +55,7 @@ public class AddUser {
* script should be executed.
* @return port number
*/
- public int getPort() {
+ public Optional<Port> getPort() {
return port;
}
@@ -61,8 +64,8 @@ public class AddUser {
* script should be executed.
* @param port port number
*/
- public void setPort(int port) {
- this.port = port;
+ public void setPort(Port port) {
+ this.port = Optional.of(port);
}
/**
http://git-wip-us.apache.org/repos/asf/james-project/blob/f9bcbf90/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
----------------------------------------------------------------------
diff --git a/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java b/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
index a9a6eb5..1b575f9 100644
--- a/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
+++ b/mpt/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
@@ -34,6 +34,7 @@ import org.apache.james.mpt.api.Monitor;
import org.apache.james.mpt.host.ExternalHostSystem;
import org.apache.james.mpt.protocol.ProtocolSessionBuilder;
import org.apache.james.mpt.user.ScriptedUserAdder;
+import org.apache.james.util.Port;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -104,7 +105,7 @@ public class MailProtocolTest implements Monitor {
} else {
reader = new FileReader(addUser.getScriptFile());
}
- final ScriptedUserAdder adder = new ScriptedUserAdder(addUser.getHost(), addUser.getPort(), this);
+ final ScriptedUserAdder adder = new ScriptedUserAdder(addUser.getHost(), addUser.getPort().orElseThrow(() -> new RuntimeException("Port should be set")), this);
adder.addUser(addUser.getUser(), addUser.getPasswd(), reader);
} catch (Exception e) {
//getLog().error("Unable to add user", e);
@@ -116,7 +117,7 @@ public class MailProtocolTest implements Monitor {
try {
inputStream = new FileInputStream(scriptFile);
- final ExternalHostSystem hostSystem = new ExternalHostSystem(SUPPORTED_FEATURES, host, port, this, shabang, null);
+ final ExternalHostSystem hostSystem = new ExternalHostSystem(SUPPORTED_FEATURES, host, new Port(port), this, shabang, null);
final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
builder.addProtocolLines(scriptFile.getName(), inputStream, runner.getTestElements());
@@ -150,7 +151,7 @@ public class MailProtocolTest implements Monitor {
throw new MojoFailureException("AddUser must contain the text of the script or a scriptFile");
}
- if (addUser.getPort() <= 0) {
+ if (! addUser.getPort().isPresent()) {
throw new MojoFailureException("'port' attribute must be set on AddUser to the port against which the script should run.");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org