[jira] [Commented] (JAMES-2865) Implementing a MockSmtpServer

2019-09-02 Thread Tellier Benoit (Jira)


[ 
https://issues.apache.org/jira/browse/JAMES-2865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16921109#comment-16921109
 ] 

Tellier Benoit commented on JAMES-2865:
---

https://github.com/linagora/james-project/pull/2647 added condition filtering

> Implementing a MockSmtpServer
> -
>
> Key: JAMES-2865
> URL: https://issues.apache.org/jira/browse/JAMES-2865
> Project: James Server
>  Issue Type: Sub-task
>  Components: Remote Delivery, tests
>Reporter: Tellier Benoit
>Assignee: Tellier Benoit
>Priority: Major
>
> Draft version [here](https://github.com/linagora/james-project/pull/2545)
> The MockSmtpServer should match these criteria:
>  - can return error responses
>  - can return error responses but actually still success to deliver the mails 
> (450 - server retry and will be success)
>  - act like a simple smtp server if no mock setup, when mails come, save them 
> in to the memory
> Regarding the behaviour:
>  - a behaviour can be applied to all given commands or a subset of them 
> (condition)
>  - A number of answer can be specified, after X answers the behaviour will no 
> longer be applied.
> You need to rely on the following POJOs : see JAMES-2853



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

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



[james-project] 01/03: JAMES-2865 Behavior conditions filtering

2019-09-02 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

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

commit 61c13426a96388fb1d4cd82e4289ffb48b5900e3
Author: Tran Tien Duc 
AuthorDate: Thu Aug 29 10:18:57 2019 +0700

JAMES-2865 Behavior conditions filtering
---
 .../james/mock/smtp/server/MockMessageHandler.java |  14 +-
 .../james/mock/smtp/server/MockSMTPServerTest.java | 188 +
 2 files changed, 196 insertions(+), 6 deletions(-)

diff --git 
a/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/MockMessageHandler.java
 
b/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/MockMessageHandler.java
index bef805f..70b01ee 100644
--- 
a/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/MockMessageHandler.java
+++ 
b/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/MockMessageHandler.java
@@ -98,7 +98,7 @@ public class MockMessageHandler implements MessageHandler {
 
 @Override
 public void from(String from) throws RejectException {
-Optional> fromBehavior = 
firstMatchedBehavior(SMTPCommand.MAIL_FROM);
+Optional> fromBehavior = 
firstMatchedBehavior(SMTPCommand.MAIL_FROM, from);
 
 fromBehavior
 .orElseGet(() -> envelopeBuilder::from)
@@ -107,7 +107,7 @@ public class MockMessageHandler implements MessageHandler {
 
 @Override
 public void recipient(String recipient) throws RejectException {
-Optional> recipientBehavior = 
firstMatchedBehavior(SMTPCommand.RCPT_TO);
+Optional> recipientBehavior = 
firstMatchedBehavior(SMTPCommand.RCPT_TO, recipient);
 
 recipientBehavior
 .orElseGet(() -> envelopeBuilder::addRecipient)
@@ -116,17 +116,19 @@ public class MockMessageHandler implements MessageHandler 
{
 
 @Override
 public void data(InputStream data) throws RejectException, 
TooMuchDataException, IOException {
-Optional> dataBehavior = 
firstMatchedBehavior(SMTPCommand.DATA);
+String dataString = readData(data);
+Optional> dataBehavior = 
firstMatchedBehavior(SMTPCommand.DATA, dataString);
 
 dataBehavior
-.orElseGet(() -> content -> mailBuilder.message(readData(content)))
-.behave(data);
+.orElseGet(() -> mailBuilder::message)
+.behave(dataString);
 }
 
-private  Optional> firstMatchedBehavior(SMTPCommand data) {
+private  Optional> firstMatchedBehavior(SMTPCommand data, 
String dataLine) {
 return behaviorRepository.remainingBehaviors()
 .map(MockSMTPBehaviorInformation::getBehavior)
 .filter(behavior -> behavior.getCommand().equals(data))
+.filter(behavior -> behavior.getCondition().matches(dataLine))
 .findFirst()
 .map(mockBehavior -> new 
SMTPBehaviorRepositoryUpdater<>(behaviorRepository, mockBehavior));
 }
diff --git 
a/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
 
b/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
index bf6fe4b..5e9c873 100644
--- 
a/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
+++ 
b/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
@@ -23,6 +23,7 @@ import static org.apache.james.mock.smtp.server.Fixture.ALICE;
 import static org.apache.james.mock.smtp.server.Fixture.BOB;
 import static org.apache.james.mock.smtp.server.Fixture.DOMAIN;
 import static org.apache.james.mock.smtp.server.Fixture.JACK;
+import static 
org.apache.james.mock.smtp.server.model.Response.SMTPStatusCode.REQUESTED_MAIL_ACTION_NOT_TAKEN_450;
 import static 
org.apache.james.mock.smtp.server.model.Response.SMTPStatusCode.SERVICE_NOT_AVAILABLE_421;
 import static org.apache.james.mock.smtp.server.model.SMTPCommand.DATA;
 import static org.apache.james.mock.smtp.server.model.SMTPCommand.MAIL_FROM;
@@ -49,6 +50,7 @@ import org.apache.james.mock.smtp.server.model.Response;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.james.util.Port;
 import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPSendingException;
 import org.apache.mailet.base.test.FakeMail;
 import org.awaitility.Awaitility;
 import org.awaitility.Duration;
@@ -338,6 +340,192 @@ class MockSMTPServerTest {
 }
 }
 
+@Nested
+class ConditionFilteringTest {
+private MockSMTPServer mockServer;
+private FakeMail mail1;
+private MimeMessage mimeMessage1;
+private SMTPMessageSender smtpClient;
+private SMTPBehaviorRepository behaviorRepository;
+
+@BeforeEach
+void setUp() throws Exception {
+behaviorRepository = new SMTPBehaviorRepository();
+ 

[james-project] 02/03: JAMES-2865 Refactor MockSMTPServerTest

2019-09-02 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

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

commit 18f37b39870efb8f8b40aae50e3ac456fdc1824e
Author: Tran Tien Duc 
AuthorDate: Thu Aug 29 10:21:27 2019 +0700

JAMES-2865 Refactor MockSMTPServerTest

Optimized setups
---
 .../james/mock/smtp/server/MockSMTPServerTest.java | 187 ++---
 1 file changed, 48 insertions(+), 139 deletions(-)

diff --git 
a/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
 
b/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
index 5e9c873..47a7c04 100644
--- 
a/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
+++ 
b/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/MockSMTPServerTest.java
@@ -58,26 +58,46 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
-import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
 
 import com.github.fge.lambdas.Throwing;
+import com.google.common.collect.ImmutableList;
 
 class MockSMTPServerTest {
 
-@Nested
-class NormalBehaviorTests {
-private MockSMTPServer mockServer;
+private MockSMTPServer mockServer;
+private FakeMail mail1;
+private MimeMessage mimeMessage1;
+private SMTPMessageSender smtpClient;
+private SMTPBehaviorRepository behaviorRepository;
+
+@BeforeEach
+void setUp() throws Exception {
+behaviorRepository = new SMTPBehaviorRepository();
+mockServer = new MockSMTPServer(behaviorRepository);
+
+mimeMessage1 = MimeMessageBuilder.mimeMessageBuilder()
+.setSubject("test")
+.setText("any text")
+.build();
+mail1 = FakeMail.builder()
+.name("name")
+.sender(BOB)
+.recipients(ALICE, JACK)
+.mimeMessage(mimeMessage1)
+.build();
 
-@BeforeEach
-void setUp() {
-mockServer = new MockSMTPServer();
-mockServer.start();
-}
+mockServer.start();
+smtpClient = new SMTPMessageSender(DOMAIN)
+.connect("localhost", mockServer.getPort());
+}
 
-@AfterEach
-void tearDown() {
-mockServer.stop();
-}
+@AfterEach
+void tearDown() {
+mockServer.stop();
+}
+
+@Nested
+class NormalBehaviorTests {
 
 @Test
 void serverShouldReceiveMessageFromClient() throws Exception {
@@ -116,39 +136,6 @@ class MockSMTPServerTest {
 
 @Nested
 class MailMockBehaviorTest {
-private MockSMTPServer mockServer;
-private FakeMail mail1;
-private MimeMessage mimeMessage1;
-private SMTPMessageSender smtpClient;
-private SMTPBehaviorRepository behaviorRepository;
-
-@BeforeEach
-void setUp() throws Exception {
-behaviorRepository = new SMTPBehaviorRepository();
-mockServer = new MockSMTPServer(behaviorRepository);
-
-mimeMessage1 = MimeMessageBuilder.mimeMessageBuilder()
-.setSubject("test")
-.setText("any text")
-.build();
-mail1 = FakeMail.builder()
-.name("name")
-.sender(BOB)
-.recipients(ALICE, JACK)
-.mimeMessage(mimeMessage1)
-.build();
-
-mockServer.start();
-smtpClient = new SMTPMessageSender(DOMAIN)
-.connect("localhost", mockServer.getPort());
-}
-
-@AfterEach
-void tearDown() {
-behaviorRepository.clearBehaviors();
-mockServer.stop();
-}
-
 @Test
 void serverShouldReceiveMessageFromClient() throws Exception {
 behaviorRepository.setBehaviors(new MockSMTPBehavior(
@@ -191,38 +178,6 @@ class MockSMTPServerTest {
 
 @Nested
 class NumberOfAnswersTest {
-private MockSMTPServer mockServer;
-private FakeMail mail1;
-private MimeMessage mimeMessage1;
-private SMTPMessageSender smtpClient;
-private SMTPBehaviorRepository behaviorRepository;
-
-@BeforeEach
-void setUp() throws Exception {
-behaviorRepository = new SMTPBehaviorRepository();
-mockServer = new MockSMTPServer(behaviorRepository);
-
-mimeMessage1 = MimeMessageBuilder.mimeMessageBuilder()
-.setSubject("test")
-.setText("any text")
-.build();
-mail1 = FakeMail.builder()
-.name("name")
-.sender(BOB)
-.recipients(ALICE, JACK)
-.mimeMessage(mimeMessage1

[james-project] branch master updated (3d8d5e1 -> c7125d4)

2019-09-02 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.


from 3d8d5e1  JAMES-2873 Inject Hostname in DistributedTaskManager
 new 61c1342  JAMES-2865 Behavior conditions filtering
 new 18f37b3  JAMES-2865 Refactor MockSMTPServerTest
 new c7125d4  MAILBOX-359 Remove no longer used classes

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../modules/CassandraRegistrationModule.java   |  44 
 .../table/CassandraMailboxPathRegisterTable.java   |  36 ---
 .../james/mock/smtp/server/MockMessageHandler.java |  14 +-
 .../james/mock/smtp/server/MockSMTPServerTest.java | 275 ++---
 4 files changed, 194 insertions(+), 175 deletions(-)
 delete mode 100644 
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraRegistrationModule.java
 delete mode 100644 
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/table/CassandraMailboxPathRegisterTable.java


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



[james-project] 03/03: MAILBOX-359 Remove no longer used classes

2019-09-02 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

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

commit c7125d401e518944c8bec2fa3aca18cbfc954449
Author: Benoit Tellier 
AuthorDate: Sat Aug 31 23:46:56 2019 +0700

MAILBOX-359 Remove no longer used classes
---
 .../modules/CassandraRegistrationModule.java   | 44 --
 .../table/CassandraMailboxPathRegisterTable.java   | 36 --
 2 files changed, 80 deletions(-)

diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraRegistrationModule.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraRegistrationModule.java
deleted file mode 100644
index 8384890..000
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraRegistrationModule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information*
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the*
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *  *
- *   http://www.apache.org/licenses/LICENSE-2.0 *
- *  *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
- * KIND, either express or implied.  See the License for the*
- * specific language governing permissions and limitations  *
- * under the License.   *
- /
-
-package org.apache.james.mailbox.cassandra.modules;
-
-import static com.datastax.driver.core.DataType.text;
-
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import 
org.apache.james.mailbox.cassandra.table.CassandraMailboxPathRegisterTable;
-
-import com.datastax.driver.core.schemabuilder.SchemaBuilder;
-
-public interface CassandraRegistrationModule {
-CassandraModule MODULE = CassandraModule.builder()
-.type(CassandraMailboxPathRegisterTable.MAILBOX_PATH)
-.statement(statement -> statement
-
.addColumn(CassandraMailboxPathRegisterTable.MailboxPath.NAMESPACE, text())
-.addColumn(CassandraMailboxPathRegisterTable.MailboxPath.NAME, 
text())
-.addColumn(CassandraMailboxPathRegisterTable.MailboxPath.USER, 
text()))
-.table(CassandraMailboxPathRegisterTable.TABLE_NAME)
-.comment("Holds node mailboxPath registration for distributed events")
-.options(options -> options
-.compactionOptions(SchemaBuilder.timeWindowCompactionStrategy()))
-.statement(statement -> statement
-
.addUDTPartitionKey(CassandraMailboxPathRegisterTable.MAILBOX_PATH, 
SchemaBuilder.frozen(CassandraMailboxPathRegisterTable.MAILBOX_PATH))
-.addClusteringColumn(CassandraMailboxPathRegisterTable.TOPIC, 
text()))
-.build();
-}
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/table/CassandraMailboxPathRegisterTable.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/table/CassandraMailboxPathRegisterTable.java
deleted file mode 100644
index 69e76eb..000
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/table/CassandraMailboxPathRegisterTable.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information*
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the*
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *  *
- *   http://www.apache.org/licenses/LICENSE-2.0 *
- *  *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
- * KIND, either express or implied.  See the License for the*
- * specific 

[jira] [Created] (JAMES-2875) Broken links in config page

2019-09-02 Thread Gualtiero Testa (Jira)
Gualtiero Testa created JAMES-2875:
--

 Summary: Broken links in config page
 Key: JAMES-2875
 URL: https://issues.apache.org/jira/browse/JAMES-2875
 Project: James Server
  Issue Type: Bug
Affects Versions: 3.3.0
Reporter: Gualtiero Testa


The following page
http://james.apache.org/server/3/config.html
has most of file links broken.


For example: "mailetcontainer.xml" links to 
https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer-template.xml
 while at that URL the file name is without "-template".



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

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



[jira] [Closed] (JAMES-2873) Distributed Task Manager should keep track of nodes emiting events

2019-09-02 Thread Matthieu Baechler (Jira)


 [ 
https://issues.apache.org/jira/browse/JAMES-2873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matthieu Baechler closed JAMES-2873.

Resolution: Fixed

merged to master

> Distributed Task Manager should keep track of nodes emiting events
> --
>
> Key: JAMES-2873
> URL: https://issues.apache.org/jira/browse/JAMES-2873
> Project: James Server
>  Issue Type: Task
>Reporter: Matthieu Baechler
>Priority: Major
>
> For Created and Started events, it makes sense to keep track of the node name 
> who emitted the event.
> We should modify the Task Manager to handle that.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

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



[james-project] 04/04: JAMES-2873 Inject Hostname in DistributedTaskManager

2019-09-02 Thread matthieu
This is an automated email from the ASF dual-hosted git repository.

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

commit 3d8d5e1a9eeb69d4f10f34145739efcf1095b8d7
Author: Gautier DI FOLCO 
AuthorDate: Mon Aug 26 12:09:26 2019 +0200

JAMES-2873 Inject Hostname in DistributedTaskManager
---
 .../apache/james/DistributedTaskManagerModule.java |  3 +-
 .../james/modules/server/HostnameModule.java   | 21 +-
 .../META-INF/org/apache/james/spring-server.xml|  5 ++-
 .../apache/james/task/eventsourcing/Events.scala   | 48 ++
 4 files changed, 38 insertions(+), 39 deletions(-)

diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/DistributedTaskManagerModule.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/DistributedTaskManagerModule.java
index 6f1a294..f5cb955 100644
--- 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/DistributedTaskManagerModule.java
+++ 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/DistributedTaskManagerModule.java
@@ -20,6 +20,7 @@
 
 package org.apache.james;
 
+import org.apache.james.modules.server.HostnameModule;
 import org.apache.james.task.MemoryWorkQueue;
 import org.apache.james.task.SerialTaskManagerWorker;
 import org.apache.james.task.TaskManager;
@@ -34,7 +35,6 @@ import com.google.inject.AbstractModule;
 import com.google.inject.Scopes;
 
 public class DistributedTaskManagerModule extends AbstractModule {
-
 public static final WorkQueueSupplier workQueueSupplier = 
eventSourcingSystem -> {
 WorkerStatusListener listener = new 
WorkerStatusListener(eventSourcingSystem);
 TaskManagerWorker worker = new SerialTaskManagerWorker(listener);
@@ -43,6 +43,7 @@ public class DistributedTaskManagerModule extends 
AbstractModule {
 
 @Override
 protected void configure() {
+install(new HostnameModule());
 bind(TaskExecutionDetailsProjection.class).in(Scopes.SINGLETON);
 bind(TaskManager.class).in(Scopes.SINGLETON);
 bind(WorkQueueSupplier.class).in(Scopes.SINGLETON);
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
index 6607a74..de590a1 100644
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
@@ -20,32 +20,13 @@
 
 package org.apache.james.modules.server;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
 import org.apache.james.task.eventsourcing.Hostname;
 
 import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
 
 public class HostnameModule extends AbstractModule {
-private static class UnconfigurableHostnameException extends 
RuntimeException {
-UnconfigurableHostnameException(String message, Exception 
originException) {
-super(message, originException);
-}
-}
-
 @Override
 protected void configure() {
-bind(Hostname.class).in(Scopes.SINGLETON);
-bind(Hostname.class).toInstance(getHostname());
-}
-
-private Hostname getHostname() {
-try {
-return new Hostname(InetAddress.getLocalHost().getHostName());
-} catch (UnknownHostException e) {
-throw new UnconfigurableHostnameException("Hostname can not be 
retrieved, unable to initialize the distributed task manager", e);
-}
+bind(Hostname.class).toInstance(Hostname.fromLocalHostname());
 }
 }
diff --git 
a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
 
b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
index 9456080..49b7a48 100644
--- 
a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
+++ 
b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
@@ -285,7 +285,10 @@
 
 
 
-
+
+
+
+
 
diff --git 
a/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala 
b/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala
index fa0607e..6d9c7ba 100644
--- 
a/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala
+++ 
b/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala
@@ -1,23 +1,25 @@
 /** **
-  * 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 copyrig

[james-project] 03/04: JAMES-2873 Add Hostname into CancelRequested event

2019-09-02 Thread matthieu
This is an automated email from the ASF dual-hosted git repository.

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

commit bc64574d21e7f703a2044744d79ce2a15ae45b0a
Author: Gautier DI FOLCO 
AuthorDate: Wed Aug 28 11:34:04 2019 +0200

JAMES-2873 Add Hostname into CancelRequested event
---
 .../CassandraTaskExecutionDetailsProjectionDAO.scala|  3 +++
 .../CassandraTaskExecutionDetailsProjectionModule.scala |  2 ++
 .../task/eventsourcing/distributed/TaskEventDTO.scala   |  7 ---
 .../distributed/TaskEventsSerializationTest.java|  4 ++--
 .../java/org/apache/james/task/MemoryTaskManager.java   |  2 +-
 .../org/apache/james/task/TaskExecutionDetails.scala| 17 +
 .../james/task/eventsourcing/CommandHandlers.scala  |  7 ---
 .../task/eventsourcing/EventSourcingTaskManager.scala   |  4 ++--
 .../org/apache/james/task/eventsourcing/Events.scala|  2 +-
 .../apache/james/task/eventsourcing/TaskAggregate.scala |  4 ++--
 .../eventsourcing/TaskExecutionDetailsProjection.scala  |  2 +-
 .../eventsourcing/EventSourcingTaskManagerTest.java | 16 
 12 files changed, 51 insertions(+), 19 deletions(-)

diff --git 
a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala
 
b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala
index e7af442..f598aa5 100644
--- 
a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala
+++ 
b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala
@@ -47,6 +47,7 @@ class CassandraTaskExecutionDetailsProjectionDAO(session: 
Session, typesProvider
 .value(RAN_NODE, bindMarker(RAN_NODE))
 .value(COMPLETED_DATE, bindMarker(COMPLETED_DATE))
 .value(CANCELED_DATE, bindMarker(CANCELED_DATE))
+.value(CANCEL_REQUESTED_NODE, bindMarker(CANCEL_REQUESTED_NODE))
 .value(FAILED_DATE, bindMarker(FAILED_DATE)))
 
   private val selectStatement = session.prepare(select().from(TABLE_NAME)
@@ -65,6 +66,7 @@ class CassandraTaskExecutionDetailsProjectionDAO(session: 
Session, typesProvider
   .setString(RAN_NODE, 
details.getRanNode.map[String](_.asString).orElse(null))
   .setUDTValue(COMPLETED_DATE, 
CassandraZonedDateTimeModule.toUDT(dateType, 
details.getCompletedDate).orElse(null))
   .setUDTValue(CANCELED_DATE, CassandraZonedDateTimeModule.toUDT(dateType, 
details.getCanceledDate).orElse(null))
+  .setString(CANCEL_REQUESTED_NODE, 
details.getCancelRequestedNode.map[String](_.asString).orElse(null))
   .setUDTValue(FAILED_DATE, CassandraZonedDateTimeModule.toUDT(dateType, 
details.getStartedDate).orElse(null)))
 
   def readDetails(taskId: TaskId): Mono[TaskExecutionDetails] = 
cassandraAsyncExecutor
@@ -85,6 +87,7 @@ class CassandraTaskExecutionDetailsProjectionDAO(session: 
Session, typesProvider
 ranNode = Optional.ofNullable(row.getString(RAN_NODE)).map(Hostname(_)),
 completedDate = 
CassandraZonedDateTimeModule.fromUDTOptional(row.getUDTValue(COMPLETED_DATE)),
 canceledDate = 
CassandraZonedDateTimeModule.fromUDTOptional(row.getUDTValue(CANCELED_DATE)),
+cancelRequestedNode = 
Optional.ofNullable(row.getString(CANCEL_REQUESTED_NODE)).map(Hostname(_)),
 failedDate = 
CassandraZonedDateTimeModule.fromUDTOptional(row.getUDTValue(FAILED_DATE)),
 additionalInformation = Optional.empty)
 }
diff --git 
a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionModule.scala
 
b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionModule.scala
index 1ee0554..4baaa0b 100644
--- 
a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionModule.scala
+++ 
b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionModule.scala
@@ -36,6 +36,7 @@ object CassandraTaskExecutionDetailsProjectionTable {
   val RAN_NODE: String = "ranNode"
   val COMPLETED_DATE: String = "completedDate"
   val CANCELED_DATE: String = "canceledDate"
+  val CANCEL_REQUESTED_NODE: String = "cancelRequestedNode"
   val FAILED_DATE: String = "failedDate"
 }
 
@@ -58,6 +59,7 @@ object CassandraTaskExecutionDetailsProjectionModule {
   .addColumn(CassandraTaskExecutionDetailsProjectionTable.RAN_NODE, text)
   
.addUDTColumn(CassandraTaskExecutionDetailsProjectionTable.COMPLETED_DATE, 
SchemaBuilder.frozen(CassandraZonedDateTimeModule.ZONED_DATE_TIME))
   
.addUDTColumn(CassandraTaskExecutionDetailsProjectionTable.CANCELED_DATE, 
SchemaBuilder.frozen(CassandraZ

[james-project] 02/04: JAMES-2873 Add Hostname into Started event

2019-09-02 Thread matthieu
This is an automated email from the ASF dual-hosted git repository.

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

commit cc8f433ad7c5c39a207b00621fada3d66998b4fd
Author: Gautier DI FOLCO 
AuthorDate: Fri Aug 23 16:21:03 2019 +0200

JAMES-2873 Add Hostname into Started event
---
 ...{TaskManagerModule.java => HostnameModule.java} | 37 --
 .../james/modules/server/TaskManagerModule.java|  1 +
 ...assandraTaskExecutionDetailsProjectionDAO.scala |  3 ++
 ...andraTaskExecutionDetailsProjectionModule.scala |  2 ++
 .../eventsourcing/distributed/TaskEventDTO.scala   |  7 ++--
 .../distributed/TaskEventsSerializationTest.java   |  4 +--
 .../org/apache/james/task/MemoryTaskManager.java   |  8 +++--
 .../apache/james/task/TaskExecutionDetails.scala   | 26 ++-
 .../james/task/eventsourcing/CommandHandlers.scala |  7 ++--
 .../eventsourcing/EventSourcingTaskManager.scala   |  4 +--
 .../apache/james/task/eventsourcing/Events.scala   |  2 +-
 .../james/task/eventsourcing/TaskAggregate.scala   |  4 +--
 .../TaskExecutionDetailsProjection.scala   |  4 +--
 .../EventSourcingTaskManagerTest.java  | 19 +++
 14 files changed, 92 insertions(+), 36 deletions(-)

diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/TaskManagerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
similarity index 52%
copy from 
server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/TaskManagerModule.java
copy to 
server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
index b3d1e4f..6607a74 100644
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/TaskManagerModule.java
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java
@@ -1,4 +1,5 @@
-/
+/**
+ * *
  * 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*
@@ -6,29 +7,45 @@
  * 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 *
- *  *
+ * *
+ * 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.server;
 
-import org.apache.james.task.MemoryTaskManager;
-import org.apache.james.task.TaskManager;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.james.task.eventsourcing.Hostname;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Scopes;
 
-public class TaskManagerModule extends AbstractModule {
+public class HostnameModule extends AbstractModule {
+private static class UnconfigurableHostnameException extends 
RuntimeException {
+UnconfigurableHostnameException(String message, Exception 
originException) {
+super(message, originException);
+}
+}
+
 @Override
 protected void configure() {
-bind(MemoryTaskManager.class).in(Scopes.SINGLETON);
-bind(TaskManager.class).to(MemoryTaskManager.class);
+bind(Hostname.class).in(Scopes.SINGLETON);
+bind(Hostname.class).toInstance(getHostname());
+}
+
+private Hostname getHostname() {
+try {
+return new Hostname(InetAddress.getLocalHost().getHostName());
+} catch (UnknownHostException e) {
+throw new UnconfigurableHostnameException("Hostname can not be 
retrieved, unable to initialize the distributed task manager", e);
+}
 }
 }
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/TaskManagerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/TaskManagerModule.java
index b3d1e4f..484ad4c 100644
--- 
a/ser

[james-project] branch master updated (3b1f73c -> 3d8d5e1)

2019-09-02 Thread matthieu
This is an automated email from the ASF dual-hosted git repository.

matthieu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.


from 3b1f73c  JAMES-2865 Allowing to setting repetition to mock smtp 
behaviors
 new dc4a523  JAMES-2873 Add Hostname into Created event
 new cc8f433  JAMES-2873 Add Hostname into Started event
 new bc64574  JAMES-2873 Add Hostname into CancelRequested event
 new 3d8d5e1  JAMES-2873 Inject Hostname in DistributedTaskManager

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../init/CassandraZonedDateTimeModule.java | 26 +++---
 .../apache/james/DistributedTaskManagerModule.java |  3 +-
 .../james/modules/server/HostnameModule.java}  | 17 ++--
 .../james/modules/server/TaskManagerModule.java|  1 +
 .../adapter/mailbox/ReIndexerManagementTest.java   |  4 +-
 .../META-INF/org/apache/james/spring-server.xml|  5 +-
 .../cassandra/vacation/CassandraVacationDAO.java   |  2 +-
 .../routes/CassandraMappingsRoutesTest.java|  3 +-
 .../routes/CassandraMigrationRoutesTest.java   |  3 +-
 .../james/webadmin/dto/ExecutionDetailsDto.java|  2 +-
 .../james/webadmin/routes/TasksRoutesTest.java |  3 +-
 .../routes/DeletedMessagesVaultRoutesTest.java |  3 +-
 .../routes/EventDeadLettersRoutesTest.java |  3 +-
 .../webadmin/routes/ReindexingRoutesTest.java  |  3 +-
 .../james/webadmin/routes/MailQueueRoutesTest.java |  3 +-
 .../webadmin/routes/MailQueueRoutesUnitTest.java   |  3 +-
 .../routes/MailRepositoriesRoutesTest.java |  3 +-
 ...assandraTaskExecutionDetailsProjectionDAO.scala | 22 +++--
 ...andraTaskExecutionDetailsProjectionModule.scala |  6 ++
 .../eventsourcing/distributed/TaskEventDTO.scala   | 21 ++---
 .../distributed/DistributedTaskManagerTest.java|  5 +-
 .../distributed/TaskEventsSerializationTest.java   |  8 +-
 .../org/apache/james/task/MemoryTaskManager.java   | 28 ---
 .../apache/james/task/TaskExecutionDetails.scala   | 93 +++---
 .../james/task/eventsourcing/CommandHandlers.scala | 14 ++--
 .../eventsourcing/EventSourcingTaskManager.scala   | 17 ++--
 .../apache/james/task/eventsourcing/Events.scala   | 58 +-
 .../james/task/eventsourcing/TaskAggregate.scala   | 12 +--
 .../TaskExecutionDetailsProjection.scala   |  8 +-
 .../apache/james/task/MemoryTaskManagerTest.java   |  4 +-
 .../EventSourcingTaskManagerTest.java  | 60 +-
 .../james/task/TaskExecutionDetailsFixture.scala   | 15 +++-
 32 files changed, 316 insertions(+), 142 deletions(-)
 copy 
server/{task/src/test/java/org/apache/james/task/eventsourcing/MemoryTaskExecutionDetailsProjectionTest.java
 => 
container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java}
 (73%)


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



[james-project] 01/04: JAMES-2873 Add Hostname into Created event

2019-09-02 Thread matthieu
This is an automated email from the ASF dual-hosted git repository.

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

commit dc4a5231ad2d7584b6d84f11ed66fc53892a9c66
Author: Matthieu Baechler 
AuthorDate: Wed Aug 21 17:04:20 2019 +0200

JAMES-2873 Add Hostname into Created event
---
 .../init/CassandraZonedDateTimeModule.java | 26 +
 .../adapter/mailbox/ReIndexerManagementTest.java   |  4 +-
 .../cassandra/vacation/CassandraVacationDAO.java   |  2 +-
 .../routes/CassandraMappingsRoutesTest.java|  3 +-
 .../routes/CassandraMigrationRoutesTest.java   |  3 +-
 .../james/webadmin/dto/ExecutionDetailsDto.java|  2 +-
 .../james/webadmin/routes/TasksRoutesTest.java |  3 +-
 .../routes/DeletedMessagesVaultRoutesTest.java |  3 +-
 .../routes/EventDeadLettersRoutesTest.java |  3 +-
 .../webadmin/routes/ReindexingRoutesTest.java  |  3 +-
 .../james/webadmin/routes/MailQueueRoutesTest.java |  3 +-
 .../webadmin/routes/MailQueueRoutesUnitTest.java   |  3 +-
 .../routes/MailRepositoriesRoutesTest.java |  3 +-
 ...assandraTaskExecutionDetailsProjectionDAO.scala | 16 +++---
 ...andraTaskExecutionDetailsProjectionModule.scala |  2 +
 .../eventsourcing/distributed/TaskEventDTO.scala   |  7 +--
 .../distributed/DistributedTaskManagerTest.java|  5 +-
 .../distributed/TaskEventsSerializationTest.java   |  4 +-
 .../org/apache/james/task/MemoryTaskManager.java   | 18 ---
 .../apache/james/task/TaskExecutionDetails.scala   | 62 ++
 .../james/task/eventsourcing/CommandHandlers.scala |  4 +-
 .../eventsourcing/EventSourcingTaskManager.scala   |  9 ++--
 .../apache/james/task/eventsourcing/Events.scala   |  6 ++-
 .../james/task/eventsourcing/TaskAggregate.scala   |  4 +-
 .../TaskExecutionDetailsProjection.scala   |  2 +-
 .../apache/james/task/MemoryTaskManagerTest.java   |  4 +-
 .../EventSourcingTaskManagerTest.java  | 25 +++--
 .../james/task/TaskExecutionDetailsFixture.scala   | 15 --
 28 files changed, 163 insertions(+), 81 deletions(-)

diff --git 
a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraZonedDateTimeModule.java
 
b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraZonedDateTimeModule.java
index dfc0654..7c0a2da 100644
--- 
a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraZonedDateTimeModule.java
+++ 
b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraZonedDateTimeModule.java
@@ -42,19 +42,25 @@ public interface CassandraZonedDateTimeModule {
 .addColumn(TIME_ZONE, text()))
 .build();
 
+static UDTValue toUDT(UserType zonedDateTimeUserType, ZonedDateTime 
zonedDateTime) {
+ZonedDateTimeRepresentation representation = 
ZonedDateTimeRepresentation.fromZonedDateTime(zonedDateTime);
+return zonedDateTimeUserType.newValue()
+.setTimestamp(CassandraZonedDateTimeModule.DATE, 
representation.getDate())
+.setString(CassandraZonedDateTimeModule.TIME_ZONE, 
representation.getSerializedZoneId());
+}
+
 static Optional toUDT(UserType zonedDateTimeUserType, 
Optional zonedDateTimeOptional) {
-return 
zonedDateTimeOptional.map(ZonedDateTimeRepresentation::fromZonedDateTime)
-.map(representation -> zonedDateTimeUserType.newValue()
-.setTimestamp(CassandraZonedDateTimeModule.DATE, 
representation.getDate())
-.setString(CassandraZonedDateTimeModule.TIME_ZONE, 
representation.getSerializedZoneId()));
+return zonedDateTimeOptional.map(zonedDateTime -> 
toUDT(zonedDateTimeUserType, zonedDateTime));
 }
 
-static Optional fromUDT(UDTValue value) {
-return Optional.ofNullable(value)
-.map(udtValue -> ZonedDateTimeRepresentation.fromDate(
-udtValue.getTimestamp(CassandraZonedDateTimeModule.DATE),
-udtValue.getString(CassandraZonedDateTimeModule.TIME_ZONE))
-.getZonedDateTime());
+static Optional fromUDTOptional(UDTValue value) {
+return 
Optional.ofNullable(value).map(CassandraZonedDateTimeModule::fromUDT);
 }
 
+static ZonedDateTime fromUDT(UDTValue udtValue) {
+return ZonedDateTimeRepresentation.fromDate(
+udtValue.getTimestamp(CassandraZonedDateTimeModule.DATE),
+udtValue.getString(CassandraZonedDateTimeModule.TIME_ZONE))
+.getZonedDateTime();
+}
 }
diff --git 
a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.java
 
b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.java
index 276b613..db04843 100644
--- 
a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.