You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/02/09 04:29:28 UTC

[james-project] branch master updated (75ee684 -> b8e6943)

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 75ee684  [REFACTORING] Remove JUNIT 4 usages in protocols-imap
     new 16a26ea  [REFACTORING] Get rid of JUNIT 4 usages in CLI integration tests
     new 3700c24  [REFACTORING] Get rid of JUNIT 4 usages in CLI tests
     new 4377ebe  [REFACTORING] Get rid of JUNIT 4 usages in cassandra-guice tests
     new f337054  [REFACTORING] Get rid of some JUNIT 4 usages in cassandra-common tests
     new 4926411  [REFACTORING] Get rid of some JUNIT 4 usages in onami tests
     new 9df470a  [REFACTORING] Get rid of some JUNIT 4 usages in mailbox-adapter tests
     new 8e6e7d3  [REFACTORING] Get rid of some JUNIT 4 usages in mailbox-plugin-spamassassin tests
     new 4651973  [REFACTORING] Get rid of some JUNIT 4 usages in guice-mailet tests
     new cbe33c2  [REFACTORING] Get rid of some JUNIT 4 usages in server-mailets tests
     new ecee174  [REFACTORING] Get rid of some JUNIT 4 usages in mailetcontainer-camel tests
     new 66e5c3e  [REFACTORING] Get rid of some JUNIT 4 usages in spamassassin tests
     new 2520ab6  [REFACTORING] Get rid of some JUNIT 4 usages in mailrepository-memory tests
     new 1947f84  JAMES-3491 StateChangeEvent Serialization
     new db48545  JAMES-3491 Provide a basic StateChangeListener
     new f5954db  JAMES-3491 StateChangeListener should filter out unwanted events
     new 4def5f5  JAMES-3491 AccountId RegistrationKey
     new b349944  JAMES-3491 Have an EventBus for JMAP
     new 737e2c0  JAMES-3491 Register state changes upon WebSocketPushEnable reception
     new f0d38ee  JAMES-3491 WebSocketPushEnable integration test
     new a661388  JAMES-3491 Transport independant StateChangeListener
     new b6c02de  JAMES-3491 Rework WebSocketRoutes
     new 1b59476  JAMES-3491 StateChangeEvent Serialization
     new ec9f8d4  JAMES-3491 Advertise webSocket push in session capabilities
     new fe9e7ce  JAMES-3491 WebSocketPushEnable defaults to `all`
     new 9691e2e  JAMES-3491 WebSocket PUSH should support delegation
     new ebc6e0e  JAMES-3491 Enabling push should not reject unhandled data types
     new 6b3189a  JAMES-3491 Add timeouts in WebSocketContract
     new 4c1ac1b  JAMES-3491 Add EmailDelivery push notification support
     new 438191a  JAMES-3491 Add VacationResponse push notification support
     new 8fbd9fd  JAMES-3491 Document that we implement WebSocket transport for JMAP (RFC-8887)
     new 6ab9d71  [REFACTORING] Convert server/dns tests to JUNIT 5
     new 4871ffb  [REFACTORING] Convert AbstractMailQueueFactoryTest tests to JUNIT 5
     new b8e6943  [REFACTORING] Convert server/app tests to JUNIT 5

The 33 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:
 .../servers/pages/distributed/configure/jmap.adoc  |   3 +-
 .../james/app/spring/JamesAppSpringMainTest.java   |   8 +-
 .../james/app/spring/JamesSpringContextTest.java   |  18 +-
 .../james/cli/DataCommandsIntegrationTest.java     |  65 +--
 .../james/cli/MailboxCommandsIntegrationTest.java  |  42 +-
 .../james/cli/QuotaCommandsIntegrationTest.java    |  54 +-
 .../james/cli/ReindexCommandIntegrationTest.java   |  45 +-
 .../cli/SieveQuotaCommandsIntegrationTest.java     |  64 +--
 .../apache/james/cli/util/OutputCaptureTest.java   |  11 +-
 .../src/test/resources/jmap.properties             |  11 -
 .../java/org/apache/james/cli/ServerCmdTest.java   | 228 ++++----
 .../org/apache/james/cli/type/CmdTypeTest.java     |  94 ++--
 .../org/apache/james/CassandraJamesServerMain.java |   2 +
 .../mailbox/TikaConfigurationReaderTest.java       |  31 +-
 .../james/CassandraRabbitMQJamesServerMain.java    |   2 +
 .../james/modules/event/JMAPEventBusModule.java    |  92 ++++
 .../modules/InitializationOperationsTest.java      |   7 +-
 .../org/apache/james/utils/ConfigurablesTest.java  |  12 +-
 .../apache/james/utils/GuiceProbeProviderTest.java |  37 +-
 .../SpamAssassinConfigurationLoaderTest.java       |  11 +-
 .../apache/james/utils/GuiceMailetLoaderTest.java  |  56 +-
 .../apache/james/utils/GuiceMatcherLoaderTest.java |  49 +-
 .../org/apache/james/MemoryJamesServerMain.java    |   2 +
 .../onami/lifecycle/DefaultStagerTestCase.java     |   9 +-
 .../onami/lifecycle/MultiLifeCycleTestCase.java    |  10 +-
 .../onami/lifecycle/StagingOrderTestCase.java      |   8 +-
 .../modules/protocols/JmapEventBusModule.java}     |  13 +-
 .../mailbox/UserRepositoryAuthenticatorTest.java   |  27 +-
 .../mailbox/UserRepositoryAuthorizatorTest.java    |  27 +-
 .../apache/james/jmap/api/change/JmapChange.java   |   4 +-
 .../dnsservice/dnsjava/DNSJavaServiceTest.java     |  32 +-
 .../library/MXHostAddressIteratorTest.java         |   7 +-
 .../inetnetwork/InetNetworkBuilderTest.java        |  14 +-
 .../library/inetnetwork/model/InetNetworkTest.java |  24 +-
 .../library/netmatcher/NetMatcherTest.java         |  32 +-
 .../dnsservice/api/AbstractDNSServiceTest.java     |  17 +-
 .../AutomaticallySentMailDetectorImplTest.java     |  57 +-
 .../impl/JamesMailetContextTest.java               | 102 ++--
 .../mailetcontainer/impl/MailetConfigImplTest.java |  20 +-
 .../mailetcontainer/impl/matchers/AndTest.java     |  21 +-
 .../mailetcontainer/impl/matchers/NotTest.java     |  21 +-
 .../mailetcontainer/impl/matchers/OrTest.java      |  21 +-
 .../mailetcontainer/impl/matchers/XorTest.java     |  24 +-
 .../lib/AbstractStateCompositeProcessorTest.java   |   8 +-
 .../lib/AbstractStateMailetProcessorTest.java      |   2 +-
 .../RecipientRewriteTableProcessorTest.java        |  58 +-
 .../mailets/RecipientRewriteTableTest.java         |  38 +-
 .../transport/mailets/ResourceLocatorTest.java     |  15 +-
 .../james/transport/mailets/WithPriorityTest.java  |  26 +-
 .../mailets/WithStorageDirectiveTest.java          |  38 +-
 .../mailets/delivery/LocalDeliveryTest.java        |  14 +-
 .../mailets/delivery/MailDispatcherTest.java       |  30 +-
 .../mailets/delivery/SieveIntegrationTest.java     | 170 +++---
 .../mailets/delivery/SimpleMailStoreTest.java      |  17 +-
 .../mailets/jsieve/DiscardActionTest.java          |  13 +-
 .../managesieve/ManageSieveMailetTestCase.java     |  98 ++--
 .../redirect/LoadedOnceInitParametersTest.java     |   7 +-
 .../redirect/NotifyMailetInitParametersTest.java   |  99 ++--
 .../mailets/redirect/NotifyMailetsMessageTest.java |  61 +--
 .../redirect/RedirectMailetInitParametersTest.java |  15 +-
 .../mailets/redirect/SpecialAddressTest.java       |  27 +-
 ...dressesArrayToMailAddressListConverterTest.java |  14 +-
 .../mailets/remote/delivery/BouncerTest.java       |  48 +-
 .../remote/delivery/DeliveryRetryHelperTest.java   |  18 +-
 .../mailets/remote/delivery/MailDelivrerTest.java  |  54 +-
 .../remote/delivery/RemoteDeliveryRunningTest.java |  19 +-
 .../remote/delivery/RemoteDeliveryTest.java        |  20 +-
 .../transport/matchers/AtLeastPriorityTest.java    |  16 +-
 .../transport/matchers/AtMostPriorityTest.java     |  16 +-
 .../james/transport/matchers/HasPriorityTest.java  |  12 +-
 .../transport/matchers/InSpammerBlacklistTest.java |  12 +-
 .../transport/matchers/IsMarkedAsSpamTest.java     |  23 +-
 .../james/transport/matchers/IsOverQuotaTest.java  |  20 +-
 .../transport/matchers/IsSenderInRRTLoopTest.java  |  22 +-
 .../matchers/RemoteAddrInNetworkTest.java          |  14 +-
 .../matchers/RemoteAddrNotInNetworkTest.java       |  18 +-
 .../james/transport/util/RecipientsUtilsTest.java  |  21 +-
 .../james/transport/util/ReplyToUtilsTest.java     |  11 +-
 .../james/transport/util/SenderUtilsTest.java      |  13 +-
 .../apache/james/transport/util/SizeUtilsTest.java |  23 +-
 .../apache/james/transport/util/TosUtilsTest.java  |  21 +-
 .../memory/MemoryMailRepositoryStoreTest.java      |  62 +--
 .../rfc8621/contract/CustomMethodContract.scala    |   4 +-
 .../rfc8621/contract/SessionRoutesContract.scala   |   4 +-
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 608 ++++++++++++++++++++-
 server/protocols/jmap-rfc-8621/pom.xml             |  10 +
 .../AccountIdRegistrationKey.scala}                |  25 +-
 .../apache/james/jmap/change}/EventDTOModule.scala |  12 +-
 .../james/jmap/change/JmapEventSerializer.scala    |  77 +++
 .../james/jmap/change/MailboxChangeListener.scala  |  33 +-
 .../org/apache/james/jmap/change/StateChange.scala |  93 ++++
 .../james/jmap/change/StateChangeListener.scala}   |  46 +-
 .../org/apache/james/jmap/core/Capabilities.scala  |   2 +-
 .../scala/org/apache/james/jmap/core/Session.scala |   6 +
 .../james/jmap/core/WebSocketTransport.scala       |  16 +-
 .../james/jmap/json/ResponseSerializer.scala       |  23 +
 .../scala/org/apache/james/jmap/json/package.scala |   2 +-
 .../jmap/method/VacationResponseSetMethod.scala    |  24 +-
 .../apache/james/jmap/routes/WebSocketRoutes.scala |  61 ++-
 .../change/AccountIdRegistrationKeyTest.scala}     |  39 +-
 .../jmap/change/MailboxChangeListenerTest.scala    |  16 +-
 .../change/StateChangeEventSerializerTest.scala    | 100 ++++
 .../jmap/change/StateChangeListenerTest.scala      |  93 ++++
 .../james/jmap/routes/SessionRoutesTest.scala      |   4 +-
 .../java/org/apache/james/jmap}/InjectionKeys.java |   4 +-
 .../library/AbstractMailQueueFactoryTest.java      |  16 +-
 src/site/xdoc/server/config-jmap.xml               |   3 +-
 .../james/spamassassin/SpamAssassinResultTest.java |  33 +-
 108 files changed, 2539 insertions(+), 1462 deletions(-)
 delete mode 100644 server/container/cli-integration/src/test/resources/jmap.properties
 create mode 100644 server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/event/JMAPEventBusModule.java
 copy server/container/guice/protocols/{managedsieve/src/main/java/org/apache/james/modules/protocols/SieveModule.java => jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java} (82%)
 copy server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/{json/UploadSerializer.scala => change/AccountIdRegistrationKey.scala} (61%)
 copy {event-sourcing/event-store-cassandra/src/main/scala/org/apache/james/eventsourcing/eventstore/cassandra/dto => server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change}/EventDTOModule.scala (92%)
 create mode 100644 server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
 create mode 100644 server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
 copy server/{mailet/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MatcherManagementMBean.java => protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala} (58%)
 copy server/protocols/jmap-rfc-8621/src/{main/scala/org/apache/james/jmap/json/UploadSerializer.scala => test/scala/org/apache/james/jmap/change/AccountIdRegistrationKeyTest.scala} (51%)
 create mode 100644 server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
 create mode 100644 server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
 copy server/protocols/{jmap-draft/src/main/java/org/apache/james/jmap/http => jmap/src/main/java/org/apache/james/jmap}/InjectionKeys.java (95%)


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


[james-project] 22/33: JAMES-3491 StateChangeEvent Serialization

Posted by bt...@apache.org.
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 1b59476c1f90ac6ebe67cd16cf020d505feae996
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 10:55:31 2021 +0700

    JAMES-3491 StateChangeEvent Serialization
---
 .../src/main/scala/org/apache/james/jmap/change/StateChange.scala  | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index 312aa72..101b592 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -51,7 +51,6 @@ case class StateChangeEvent(eventId: EventId,
                             username: Username,
                             mailboxState: Option[State],
                             emailState: Option[State]) extends Event {
-
   def asStateChange: StateChange =
     StateChange(Map(AccountId.from(username).fold(
       failure => throw new IllegalArgumentException(failure),
@@ -60,9 +59,9 @@ case class StateChangeEvent(eventId: EventId,
         MailboxTypeName.asMap(mailboxState) ++
           EmailTypeName.asMap(emailState))))
 
-  override def getUsername: Username = username
+  override val getUsername: Username = username
 
-  override def isNoop: Boolean = mailboxState.isEmpty && emailState.isEmpty
+  override val isNoop: Boolean = mailboxState.isEmpty && emailState.isEmpty
 
-  override def getEventId: EventId = eventId
+  override val getEventId: EventId = eventId
 }
\ No newline at end of file


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


[james-project] 13/33: JAMES-3491 StateChangeEvent Serialization

Posted by bt...@apache.org.
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 1947f84be42c6efdb68ac2bd42632c319b766483
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Feb 2 11:52:43 2021 +0700

    JAMES-3491 StateChangeEvent Serialization
---
 server/protocols/jmap-rfc-8621/pom.xml             | 10 +++
 .../apache/james/jmap/change/EventDTOModule.scala  | 38 +++++++++++
 .../james/jmap/change/JmapEventSerializer.scala    | 76 ++++++++++++++++++++++
 .../org/apache/james/jmap/change/StateChange.scala | 57 ++++++++++++++++
 .../scala/org/apache/james/jmap/core/Session.scala |  6 ++
 .../james/jmap/json/ResponseSerializer.scala       |  7 ++
 .../change/StateChangeEventSerializerTest.scala    | 70 ++++++++++++++++++++
 7 files changed, 264 insertions(+)

diff --git a/server/protocols/jmap-rfc-8621/pom.xml b/server/protocols/jmap-rfc-8621/pom.xml
index 70a0624..9a6058e 100644
--- a/server/protocols/jmap-rfc-8621/pom.xml
+++ b/server/protocols/jmap-rfc-8621/pom.xml
@@ -65,6 +65,16 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>james-json</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-json</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-core</artifactId>
         </dependency>
         <dependency>
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/EventDTOModule.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/EventDTOModule.scala
new file mode 100644
index 0000000..f5a47ad
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/EventDTOModule.scala
@@ -0,0 +1,38 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap.change
+
+import org.apache.james.events.Event
+import org.apache.james.json.{DTO, DTOModule}
+
+
+trait EventDTO extends DTO
+
+object EventDTOModule {
+  def forEvent[EventTypeT <: Event](eventType: Class[EventTypeT]) = new DTOModule.Builder[EventTypeT](eventType)
+}
+
+case class EventDTOModule[T <: Event, U <: EventDTO](converter: DTOModule.DTOConverter[T, U],
+                                                     toDomainObjectConverter: DTOModule.DomainObjectConverter[T, U],
+                                                     domainObjectType: Class[T],
+                                                     dtoType: Class[U],
+                                                     typeName: String) extends DTOModule[T, U](converter, toDomainObjectConverter, domainObjectType, dtoType, typeName) {
+  override def toDTO(domainObject: T) : U = super.toDTO(domainObject)
+}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
new file mode 100644
index 0000000..2c4e28c
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
@@ -0,0 +1,76 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap.change
+
+import java.util.Optional
+
+import com.fasterxml.jackson.annotation.JsonProperty
+import javax.inject.Inject
+import org.apache.james.core.Username
+import org.apache.james.events.Event.EventId
+import org.apache.james.events.{Event, EventSerializer}
+import org.apache.james.jmap.core.State
+import org.apache.james.json.JsonGenericSerializer
+
+import scala.jdk.CollectionConverters._
+import scala.jdk.OptionConverters._
+
+object StateChangeEventDTO {
+  val dtoModule: EventDTOModule[StateChangeEvent, StateChangeEventDTO] = EventDTOModule.forEvent(classOf[StateChangeEvent])
+    .convertToDTO(classOf[StateChangeEventDTO])
+    .toDomainObjectConverter(dto => dto.toDomainObject)
+    .toDTOConverter((event, aType) => StateChangeEventDTO.toDTO(event))
+    .typeName(classOf[StateChangeEvent].getCanonicalName)
+    .withFactory(EventDTOModule.apply);
+
+  def toDTO(event: StateChangeEvent): StateChangeEventDTO = StateChangeEventDTO(
+    getType = classOf[StateChangeEvent].getCanonicalName,
+    getEventId = event.eventId.getId.toString,
+    getUsername = event.username.asString(),
+    getMailboxState = event.mailboxState.map(_.value).map(_.toString).toJava,
+    getEmailState = event.emailState.map(_.value).map(_.toString).toJava)
+}
+
+case class StateChangeEventDTO(@JsonProperty("type") getType: String,
+                               @JsonProperty("eventId") getEventId: String,
+                               @JsonProperty("username") getUsername: String,
+                               @JsonProperty("mailboxState") getMailboxState: Optional[String],
+                               @JsonProperty("emailState") getEmailState: Optional[String]) extends EventDTO {
+  def toDomainObject: StateChangeEvent = StateChangeEvent(
+    eventId = EventId.of(getEventId),
+    username = Username.of(getUsername),
+    mailboxState = getMailboxState.toScala.map(State.fromStringUnchecked),
+    emailState = getEmailState.toScala.map(State.fromStringUnchecked))
+}
+
+case class JmapEventSerializer(dtoModules: Set[EventDTOModule[Event, EventDTO]]) extends EventSerializer {
+  @Inject
+  def this(javaModules: java.util.Set[EventDTOModule[Event, EventDTO]]) {
+    this(javaModules.asScala.toSet)
+  }
+
+  private val genericSerializer: JsonGenericSerializer[Event, EventDTO] = JsonGenericSerializer
+    .forModules(dtoModules.asJava)
+    .withoutNestedType()
+
+  override def toJson(event: Event): String = genericSerializer.serialize(event)
+
+  override def asEvent(serialized: String): Event = genericSerializer.deserialize(serialized)
+}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
new file mode 100644
index 0000000..d6c555c
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -0,0 +1,57 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap.change
+
+import org.apache.james.core.Username
+import org.apache.james.events.Event
+import org.apache.james.events.Event.EventId
+import org.apache.james.jmap.core.{AccountId, State}
+
+sealed trait TypeName {
+  def asMap(maybeState: Option[State]): Map[TypeName, State] =
+    maybeState.map(state => Map[TypeName, State](this -> state))
+      .getOrElse(Map())
+}
+case object MailboxTypeName extends TypeName
+case object EmailTypeName extends TypeName
+
+case class StateChange(changes: Map[AccountId, TypeState])
+
+case class TypeState(changes: Map[TypeName, State])
+
+case class StateChangeEvent(eventId: EventId,
+                            username: Username,
+                            mailboxState: Option[State],
+                            emailState: Option[State]) extends Event {
+
+  def asStateChange: StateChange =
+    StateChange(Map(AccountId.from(username).fold(
+      failure => throw new IllegalArgumentException(failure),
+      success => success) ->
+      TypeState(
+        MailboxTypeName.asMap(mailboxState) ++
+          EmailTypeName.asMap(emailState))))
+
+  override def getUsername: Username = username
+
+  override def isNoop: Boolean = false
+
+  override def getEventId: EventId = eventId
+}
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala
index bca220a..9ab5a13 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala
@@ -80,6 +80,12 @@ object State {
 
   val INSTANCE: State = fromJava(JavaState.INITIAL)
 
+  def fromStringUnchecked(value: String): State = 
+    refineV[Uuid](value)
+      .fold(
+        failure => throw new IllegalArgumentException(failure),
+        success => State.fromString(success))
+
   def fromString(value: UUIDString): State = State(UUID.fromString(value.value))
 
   def fromMailboxChanges(mailboxChanges: MailboxChanges): State = fromJava(mailboxChanges.getNewState)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
index 71e04f7..2304565 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
@@ -185,10 +185,17 @@ object ResponseSerializer {
       }
     case _ => JsError("Expecting a JsObject to represent a webSocket inbound request")
   }
+  private implicit val typeNameReads: Reads[TypeName] = {
+    case JsString(value) if value.equals(MailboxTypeName.asString()) => JsSuccess(MailboxTypeName)
+    case JsString(value) if value.equals(EmailTypeName.asString()) => JsSuccess(EmailTypeName)
+    case _ => JsError("Expecting a JsString as typeName")
+  }
+  private implicit val webSocketPushEnableReads: Reads[WebSocketPushEnable] = Json.reads[WebSocketPushEnable]
   private implicit val webSocketInboundReads: Reads[WebSocketInboundMessage] = {
     case json: JsObject =>
       json.value.get("@type") match {
         case Some(JsString("Request")) => webSocketRequestReads.reads(json)
+        case Some(JsString("WebSocketPushEnable")) => webSocketPushEnableReads.reads(json)
         case Some(JsString(unknownType)) => JsError(s"Unknown @type field on a webSocket inbound message: $unknownType")
         case Some(invalidType) => JsError(s"Invalid @type field on a webSocket inbound message: expecting a JsString, got $invalidType")
         case None => JsError(s"Missing @type field on a webSocket inbound message")
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
new file mode 100644
index 0000000..cab2643
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
@@ -0,0 +1,70 @@
+ /***************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.jmap.change
+
+import org.apache.james.JsonSerializationVerifier
+import org.apache.james.core.Username
+import org.apache.james.events.Event.EventId
+import org.apache.james.jmap.change.StateChangeEventSerializerTest.{EVENT, EVENT_JSON}
+import org.apache.james.jmap.core.State
+import org.apache.james.json.JsonGenericSerializer
+import org.apache.james.json.JsonGenericSerializer.UnknownTypeException
+import org.assertj.core.api.Assertions.assertThatThrownBy
+import org.junit.jupiter.api.Test
+
+
+object StateChangeEventSerializerTest {
+  val EVENT_ID: EventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4")
+  val USERNAME: Username = Username.of("bob")
+  val EVENT: StateChangeEvent = StateChangeEvent(EVENT_ID, USERNAME, Some(State.INSTANCE), Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
+  val EVENT_JSON: String =
+    """{
+      |  "eventId":"6e0dd59d-660e-4d9b-b22f-0354479f47b4",
+      |  "username":"bob",
+      |  "mailboxState":"2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+      |  "emailState":"2d9f1b12-b35a-43e6-9af2-0106fb53a943",
+      |  "type":"org.apache.james.jmap.change.StateChangeEvent"
+      |}""".stripMargin
+}
+
+class StateChangeEventSerializerTest {
+  @Test
+  def shouldSerializeKnownEvent(): Unit =
+    JsonSerializationVerifier.serializer(JsonGenericSerializer
+      .forModules(StateChangeEventDTO.dtoModule)
+      .withoutNestedType())
+      .bean(EVENT)
+      .json(EVENT_JSON)
+      .verify()
+
+  @Test
+  def shouldThrowWhenDeserializeUnknownEvent(): Unit =
+    assertThatThrownBy(() =>
+      JsonGenericSerializer
+        .forModules(StateChangeEventDTO.dtoModule)
+        .withoutNestedType()
+        .deserialize("""{
+                       |  "eventId":"6e0dd59d-660e-4d9b-b22f-0354479f47b4",
+                       |  "username":"bob",
+                       |  "mailboxState":"2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+                       |  "emailState":"2d9f1b12-b35a-43e6-9af2-0106fb53a943",
+                       |  "type":"org.apache.james.jmap.change.Unknown"
+                       |}""".stripMargin))
+      .isInstanceOf(classOf[UnknownTypeException])
+}
\ No newline at end of file


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


[james-project] 31/33: [REFACTORING] Convert server/dns tests to JUNIT 5

Posted by bt...@apache.org.
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 6ab9d7144f2f215ea323684bd013c4dd2fd2ac63
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Feb 8 11:46:46 2021 +0700

    [REFACTORING] Convert server/dns tests to JUNIT 5
    
     - Clean up some javadoc along the way
---
 .../dnsservice/dnsjava/DNSJavaServiceTest.java     | 32 +++++++++++-----------
 .../library/MXHostAddressIteratorTest.java         |  7 ++---
 .../inetnetwork/InetNetworkBuilderTest.java        | 14 ++--------
 .../library/inetnetwork/model/InetNetworkTest.java | 24 +++++-----------
 .../library/netmatcher/NetMatcherTest.java         | 32 ++++++----------------
 .../dnsservice/api/AbstractDNSServiceTest.java     | 17 ++++--------
 6 files changed, 44 insertions(+), 82 deletions(-)

diff --git a/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java b/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
index e27a880..939cb70 100644
--- a/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
+++ b/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
@@ -34,9 +34,9 @@ import java.util.List;
 
 import org.apache.james.metrics.tests.RecordingMetricFactory;
 import org.apache.james.server.core.configuration.FileConfigurationProvider;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xbill.DNS.Cache;
@@ -48,7 +48,7 @@ import org.xbill.DNS.Zone;
 
 import com.google.common.io.Resources;
 
-public class DNSJavaServiceTest {
+class DNSJavaServiceTest {
     private static final Logger LOGGER = LoggerFactory.getLogger(DNSJavaServiceTest.class);
 
     private TestableDNSServer dnsServer;
@@ -63,8 +63,8 @@ public class DNSJavaServiceTest {
 
     private Cache mockedCache;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         dnsServer = new TestableDNSServer();
 
         dnsServer.configure(FileConfigurationProvider.getConfig(new ByteArrayInputStream(DNS_SERVER_CONFIG)));
@@ -81,8 +81,8 @@ public class DNSJavaServiceTest {
         mockedCache = mock(Cache.class);
     }
 
-    @After
-    public void tearDown() throws Exception {
+    @AfterEach
+    void tearDown() {
         dnsServer.setCache(null);
         dnsServer = null;
         Lookup.setDefaultCache(defaultCache, DClass.IN);
@@ -91,7 +91,7 @@ public class DNSJavaServiceTest {
     }
 
     @Test
-    public void testNoMX() throws Exception {
+    void testNoMX() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("dnstest.com.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -103,7 +103,7 @@ public class DNSJavaServiceTest {
     }
 
     @Test
-    public void testBadMX() throws Exception {
+    void testBadMX() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("dnstest.com.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -118,7 +118,7 @@ public class DNSJavaServiceTest {
     }
 
     @Test
-    public void testINARecords() throws Exception {
+    void testINARecords() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("pippo.com.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -130,7 +130,7 @@ public class DNSJavaServiceTest {
     }
 
     @Test
-    public void testMXCatches() throws Exception {
+    void testMXCatches() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("test-zone.com.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -151,7 +151,7 @@ public class DNSJavaServiceTest {
      * Test for JAMES-1251
      */
     @Test
-    public void testTwoMXSamePrio() throws Exception {
+    void testTwoMXSamePrio() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("two-mx.sameprio.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -164,7 +164,7 @@ public class DNSJavaServiceTest {
     }
 
     @Test
-    public void testThreeMX() throws Exception {
+    void testThreeMX() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("three-mx.bar.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -182,7 +182,7 @@ public class DNSJavaServiceTest {
      * Test for JAMES-1251
      */
     @Test
-    public void testTwoMXDifferentPrio() throws Exception {
+    void testTwoMXDifferentPrio() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("two-mx.differentprio.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
@@ -198,7 +198,7 @@ public class DNSJavaServiceTest {
      * Test for JAMES-1251
      */
     @Test
-    public void testOneMX() throws Exception {
+    void testOneMX() throws Exception {
         doAnswer(new ZoneCacheLookupRecordsAnswer(loadZone("one-mx.bar.")))
                 .when(mockedCache).lookupRecords(any(Name.class), anyInt(), anyInt());
         dnsServer.setCache(mockedCache);
diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java
index c43e061..6f8a57d 100644
--- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java
+++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java
@@ -25,17 +25,16 @@ import java.util.Arrays;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.InMemoryDNSService;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
 public class MXHostAddressIteratorTest {
-
     /**
      * Test case for JAMES-1251
      */
     @Test
-    public void testIteratorContainMultipleMX() throws Exception {
+    void testIteratorContainMultipleMX() throws Exception {
         InetAddress address = InetAddress.getLocalHost();
         ImmutableList<String> mxs = ImmutableList.of(address.getHostAddress());
         ImmutableList<String> noTxtRecord = ImmutableList.of();
@@ -60,7 +59,7 @@ public class MXHostAddressIteratorTest {
     }
 
     @Test
-    public void testIteratorWithInvalidMX() {
+    void testIteratorWithInvalidMX() {
 
         // See JAMES-1271
         MXHostAddressIterator it = new MXHostAddressIterator(Arrays.asList("localhost").iterator(), new InMemoryDNSService(), false);
diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java
index bc0a786..fa1c97b 100644
--- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java
+++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java
@@ -24,23 +24,17 @@ import java.net.UnknownHostException;
 
 import org.apache.james.dnsservice.api.mock.DNSFixture;
 import org.apache.james.dnsservice.library.inetnetwork.model.InetNetwork;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-/**
- * Test the InetNetworkBuilder.
- */
 public class InetNetworkBuilderTest {
-
     private InetNetworkBuilder inetNetworkBuilder;
     private InetNetwork inetNetwork;
 
     /**
      * Verify that InetNetworkBuild return correctly initialized Inet4Network.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInetNetworkBuilderDnsV4() throws UnknownHostException {
+    void testInetNetworkBuilderDnsV4() throws UnknownHostException {
 
         inetNetworkBuilder = new InetNetworkBuilder(DNSFixture.DNS_SERVER_IPV4_MOCK);
 
@@ -54,11 +48,9 @@ public class InetNetworkBuilderTest {
 
     /**
      * Verify that InetNetworkBuild return correctly initialized Inet6Network.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInetNetworkBuilderDnsV6() throws UnknownHostException {
+    void testInetNetworkBuilderDnsV6() throws UnknownHostException {
 
         inetNetworkBuilder = new InetNetworkBuilder(DNSFixture.DNS_SERVER_IPV6_MOCK);
 
diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java
index 677950c..371beaf 100644
--- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java
+++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java
@@ -26,12 +26,12 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.StringTokenizer;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test the InetNetwork class with various IPv4 and IPv6 network specification.
  */
-public class InetNetworkTest {
+class InetNetworkTest {
 
     private static InetAddress address;
 
@@ -42,11 +42,9 @@ public class InetNetworkTest {
      * The InetAddress.toString() returns a string with format
      * "name/ip_address". It has no indication of subnetmask. The name is
      * optional.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInetAddress() throws UnknownHostException {
+    void testInetAddress() throws UnknownHostException {
 
         // Test name alone (can be IPv4 or IPv6 depending on the OS plaform
         // configuration).
@@ -62,11 +60,9 @@ public class InetNetworkTest {
      * The InetAddress.toString() returns a string with format
      * "name/ip_address". It has no indication of subnetmask. The returned name
      * is optional.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInet4Address() throws UnknownHostException {
+    void testInet4Address() throws UnknownHostException {
 
         // Test Bad IP V4 address.
         try {
@@ -99,11 +95,9 @@ public class InetNetworkTest {
      * The InetAddress.toString() returns a string with format
      * "name/ip_address". It has no indication of subnetmask. The returned name
      * is optional.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInet6Address() throws UnknownHostException {
+    void testInet6Address() throws UnknownHostException {
 
         // Test Bad IP V6 address.
         try {
@@ -128,11 +122,9 @@ public class InetNetworkTest {
 
     /**
      * Test the Inet4Network.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInet4Network() throws UnknownHostException {
+     void testInet4Network() throws UnknownHostException {
 
         // Test with null parameter.
         address = InetAddress.getByAddress(getBytesFromAddress("127.0.0.1"));
@@ -153,11 +145,9 @@ public class InetNetworkTest {
 
     /**
      * Test the Inet6Network.
-     * 
-     * @throws UnknownHostException
      */
     @Test
-    public void testInet6Network() throws UnknownHostException {
+    void testInet6Network() throws UnknownHostException {
 
         // Test with null parameter.
         address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
index dbea721..94228d3 100644
--- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
+++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
@@ -20,24 +20,20 @@ package org.apache.james.dnsservice.library.netmatcher;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.net.UnknownHostException;
-
 import org.apache.james.dnsservice.api.mock.DNSFixture;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test the NetMatcher class with various IPv4 and IPv6 parameters.
- * 
  */
-public class NetMatcherTest {
-
+class NetMatcherTest {
     private static NetMatcher netMatcher;
 
     /**
      * Test ability to split expressions even when comma is not followed by a space.
      */
     @Test
-    public void testSplitterDoesNotRequireSpaceAfterComma() {
+    void testSplitterDoesNotRequireSpaceAfterComma() {
         netMatcher = new NetMatcher("127.0.0.1,192.168.100.14/24,10.*", DNSFixture.DNS_SERVER_IPV4_MOCK);
         assertThat(netMatcher.toString())
                 .isEqualTo("[10.0.0.0/255.0.0.0, 127.0.0.1/255.255.255.255, 192.168.100.0/255.255.255.0]");
@@ -47,7 +43,7 @@ public class NetMatcherTest {
      * Test for IPV4 uniqueness.
      */
     @Test
-    public void testIpV4NetworksUniqueness() {
+    void testIpV4NetworksUniqueness() {
         netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES_DUPLICATE, DNSFixture.DNS_SERVER_IPV4_MOCK);
         assertThat(netMatcher.toString()).isEqualTo("[172.16.0.0/255.255.0.0, 192.168.1.0/255.255.255.0]");
     }
@@ -56,17 +52,16 @@ public class NetMatcherTest {
      * Test for IPV6 uniqueness.
      */
     @Test
-    public void testIpV6NetworksUniqueness() {
+    void testIpV6NetworksUniqueness() {
         netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES_DUPLICATE, DNSFixture.DNS_SERVER_IPV6_MOCK);
         assertThat(netMatcher.toString()).isEqualTo("[0:0:0:0:0:0:0:1/32768, 2781:db8:1234:0:0:0:0:0/48]");
     }
 
     /**
      * Test for IPV4 matcher.
-     * @throws UnknownHostException
      */
     @Test
-    public void testIpV4Matcher() throws UnknownHostException {
+    void testIpV4Matcher() {
 
         netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK);
 
@@ -77,11 +72,8 @@ public class NetMatcherTest {
         assertThat(netMatcher.matchInetNetwork("192.169.1.254")).isFalse();
     }
 
-    /**
-     * @throws UnknownHostException
-     */
     @Test
-    public void testIpV4MatcherWithIpV6() throws UnknownHostException {
+    void testIpV4MatcherWithIpV6() {
 
         netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK);
 
@@ -92,11 +84,8 @@ public class NetMatcherTest {
         assertThat(netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001")).isFalse();
     }
 
-    /**
-     * @throws UnknownHostException
-     */
     @Test
-    public void testIpV6Matcher() throws UnknownHostException {
+    void testIpV6Matcher() {
 
         netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK);
 
@@ -107,11 +96,8 @@ public class NetMatcherTest {
         assertThat(netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001")).isFalse();
     }
 
-    /**
-     * @throws UnknownHostException
-     */
     @Test
-    public void testIpV6MatcherWithIpV4() throws UnknownHostException {
+    void testIpV6MatcherWithIpV4() {
 
         netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK);
 
diff --git a/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java b/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java
index 6b93f5d..4950034 100644
--- a/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java
+++ b/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java
@@ -25,8 +25,8 @@ import java.net.UnknownHostException;
 import java.util.Collection;
 
 import org.apache.james.dnsservice.api.mock.MockDNSService;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
@@ -35,8 +35,7 @@ import com.google.common.collect.ImmutableList;
  * Basic tests for AbstractDNSServer. The goal is to verify that the interface
  * remains constants and that the built platform has access to the Internet.
  */
-public class AbstractDNSServiceTest {
-
+class AbstractDNSServiceTest {
     /**
      * Simple Mock DNSService relaying on InetAddress.
      */
@@ -65,11 +64,9 @@ public class AbstractDNSServiceTest {
 
     /**
      * Simple localhost resolution.
-     *
-     * @throws UnknownHostException
      */
     @Test
-    public void testLocalhost() throws UnknownHostException {
+    void testLocalhost() throws UnknownHostException {
 
         assertThat(DNS_SERVER.getByName("localhost").toString()).isEqualTo("localhost/127.0.0.1");
 
@@ -81,12 +78,10 @@ public class AbstractDNSServiceTest {
 
     /**
      * Simple apache.org resolution.
-     *
-     * @throws UnknownHostException
      */
     @Test
-    @Ignore(value = "It requires internet connection!")
-    public void testApache() throws UnknownHostException {
+    @Disabled(value = "It requires internet connection!")
+    void testApache() throws UnknownHostException {
         //TODO: move to some sort of Live tests
         assertThat(DNS_SERVER.getByName("www.apache.org").toString().startsWith("www.apache.org")).isTrue();
     }


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


[james-project] 08/33: [REFACTORING] Get rid of some JUNIT 4 usages in guice-mailet tests

Posted by bt...@apache.org.
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 4651973290022a6fcd59ca61f79a8b5561c9dbae
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 10:12:19 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in guice-mailet tests
---
 .../apache/james/utils/GuiceMailetLoaderTest.java  | 56 ++++++++++------------
 .../apache/james/utils/GuiceMatcherLoaderTest.java | 49 +++++++++----------
 2 files changed, 48 insertions(+), 57 deletions(-)

diff --git a/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMailetLoaderTest.java b/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMailetLoaderTest.java
index 43c2434..5b8937b 100644
--- a/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMailetLoaderTest.java
+++ b/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMailetLoaderTest.java
@@ -24,6 +24,7 @@ import static org.apache.james.filesystem.api.FileSystemFixture.RECURSIVE_CLASSP
 import static org.apache.james.filesystem.api.FileSystemFixture.THROWING_FILE_SYSTEM;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -33,22 +34,17 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.inject.Guice;
 
-public class GuiceMailetLoaderTest {
-
+class GuiceMailetLoaderTest {
     public static final ImmutableSet<MailetConfigurationOverride> NO_MAILET_CONFIG_OVERRIDES = ImmutableSet.of();
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
 
     @Test
-    public void getMailetShouldLoadClass() throws Exception {
+    void getMailetShouldLoadClass() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(THROWING_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -61,7 +57,7 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailetShouldLoadClassWhenInSubPackageFromDefaultPackage() throws Exception {
+    void getMailetShouldLoadClassWhenInSubPackageFromDefaultPackage() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(THROWING_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -74,20 +70,20 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailetShouldThrowOnBadType() throws Exception {
+    void getMailetShouldThrowOnBadType() {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(THROWING_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
-        expectedException.expect(MessagingException.class);
-
-        guiceMailetLoader.getMailet(FakeMailetConfig.builder()
-            .mailetName("org.apache.james.transport.matchers.SizeGreaterThan")
-            .mailetContext(FakeMailContext.defaultContext())
-            .build());
+        assertThatThrownBy(() ->
+            guiceMailetLoader.getMailet(FakeMailetConfig.builder()
+                .mailetName("org.apache.james.transport.matchers.SizeGreaterThan")
+                .mailetContext(FakeMailContext.defaultContext())
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void getMailetShouldLoadClassWhenInExtensionsJars() throws Exception {
+    void getMailetShouldLoadClassWhenInExtensionsJars() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(CLASSPATH_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -101,7 +97,7 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailetShouldBrowseRecursivelyExtensionsJars() throws Exception {
+    void getMailetShouldBrowseRecursivelyExtensionsJars() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -115,7 +111,7 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailedShouldAllowCustomPackages() throws Exception {
+    void getMailedShouldAllowCustomPackages() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(CLASSPATH_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -129,20 +125,20 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailetShouldThrowOnUnknownMailet() throws Exception {
+    void getMailetShouldThrowOnUnknownMailet() {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(CLASSPATH_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
-        expectedException.expect(MessagingException.class);
-
-        guiceMailetLoader.getMailet(FakeMailetConfig.builder()
-            .mailetName("org.apache.james.transport.mailets.Unknown")
-            .mailetContext(FakeMailContext.defaultContext())
-            .build());
+        assertThatThrownBy(() ->
+            guiceMailetLoader.getMailet(FakeMailetConfig.builder()
+                .mailetName("org.apache.james.transport.mailets.Unknown")
+                .mailetContext(FakeMailContext.defaultContext())
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void getMailetShouldLoadMailetsWithCustomDependencyInConstructor() throws Exception {
+    void getMailetShouldLoadMailetsWithCustomDependencyInConstructor() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -156,7 +152,7 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailetShouldLoadMailetsWithCustomDependencyInService() throws Exception {
+    void getMailetShouldLoadMailetsWithCustomDependencyInService() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM));
         GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES);
 
@@ -169,7 +165,7 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void getMailetShouldAllowCustomInjections() throws Exception {
+    void getMailetShouldAllowCustomInjections() throws Exception {
         GuiceGenericLoader genericLoader = new GuiceGenericLoader(
             Guice.createInjector(),
             new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM),
@@ -185,7 +181,7 @@ public class GuiceMailetLoaderTest {
     }
 
     @Test
-    public void allMailetsShouldShareTheSameSingleton() throws Exception {
+    void allMailetsShouldShareTheSameSingleton() throws Exception {
         GuiceGenericLoader genericLoader = new GuiceGenericLoader(
             Guice.createInjector(),
             new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM),
diff --git a/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMatcherLoaderTest.java b/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMatcherLoaderTest.java
index f3e110f..711a8ae 100644
--- a/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMatcherLoaderTest.java
+++ b/server/container/guice/mailet/src/test/java/org/apache/james/utils/GuiceMatcherLoaderTest.java
@@ -23,6 +23,7 @@ import static org.apache.james.filesystem.api.FileSystemFixture.CLASSPATH_FILE_S
 import static org.apache.james.filesystem.api.FileSystemFixture.RECURSIVE_CLASSPATH_FILE_SYSTEM;
 import static org.apache.james.filesystem.api.FileSystemFixture.THROWING_FILE_SYSTEM;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -30,17 +31,11 @@ import org.apache.james.transport.matchers.All;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-public class GuiceMatcherLoaderTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+import org.junit.jupiter.api.Test;
 
+class GuiceMatcherLoaderTest {
     @Test
-    public void getMatcherShouldLoadClass() throws Exception {
+    void getMatcherShouldLoadClass() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(THROWING_FILE_SYSTEM));
         GuiceMatcherLoader guiceMailetLoader = new GuiceMatcherLoader(genericLoader);
 
@@ -53,7 +48,7 @@ public class GuiceMatcherLoaderTest {
     }
 
     @Test
-    public void getMatcherShouldLoadClassWhenInSubPackageFromDefaultPackage() throws Exception {
+    void getMatcherShouldLoadClassWhenInSubPackageFromDefaultPackage() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(THROWING_FILE_SYSTEM));
         GuiceMatcherLoader guiceMailetLoader = new GuiceMatcherLoader(genericLoader);
 
@@ -66,20 +61,20 @@ public class GuiceMatcherLoaderTest {
     }
 
     @Test
-    public void getMatcherShouldThrowOnBadType() throws Exception {
+    void getMatcherShouldThrowOnBadType() {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(THROWING_FILE_SYSTEM));
         GuiceMatcherLoader guiceMatcherLoader = new GuiceMatcherLoader(genericLoader);
 
-        expectedException.expect(MessagingException.class);
-
-        guiceMatcherLoader.getMatcher(FakeMatcherConfig.builder()
-            .matcherName("org.apache.james.transport.mailets.Null")
-            .mailetContext(FakeMailContext.defaultContext())
-            .build());
+        assertThatThrownBy(() ->
+            guiceMatcherLoader.getMatcher(FakeMatcherConfig.builder()
+                .matcherName("org.apache.james.transport.mailets.Null")
+                .mailetContext(FakeMailContext.defaultContext())
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void getMatcherShouldLoadClassWhenInExtensionsJars() throws Exception {
+    void getMatcherShouldLoadClassWhenInExtensionsJars() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(CLASSPATH_FILE_SYSTEM));
         GuiceMatcherLoader guiceMatcherLoader = new GuiceMatcherLoader(genericLoader);
 
@@ -93,7 +88,7 @@ public class GuiceMatcherLoaderTest {
     }
 
     @Test
-    public void getMatcherShouldBrowseRecursivelyExtensionJars() throws Exception {
+    void getMatcherShouldBrowseRecursivelyExtensionJars() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM));
         GuiceMatcherLoader guiceMatcherLoader = new GuiceMatcherLoader(genericLoader);
 
@@ -107,7 +102,7 @@ public class GuiceMatcherLoaderTest {
     }
 
     @Test
-    public void getMatcherShouldAllowCustomPackages() throws Exception {
+    void getMatcherShouldAllowCustomPackages() throws Exception {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(RECURSIVE_CLASSPATH_FILE_SYSTEM));
         GuiceMatcherLoader guiceMatcherLoader = new GuiceMatcherLoader(genericLoader);
 
@@ -121,16 +116,16 @@ public class GuiceMatcherLoaderTest {
     }
 
     @Test
-    public void getMatcherShouldThrowOnUnknownMailet() throws Exception {
+    void getMatcherShouldThrowOnUnknownMailet() {
         GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(CLASSPATH_FILE_SYSTEM));
         GuiceMatcherLoader guiceMatcherLoader = new GuiceMatcherLoader(genericLoader);
 
-        expectedException.expect(MessagingException.class);
-
-        guiceMatcherLoader.getMatcher(FakeMatcherConfig.builder()
-            .matcherName("org.apache.james.transport.matchers.Unknown")
-            .mailetContext(FakeMailContext.defaultContext())
-            .build());
+        assertThatThrownBy(() ->
+            guiceMatcherLoader.getMatcher(FakeMatcherConfig.builder()
+                .matcherName("org.apache.james.transport.matchers.Unknown")
+                .mailetContext(FakeMailContext.defaultContext())
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
 }


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


[james-project] 32/33: [REFACTORING] Convert AbstractMailQueueFactoryTest tests to JUNIT 5

Posted by bt...@apache.org.
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 4871ffb028c1d7e420e07137b37c63ae88f72890
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Feb 8 11:48:13 2021 +0700

    [REFACTORING] Convert AbstractMailQueueFactoryTest tests to JUNIT 5
---
 .../queue/library/AbstractMailQueueFactoryTest.java      | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/library/AbstractMailQueueFactoryTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/library/AbstractMailQueueFactoryTest.java
index ff6f8fc..521e16e 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/library/AbstractMailQueueFactoryTest.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/library/AbstractMailQueueFactoryTest.java
@@ -31,8 +31,8 @@ import javax.management.ObjectName;
 
 import org.apache.james.queue.api.MailQueueName;
 import org.apache.james.queue.api.ManageableMailQueue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class AbstractMailQueueFactoryTest {
     private static final MailQueueName QUEUE_1 = MailQueueName.of("queue1");
@@ -42,8 +42,8 @@ public class AbstractMailQueueFactoryTest {
     private AbstractMailQueueFactory<?> abstractMailQueueFactory;
     private MBeanServer mBeanServer;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         mBeanServer = mock(MBeanServer.class);
         abstractMailQueueFactory = new AbstractMailQueueFactory<ManageableMailQueue>() {
             @Override
@@ -55,13 +55,13 @@ public class AbstractMailQueueFactoryTest {
     }
 
     @Test
-    public void destroyShouldRegisterManageableQueues() throws Exception {
+    void destroyShouldRegisterManageableQueues() throws Exception {
         abstractMailQueueFactory.createQueue(QUEUE_1);
         verify(mBeanServer).registerMBean(any(MailQueueManagement.class), eq(new ObjectName(AbstractMailQueueFactory.MBEAN_NAME_QUEUE_PREFIX + QUEUE_1.asString())));
     }
 
     @Test
-    public void destroyShouldUnregisterAllRegisterQueue() throws Exception {
+    void destroyShouldUnregisterAllRegisterQueue() throws Exception {
         abstractMailQueueFactory.createQueue(QUEUE_1);
         abstractMailQueueFactory.createQueue(QUEUE_2);
         abstractMailQueueFactory.createQueue(QUEUE_3);
@@ -72,14 +72,14 @@ public class AbstractMailQueueFactoryTest {
     }
 
     @Test
-    public void unregisterMBeanShouldWork() throws Exception {
+    void unregisterMBeanShouldWork() throws Exception {
         abstractMailQueueFactory.createQueue(QUEUE_1);
         abstractMailQueueFactory.unregisterMBean(AbstractMailQueueFactory.MBEAN_NAME_QUEUE_PREFIX + QUEUE_1.asString());
         verify(mBeanServer).unregisterMBean(eq(new ObjectName(AbstractMailQueueFactory.MBEAN_NAME_QUEUE_PREFIX + QUEUE_1.asString())));
     }
 
     @Test
-    public void destroyShouldNotBeStoppedByExceptions() throws Exception {
+    void destroyShouldNotBeStoppedByExceptions() throws Exception {
         abstractMailQueueFactory.createQueue(QUEUE_1);
         abstractMailQueueFactory.createQueue(QUEUE_2);
         abstractMailQueueFactory.createQueue(QUEUE_3);


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


[james-project] 06/33: [REFACTORING] Get rid of some JUNIT 4 usages in mailbox-adapter tests

Posted by bt...@apache.org.
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 9df470a1bfc718988a3c19a8392245abdd6f82df
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 10:06:47 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in mailbox-adapter tests
---
 .../mailbox/UserRepositoryAuthenticatorTest.java   | 27 +++++++++-------------
 .../mailbox/UserRepositoryAuthorizatorTest.java    | 27 +++++++++-------------
 2 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java
index 60208bd..7cf075e 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.adapter.mailbox;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -27,10 +28,8 @@ import org.apache.james.core.Username;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class UserRepositoryAuthenticatorTest {
 
@@ -41,43 +40,39 @@ public class UserRepositoryAuthenticatorTest {
     private UsersRepository usersRepository;
     private UserRepositoryAuthenticator testee;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         usersRepository = mock(UsersRepository.class);
         testee = new UserRepositoryAuthenticator(usersRepository);
     }
 
     @Test
-    public void isAuthenticShouldReturnTrueWhenGoodLoginPassword() throws Exception {
+    void isAuthenticShouldReturnTrueWhenGoodLoginPassword() throws Exception {
         when(usersRepository.test(USER, PASSWORD)).thenReturn(true);
 
         assertThat(testee.isAuthentic(USER, PASSWORD)).isTrue();
     }
 
     @Test
-    public void isAuthenticShouldReturnFalseWhenWrongPassword() throws Exception {
+    void isAuthenticShouldReturnFalseWhenWrongPassword() throws Exception {
         when(usersRepository.test(USER, BAD_PASSWORD)).thenReturn(false);
 
         assertThat(testee.isAuthentic(USER, BAD_PASSWORD)).isFalse();
     }
 
     @Test
-    public void isAuthenticShouldReturnFalseWhenBadUser() throws Exception {
+    void isAuthenticShouldReturnFalseWhenBadUser() throws Exception {
         when(usersRepository.test(USER, BAD_PASSWORD)).thenReturn(false);
 
         assertThat(testee.isAuthentic(BAD_USER, BAD_PASSWORD)).isFalse();
     }
 
     @Test
-    public void isAuthenticShouldFailOnUserRepositoryFailure() throws Exception {
+    void isAuthenticShouldFailOnUserRepositoryFailure() throws Exception {
         when(usersRepository.test(USER, PASSWORD)).thenThrow(new UsersRepositoryException(""));
 
-        expectedException.expect(MailboxException.class);
-
-        testee.isAuthentic(USER, PASSWORD);
+        assertThatThrownBy(() -> testee.isAuthentic(USER, PASSWORD))
+            .isInstanceOf(MailboxException.class);
     }
 
 }
diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java
index c1c6ca5..fc4d09c 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.adapter.mailbox;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -28,10 +29,8 @@ import org.apache.james.mailbox.Authorizator;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class UserRepositoryAuthorizatorTest {
     private static final Username ADMIN = Username.of("admin");
@@ -40,27 +39,23 @@ public class UserRepositoryAuthorizatorTest {
     private UsersRepository usersRepository;
     private UserRepositoryAuthorizator testee;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         usersRepository = mock(UsersRepository.class);
         testee = new UserRepositoryAuthorizator(usersRepository);
     }
 
     @Test
-    public void canLoginAsOtherUserShouldThrowMailboxExceptionWhenIsAdministratorThrows() throws Exception {
+    void canLoginAsOtherUserShouldThrowMailboxExceptionWhenIsAdministratorThrows() throws Exception {
         when(usersRepository.isAdministrator(ADMIN))
             .thenThrow(new UsersRepositoryException("expected error"));
 
-        expectedException.expect(MailboxException.class);
-
-        testee.canLoginAsOtherUser(ADMIN, USER);
+        assertThatThrownBy(() -> testee.canLoginAsOtherUser(ADMIN, USER))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
-    public void canLoginAsOtherUserShouldReturnNotAdminWhenNotAdminAndNoUser() throws Exception {
+    void canLoginAsOtherUserShouldReturnNotAdminWhenNotAdminAndNoUser() throws Exception {
         when(usersRepository.isAdministrator(ADMIN))
             .thenReturn(false);
         when(usersRepository.contains(USER))
@@ -70,7 +65,7 @@ public class UserRepositoryAuthorizatorTest {
     }
 
     @Test
-    public void canLoginAsOtherUserShouldReturnNotAdminWhenNotAdminAndUser() throws Exception {
+    void canLoginAsOtherUserShouldReturnNotAdminWhenNotAdminAndUser() throws Exception {
         when(usersRepository.isAdministrator(ADMIN))
             .thenReturn(false);
         when(usersRepository.contains(USER))
@@ -80,7 +75,7 @@ public class UserRepositoryAuthorizatorTest {
     }
 
     @Test
-    public void canLoginAsOtherUserShouldReturnUnknownUserWhenUserIsNotInRepository() throws Exception {
+    void canLoginAsOtherUserShouldReturnUnknownUserWhenUserIsNotInRepository() throws Exception {
         when(usersRepository.isAdministrator(ADMIN))
             .thenReturn(true);
         when(usersRepository.contains(USER))
@@ -90,7 +85,7 @@ public class UserRepositoryAuthorizatorTest {
     }
 
     @Test
-    public void canLoginAsOtherUserShouldReturnAllowedWhenAdminAndUserIsInRepository() throws Exception {
+    void canLoginAsOtherUserShouldReturnAllowedWhenAdminAndUserIsInRepository() throws Exception {
         when(usersRepository.isAdministrator(ADMIN))
             .thenReturn(true);
         when(usersRepository.contains(USER))


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


[james-project] 11/33: [REFACTORING] Get rid of some JUNIT 4 usages in spamassassin tests

Posted by bt...@apache.org.
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 66e5c3efbc933804cf5674778741dd0d9501d45d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 12:30:18 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in spamassassin tests
---
 .../james/spamassassin/SpamAssassinResultTest.java | 33 ++++++++++------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinResultTest.java b/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinResultTest.java
index 470f8c9..f738b8b 100644
--- a/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinResultTest.java
+++ b/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinResultTest.java
@@ -23,17 +23,12 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeValue;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.Test;
 
 public class SpamAssassinResultTest {
-
-    @Rule
-    public JUnitSoftAssertions softly = new JUnitSoftAssertions();
-
     @Test
-    public void buildShouldThrowWhenHitsIsNotGiven() {
+    void buildShouldThrowWhenHitsIsNotGiven() {
         assertThatThrownBy(() -> SpamAssassinResult.asSpam()
                 .requiredHits("4.0")
                 .build())
@@ -41,7 +36,7 @@ public class SpamAssassinResultTest {
     }
 
     @Test
-    public void buildShouldThrowWhenRequiredHitsIsNotGiven() {
+    void buildShouldThrowWhenRequiredHitsIsNotGiven() {
         assertThatThrownBy(() -> SpamAssassinResult.asSpam()
                 .hits("4.0")
                 .build())
@@ -49,7 +44,7 @@ public class SpamAssassinResultTest {
     }
 
     @Test
-    public void buildShouldWork() {
+    void buildShouldWork() {
         String hits = "1.1";
         String requiredHits = "5.0";
 
@@ -58,16 +53,18 @@ public class SpamAssassinResultTest {
             .requiredHits(requiredHits)
             .build();
 
-        softly.assertThat(spamAssassinResult.getHits()).isEqualTo(hits);
-        softly.assertThat(spamAssassinResult.getRequiredHits()).isEqualTo(requiredHits);
-        softly.assertThat(spamAssassinResult.getHeadersAsAttributes())
-            .containsOnly(
-                new Attribute(SpamAssassinResult.FLAG_MAIL, AttributeValue.of("YES")),
-                new Attribute(SpamAssassinResult.STATUS_MAIL, AttributeValue.of("Yes, hits=1.1 required=5.0")));
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(spamAssassinResult.getHits()).isEqualTo(hits);
+            softly.assertThat(spamAssassinResult.getRequiredHits()).isEqualTo(requiredHits);
+            softly.assertThat(spamAssassinResult.getHeadersAsAttributes())
+                .containsOnly(
+                    new Attribute(SpamAssassinResult.FLAG_MAIL, AttributeValue.of("YES")),
+                    new Attribute(SpamAssassinResult.STATUS_MAIL, AttributeValue.of("Yes, hits=1.1 required=5.0")));
+        });
     }
 
     @Test
-    public void headersAsAttributeShouldContainSpamHeaderWithYESValueWhenBuiltAsSpam() {
+    void headersAsAttributeShouldContainSpamHeaderWithYESValueWhenBuiltAsSpam() {
         String hits = "1.1";
         String requiredHits = "5.0";
 
@@ -81,7 +78,7 @@ public class SpamAssassinResultTest {
     }
 
     @Test
-    public void headersAsAttributeShouldContainSpamHeaderWithNOValueWhenBuiltAsHam() {
+    void headersAsAttributeShouldContainSpamHeaderWithNOValueWhenBuiltAsHam() {
         String hits = "1.1";
         String requiredHits = "5.0";
 


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


[james-project] 23/33: JAMES-3491 Advertise webSocket push in session capabilities

Posted by bt...@apache.org.
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 ec9f8d44ab4705237ec35ea3c9e6b708efd9edca
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 11:14:34 2021 +0700

    JAMES-3491 Advertise webSocket push in session capabilities
---
 .../org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala | 4 ++--
 .../apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala    | 4 ++--
 .../src/main/scala/org/apache/james/jmap/core/Capabilities.scala      | 2 +-
 .../test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala   | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
index 48b8b8b..0f7607c 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
@@ -71,7 +71,7 @@ object CustomMethodContract {
       |      "mayCreateTopLevelMailbox" : true
       |    },
       |    "urn:ietf:params:jmap:websocket": {
-      |      "supportsPush": false,
+      |      "supportsPush": true,
       |      "url": "http://domain.com/jmap/ws"
       |    },
       |    "urn:apache:james:params:jmap:mail:quota": {},
@@ -90,7 +90,7 @@ object CustomMethodContract {
       |          "submissionExtensions": []
       |        },
       |        "urn:ietf:params:jmap:websocket": {
-      |            "supportsPush": false,
+      |            "supportsPush": true,
       |            "url": "http://domain.com/jmap/ws"
       |        },
       |        "urn:ietf:params:jmap:core" : {
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala
index 7e1abc8..a7ffe3d 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala
@@ -64,7 +64,7 @@ object SessionRoutesContract {
                          |      "mayCreateTopLevelMailbox" : true
                          |    },
                          |    "urn:ietf:params:jmap:websocket": {
-                         |      "supportsPush": false,
+                         |      "supportsPush": true,
                          |      "url": "http://domain.com/jmap/ws"
                          |    },
                          |    "urn:apache:james:params:jmap:mail:quota": {},
@@ -82,7 +82,7 @@ object SessionRoutesContract {
                          |          "submissionExtensions": []
                          |        },
                          |        "urn:ietf:params:jmap:websocket": {
-                         |            "supportsPush": false,
+                         |            "supportsPush": true,
                          |            "url": "http://domain.com/jmap/ws"
                          |        },
                          |        "urn:ietf:params:jmap:core" : {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Capabilities.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Capabilities.scala
index d3f7be4..654fb85 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Capabilities.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Capabilities.scala
@@ -36,7 +36,7 @@ object DefaultCapabilities {
       collationAlgorithms = List("i;unicode-casemap")))
 
   def webSocketCapability(url: URL) = WebSocketCapability(
-    properties = WebSocketCapabilityProperties(SupportsPush(false), url))
+    properties = WebSocketCapabilityProperties(SupportsPush(true), url))
 
   val MAIL_CAPABILITY = MailCapability(
     properties = MailCapabilityProperties(
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
index b6d5766..aae99de 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
@@ -145,7 +145,7 @@ class SessionRoutesTest extends AnyFlatSpec with BeforeAndAfter with Matchers {
                          |      "mayCreateTopLevelMailbox" : true
                          |    },
                          |    "urn:ietf:params:jmap:websocket": {
-                         |      "supportsPush": false,
+                         |      "supportsPush": true,
                          |      "url": "http://localhost/jmap/ws"
                          |    },
                          |    "urn:apache:james:params:jmap:mail:quota": {},
@@ -163,7 +163,7 @@ class SessionRoutesTest extends AnyFlatSpec with BeforeAndAfter with Matchers {
                          |          "submissionExtensions": []
                          |        },
                          |        "urn:ietf:params:jmap:websocket": {
-                         |            "supportsPush": false,
+                         |            "supportsPush": true,
                          |            "url": "http://localhost/jmap/ws"
                          |        },
                          |        "urn:ietf:params:jmap:core" : {


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


[james-project] 03/33: [REFACTORING] Get rid of JUNIT 4 usages in cassandra-guice tests

Posted by bt...@apache.org.
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 4377ebe3aa7e4a90dcd26923f48f2ed17bc59aab
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 09:54:40 2021 +0700

    [REFACTORING] Get rid of JUNIT 4 usages in cassandra-guice tests
---
 .../mailbox/TikaConfigurationReaderTest.java       | 31 +++++++++++-----------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/TikaConfigurationReaderTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/TikaConfigurationReaderTest.java
index aefa878..26da034 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/TikaConfigurationReaderTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/TikaConfigurationReaderTest.java
@@ -28,14 +28,13 @@ import org.apache.commons.configuration2.PropertiesConfiguration;
 import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
 import org.apache.james.mailbox.model.ContentType.MimeType;
 import org.apache.james.mailbox.tika.TikaConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableSet;
 
-public class TikaConfigurationReaderTest {
-
+class TikaConfigurationReaderTest {
     @Test
-    public void readTikaConfigurationShouldAcceptMandatoryValues() throws Exception {
+    void readTikaConfigurationShouldAcceptMandatoryValues() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
                 "tika.enabled=true\n" +
@@ -57,7 +56,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldReturnDefaultOnMissingHost() throws Exception {
+    void readTikaConfigurationShouldReturnDefaultOnMissingHost() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -75,7 +74,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldReturnDefaultOnMissingPort() throws Exception {
+    void readTikaConfigurationShouldReturnDefaultOnMissingPort() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -93,7 +92,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldReturnDefaultOnMissingTimeout() throws Exception {
+    void readTikaConfigurationShouldReturnDefaultOnMissingTimeout() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -111,7 +110,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void tikaShouldBeDisabledByDefault() throws Exception {
+    void tikaShouldBeDisabledByDefault() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(""));
 
@@ -123,7 +122,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldParseUnitForCacheEvictionPeriod() throws Exception {
+    void readTikaConfigurationShouldParseUnitForCacheEvictionPeriod() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -144,7 +143,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldDefaultToSecondWhenMissingUnitForCacheEvitionPeriod() throws Exception {
+    void readTikaConfigurationShouldDefaultToSecondWhenMissingUnitForCacheEvitionPeriod() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -165,7 +164,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldParseUnitForCacheWeightMax() throws Exception {
+    void readTikaConfigurationShouldParseUnitForCacheWeightMax() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -186,7 +185,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldDefaultToByteAsSizeUnit() throws Exception {
+    void readTikaConfigurationShouldDefaultToByteAsSizeUnit() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -207,7 +206,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldEnableCacheWhenConfigured() throws Exception {
+    void readTikaConfigurationShouldEnableCacheWhenConfigured() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -230,7 +229,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldNotHaveContentTypeBlacklist() throws Exception {
+    void readTikaConfigurationShouldNotHaveContentTypeBlacklist() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -253,7 +252,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldHaveContentTypeBlacklist() throws Exception {
+    void readTikaConfigurationShouldHaveContentTypeBlacklist() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +
@@ -278,7 +277,7 @@ public class TikaConfigurationReaderTest {
     }
 
     @Test
-    public void readTikaConfigurationShouldHaveContentTypeBlacklistWithWhiteSpace() throws Exception {
+    void readTikaConfigurationShouldHaveContentTypeBlacklistWithWhiteSpace() throws Exception {
         PropertiesConfiguration configuration = newConfiguration();
         configuration.read(new StringReader(
             "tika.enabled=true\n" +


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


[james-project] 01/33: [REFACTORING] Get rid of JUNIT 4 usages in CLI integration tests

Posted by bt...@apache.org.
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 16a26eabb9192513a5b1341d820e2119e7b40070
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 09:48:28 2021 +0700

    [REFACTORING] Get rid of JUNIT 4 usages in CLI integration tests
---
 .../james/cli/DataCommandsIntegrationTest.java     | 65 ++++++++++------------
 .../james/cli/MailboxCommandsIntegrationTest.java  | 42 +++++++-------
 .../james/cli/QuotaCommandsIntegrationTest.java    | 54 +++++++++---------
 .../james/cli/ReindexCommandIntegrationTest.java   | 45 +++++++--------
 .../cli/SieveQuotaCommandsIntegrationTest.java     | 64 +++++++++------------
 .../apache/james/cli/util/OutputCaptureTest.java   | 11 ++--
 .../src/test/resources/jmap.properties             | 11 ----
 7 files changed, 125 insertions(+), 167 deletions(-)

diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
index bdd9e80..09de657 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
@@ -24,7 +24,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.cli.util.OutputCapture;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.modules.server.JMXServerModule;
@@ -32,47 +34,40 @@ import org.apache.james.rrt.api.SourceDomainIsNotInDomainListException;
 import org.apache.james.rrt.lib.Mapping;
 import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.utils.DataProbeImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DataCommandsIntegrationTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
+class DataCommandsIntegrationTest {
     public static final String DOMAIN = "domain.com";
     public static final String USER = "chibenwa";
     public static final String MAIL_ADDRESS = USER + "@" + DOMAIN;
     public static final String PASSWORD = "12345";
     private OutputCapture outputCapture;
 
-    @Rule
-    public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
-    private GuiceJamesServer guiceJamesServer;
+    @RegisterExtension
+    JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+        .server(conf -> MemoryJamesServerMain.createServer(conf)
+            .overrideWith(new JMXServerModule(),
+                binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+        .build();
     private DataProbeImpl dataProbe;
 
-    @Before
-    public void setUp() throws Exception {
-        guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
-            binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
-        guiceJamesServer.start();
+    @BeforeEach
+    public void setUp(GuiceJamesServer guiceJamesServer) {
         dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
         outputCapture = new OutputCapture();
     }
 
-    @After
-    public void tearDown() {
-        guiceJamesServer.stop();
-    }
-
     @Test
-    public void addDomainShouldWork() throws Exception {
+    void addDomainShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "ADDDOMAIN", DOMAIN});
 
         assertThat(dataProbe.containsDomain(DOMAIN)).isTrue();
     }
 
     @Test
-    public void removeDomainShouldWork() throws Exception {
+    void removeDomainShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "REMOVEDOMAIN", DOMAIN});
@@ -81,7 +76,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void listDomainsShouldWork() throws Exception {
+    void listDomainsShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "listdomains"}, outputCapture.getPrintStream());
@@ -90,7 +85,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void containsDomainShouldWork() throws Exception {
+    void containsDomainShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "containsdomain", DOMAIN},
@@ -101,7 +96,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void addUserShouldWork() throws Exception {
+    void addUserShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "ADDUSER", MAIL_ADDRESS, PASSWORD});
@@ -110,7 +105,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void removeUserShouldWork() throws Exception {
+    void removeUserShouldWork() throws Exception {
         dataProbe.fluent()
             .addDomain(DOMAIN)
             .addUser(MAIL_ADDRESS, PASSWORD);
@@ -121,7 +116,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void listUsersShouldWork() throws Exception {
+    void listUsersShouldWork() throws Exception {
         dataProbe.fluent()
             .addDomain(DOMAIN)
             .addUser(MAIL_ADDRESS, PASSWORD);
@@ -133,7 +128,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void addAddressMappingShouldWork() throws Exception {
+    void addAddressMappingShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         String redirectionAddress = "redirect@apache.org";
@@ -149,7 +144,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void addAddressMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
+    void addAddressMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
         String redirectionAddress = "redirect@apache.org";
 
         assertThatThrownBy(() -> ServerCmd.executeAndOutputToStream(
@@ -160,7 +155,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void listMappingsShouldWork() throws Exception {
+    void listMappingsShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         String redirectionAddress = "redirect@apache.org";
@@ -174,7 +169,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void listUsersDomainMappingShouldWork() throws Exception {
+    void listUsersDomainMappingShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         String redirectionAddress = "redirect@apache.org";
@@ -188,7 +183,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void removeAddressMappingShouldWork() throws Exception {
+    void removeAddressMappingShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         String redirectionAddress = "redirect@apache.org";
@@ -202,7 +197,7 @@ public class DataCommandsIntegrationTest {
 
 
     @Test
-    public void addRegexMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
+    void addRegexMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
         String regexMapping = ".*@apache.org";
 
         assertThatThrownBy(() -> ServerCmd.executeAndOutputToStream(
@@ -213,7 +208,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void addRegexMappingShouldWork() throws Exception {
+    void addRegexMappingShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         String regex = "regex";
@@ -229,7 +224,7 @@ public class DataCommandsIntegrationTest {
     }
 
     @Test
-    public void removeRegexMappingShouldWork() throws Exception {
+    void removeRegexMappingShouldWork() throws Exception {
         dataProbe.addDomain(DOMAIN);
 
         String regex = "regex";
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java
index 9e131bb..88d2c63 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java
@@ -23,50 +23,46 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.cli.util.OutputCapture;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.modules.MailboxProbeImpl;
 import org.apache.james.modules.server.JMXServerModule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class MailboxCommandsIntegrationTest {
+class MailboxCommandsIntegrationTest {
     public static final String USER = "user";
     public static final String MAILBOX = "mailboxExampleName";
 
-    @Rule
-    public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
-    private GuiceJamesServer guiceJamesServer;
+    @RegisterExtension
+    JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+        .server(conf -> MemoryJamesServerMain.createServer(conf)
+            .overrideWith(new JMXServerModule(),
+                binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+        .build();
     private MailboxProbeImpl mailboxProbe;
     private OutputCapture outputCapture;
 
-    @Before
-    public void setUp() throws Exception {
-        guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
-            binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
-        guiceJamesServer.start();
+    @BeforeEach
+    void setUp(GuiceJamesServer guiceJamesServer) {
         outputCapture = new OutputCapture();
         mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class);
     }
 
-    @After
-    public void tearDown() {
-        guiceJamesServer.stop();
-    }
-
     @Test
-    public void createMailboxShouldWork() throws Exception {
+    void createMailboxShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
 
         assertThat(mailboxProbe.listUserMailboxes(USER)).containsOnly(MAILBOX);
     }
 
     @Test
-    public void deleteUserMailboxesShouldWork() throws Exception {
+    void deleteUserMailboxesShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "deleteusermailboxes", USER});
@@ -75,7 +71,7 @@ public class MailboxCommandsIntegrationTest {
     }
 
     @Test
-    public void listUserMailboxesShouldWork() throws Exception {
+    void listUserMailboxesShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "listusermailboxes", USER},
@@ -86,7 +82,7 @@ public class MailboxCommandsIntegrationTest {
     }
 
     @Test
-    public void deleteMailboxeShouldWork() throws Exception {
+    void deleteMailboxeShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "deletemailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java
index 50d61ff..01d7cf5 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java
@@ -25,7 +25,9 @@ import static org.mockito.Mockito.mock;
 import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.cli.util.OutputCapture;
 import org.apache.james.core.quota.QuotaCountLimit;
 import org.apache.james.core.quota.QuotaSizeLimit;
@@ -33,44 +35,38 @@ import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.modules.QuotaProbesImpl;
 import org.apache.james.modules.server.JMXServerModule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class QuotaCommandsIntegrationTest {
+class QuotaCommandsIntegrationTest {
     public static final String USER = "user";
     public static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("#private&" + USER, Optional.empty());
     private OutputCapture outputCapture;
 
-    @Rule
-    public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
-    private GuiceJamesServer guiceJamesServer;
+    @RegisterExtension
+    JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+        .server(conf -> MemoryJamesServerMain.createServer(conf)
+            .overrideWith(new JMXServerModule(),
+                binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+        .build();
     private QuotaProbesImpl quotaProbe;
 
-    @Before
-    public void setUp() throws Exception {
-        guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
-            binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
-        guiceJamesServer.start();
+    @BeforeEach
+    void setUp(GuiceJamesServer guiceJamesServer) {
         quotaProbe = guiceJamesServer.getProbe(QuotaProbesImpl.class);
         outputCapture = new OutputCapture();
     }
 
-    @After
-    public void tearDown() {
-        guiceJamesServer.stop();
-    }
-
     @Test
-    public void setGlobalMaxStorageShouldWork() throws Exception {
+    void setGlobalMaxStorageShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxstoragequota", "36"});
 
         assertThat(quotaProbe.getGlobalMaxStorage().map(QuotaSizeLimit::asLong)).contains(36L);
     }
 
     @Test
-    public void getGlobalMaxStorageShouldWork() throws Exception {
+    void getGlobalMaxStorageShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxstoragequota", "36M"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getglobalmaxstoragequota"},
@@ -81,14 +77,14 @@ public class QuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void setGlobalMaxMessageCountShouldWork() throws Exception {
+    void setGlobalMaxMessageCountShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxmessagecountquota", "36"});
 
         assertThat(quotaProbe.getGlobalMaxMessageCount().map(QuotaCountLimit::asLong)).contains(36L);
     }
 
     @Test
-    public void getGlobalMaxMessageCountShouldWork() throws Exception {
+    void getGlobalMaxMessageCountShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxmessagecountquota", "36"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getglobalmaxmessagecountquota"},
@@ -99,14 +95,14 @@ public class QuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void setMaxStorageShouldWork() throws Exception {
+    void setMaxStorageShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "36"});
 
         assertThat(quotaProbe.getMaxStorage(QUOTA_ROOT).map(QuotaSizeLimit::asLong)).contains(36L);
     }
 
     @Test
-    public void getMaxStorageShouldWork() throws Exception {
+    void getMaxStorageShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "1g"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getmaxstoragequota", QUOTA_ROOT.getValue()},
@@ -117,14 +113,14 @@ public class QuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void setMaxMessageCountShouldWork() throws Exception {
+    void setMaxMessageCountShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"});
 
         assertThat(quotaProbe.getMaxMessageCount(QUOTA_ROOT).map(QuotaCountLimit::asLong)).contains(36L);
     }
 
     @Test
-    public void getMaxMessageCountShouldWork() throws Exception {
+    void getMaxMessageCountShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getmaxmessagecountquota", QUOTA_ROOT.getValue()},
@@ -135,7 +131,7 @@ public class QuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void getStorageQuotaShouldWork() throws Exception {
+    void getStorageQuotaShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "36"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getstoragequota", QUOTA_ROOT.getValue()},
@@ -146,7 +142,7 @@ public class QuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void getMessageCountQuotaShouldWork() throws Exception {
+    void getMessageCountQuotaShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getmessagecountquota", QUOTA_ROOT.getValue()},
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
index cdc2ca3..0b976ec 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
@@ -24,8 +24,9 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.core.Username;
 import org.apache.james.mailbox.indexer.ReIndexer;
 import org.apache.james.mailbox.indexer.ReIndexer.RunningOptions;
@@ -35,47 +36,39 @@ import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.task.MemoryReferenceTask;
 import org.apache.james.task.Task;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.inject.name.Names;
 
-public class ReindexCommandIntegrationTest {
+class ReindexCommandIntegrationTest {
     private static final String USER = "user";
-    private ReIndexer reIndexer;
+    private ReIndexer reIndexer = mock(ReIndexer.class);
 
-    @Rule
-    public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
-    private GuiceJamesServer guiceJamesServer;
+    @RegisterExtension
+    JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+        .server(conf -> MemoryJamesServerMain.createServer(conf)
+            .overrideWith(new JMXServerModule()).overrideWith(
+                binder -> binder.bind(ReIndexer.class).annotatedWith(Names.named("reindexer")).toInstance(reIndexer),
+                binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+        .build();
 
-    @Before
-    public void setUp() throws Exception {
-        reIndexer = mock(ReIndexer.class);
+    @BeforeEach
+    void setUp() throws Exception {
         when(reIndexer.reIndex(any(RunningOptions.class))).thenReturn(new MemoryReferenceTask(() -> Task.Result.COMPLETED));
         when(reIndexer.reIndex(any(MailboxPath.class), any(RunningOptions.class))).thenReturn(new MemoryReferenceTask(() -> Task.Result.COMPLETED));
-        guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
-            binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)))
-            .overrideWith(binder -> binder.bind(ReIndexer.class)
-                .annotatedWith(Names.named("reindexer")).toInstance(reIndexer));
-        guiceJamesServer.start();
-    }
-
-    @After
-    public void tearDown() {
-        guiceJamesServer.stop();
     }
 
     @Test
-    public void reindexAllShouldWork() throws Exception {
+    void reindexAllShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "reindexall"});
 
         verify(reIndexer).reIndex(ReIndexer.RunningOptions.DEFAULT);
     }
 
     @Test
-    public void reindexMailboxShouldWork() throws Exception {
+    void reindexMailboxShouldWork() throws Exception {
         String mailbox = "mailbox";
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "reindexmailbox", MailboxConstants.USER_NAMESPACE, USER, mailbox});
 
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java
index ac7d5b4..0bf0a10 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java
@@ -20,58 +20,49 @@
 package org.apache.james.cli;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.cli.util.OutputCapture;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.modules.protocols.SieveProbeImpl;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-
-public class SieveQuotaCommandsIntegrationTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class SieveQuotaCommandsIntegrationTest {
     public static final String USER = "user";
 
-    @Rule
-    public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-    @Rule
-    public TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private GuiceJamesServer guiceJamesServer;
+    @RegisterExtension
+    JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+        .server(conf -> MemoryJamesServerMain.createServer(conf)
+            .overrideWith(new JMXServerModule(),
+                binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+        .build();
     private SieveProbeImpl sieveProbe;
     private OutputCapture outputCapture;
 
-    @Before
-    public void setUp() throws Exception {
-        guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
-            binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
-        guiceJamesServer.start();
+    @BeforeEach
+    void setUp(GuiceJamesServer guiceJamesServer) {
         outputCapture = new OutputCapture();
         sieveProbe = guiceJamesServer.getProbe(SieveProbeImpl.class);
     }
 
-    @After
-    public void tearDown() {
-        guiceJamesServer.stop();
-    }
-
     @Test
-    public void setSieveUserQuotaShouldWork() throws Exception {
+    void setSieveUserQuotaShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsieveuserquota", USER, "36"});
 
         assertThat(sieveProbe.getSieveQuota(USER)).isEqualTo(36);
     }
 
     @Test
-    public void getSieveUserQuotaShouldWork() throws Exception {
+    void getSieveUserQuotaShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsieveuserquota", USER, "36"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getsieveuserquota", USER},
@@ -82,14 +73,14 @@ public class SieveQuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void setSieveQuotaShouldWork() throws Exception {
+    void setSieveQuotaShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsievequota", "36"});
 
         assertThat(sieveProbe.getSieveQuota()).isEqualTo(36);
     }
 
     @Test
-    public void getSieveQuotaShouldWork() throws Exception {
+    void getSieveQuotaShouldWork() throws Exception {
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsievequota", "36"});
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getsievequota"},
@@ -100,23 +91,22 @@ public class SieveQuotaCommandsIntegrationTest {
     }
 
     @Test
-    public void removeSieveUserQuotaShouldWork() throws Exception {
+    void removeSieveUserQuotaShouldWork() throws Exception {
         sieveProbe.setSieveQuota(USER, 36);
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removesieveuserquota", USER});
 
-        expectedException.expect(QuotaNotFoundException.class);
-        sieveProbe.getSieveQuota(USER);
+        assertThatThrownBy(() -> sieveProbe.getSieveQuota(USER))
+            .isInstanceOf(QuotaNotFoundException.class);
     }
 
     @Test
-    public void removeSieveQuotaShouldWork() throws Exception {
+    void removeSieveQuotaShouldWork() throws Exception {
         sieveProbe.setSieveQuota(36);
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removesievequota"});
 
-        expectedException.expect(QuotaNotFoundException.class);
-        sieveProbe.getSieveQuota();
+        assertThatThrownBy(() -> sieveProbe.getSieveQuota())
+            .isInstanceOf(QuotaNotFoundException.class);
     }
-
 }
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java
index 24ca692..4e7232d 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java
@@ -23,17 +23,17 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.nio.charset.StandardCharsets;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class OutputCaptureTest {
+class OutputCaptureTest {
 
     @Test
-    public void contentShouldBeEmptyByDefault() {
+    void contentShouldBeEmptyByDefault() {
         assertThat(new OutputCapture().getContent()).isEmpty();
     }
 
     @Test
-    public void contentShouldReturnOutputStreamInput() throws Exception {
+    void contentShouldReturnOutputStreamInput() throws Exception {
         OutputCapture outputCapture = new OutputCapture();
 
         String message = "Hello world!\n";
@@ -42,9 +42,8 @@ public class OutputCaptureTest {
         assertThat(outputCapture.getContent()).isEqualTo(message);
     }
 
-
     @Test
-    public void mixingReadsAndWritesShouldWork() throws Exception {
+    void mixingReadsAndWritesShouldWork() throws Exception {
         OutputCapture outputCapture = new OutputCapture();
         String message = "Hello world!\n";
         outputCapture.getPrintStream().write(message.getBytes(StandardCharsets.UTF_8));
diff --git a/server/container/cli-integration/src/test/resources/jmap.properties b/server/container/cli-integration/src/test/resources/jmap.properties
deleted file mode 100644
index 34ab451..0000000
--- a/server/container/cli-integration/src/test/resources/jmap.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# Configuration file for JMAP
-
-tls.keystoreURL=file://conf/keystore
-tls.secret=james72laBalle
-
-#
-# If you wish to use OAuth authentication, you should provide a valid JWT public key.
-# The following entry specify the link to the URL of the public key file,
-# which should be a PEM format file.
-#
-jwt.publickeypem.url=file://conf/jwt_publickey


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


[james-project] 28/33: JAMES-3491 Add EmailDelivery push notification support

Posted by bt...@apache.org.
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 4c1ac1b344238cf36beda63e4bfd8043a35e0291
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 14:25:04 2021 +0700

    JAMES-3491 Add EmailDelivery push notification support
---
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 128 ++++++++++++++++++++-
 .../james/jmap/change/JmapEventSerializer.scala    |   9 +-
 .../james/jmap/change/MailboxChangeListener.scala  |   3 +
 .../org/apache/james/jmap/change/StateChange.scala |   4 +-
 .../change/StateChangeEventSerializerTest.scala    |  33 +++++-
 5 files changed, 168 insertions(+), 9 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index e477607..c8897ba 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -577,7 +577,7 @@ trait WebSocketContract {
     val mailboxState: String = jmapGuiceProbe.getLatestMailboxState(accountId).getValue.toString
 
     val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
-    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"EmailDelivery":"$emailState","Email":"$emailState"}}}"""
 
     assertThat(response.toOption.get.asJava)
       .hasSize(3) // email notification + mailbox notification + API response
@@ -586,6 +586,130 @@ trait WebSocketContract {
 
   @Test
   @Timeout(180)
+  // For client compatibility purposes
+  def emailDeliveryShouldNotIncludeFlagUpdatesAndDeletes(server: GuiceJamesServer): Unit = {
+    val bobPath = MailboxPath.inbox(BOB)
+    val accountId: AccountId = AccountId.fromUsername(BOB)
+    val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+
+    Thread.sleep(100)
+
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "@type": "Request",
+                 |  "requestId": "req-36",
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "create": {
+                 |        "aaaaaa":{
+                 |          "mailboxIds": {
+                 |             "${mailboxId.serialize}": true
+                 |          }
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            val responseAsJson = Json.parse(ws.receive()
+              .map { case t: Text =>
+                t.payload
+              })
+              .\("methodResponses")
+              .\(0).\(1)
+              .\("created")
+              .\("aaaaaa")
+
+            val messageId = responseAsJson
+              .\("id")
+              .get.asInstanceOf[JsString].value
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["Mailbox", "Email", "VacationResponse", "Thread", "Identity", "EmailSubmission", "EmailDelivery"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "@type": "Request",
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "update": {
+                 |        "$messageId":{
+                 |          "keywords": {
+                 |             "music": true
+                 |          }
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            val stateChange1 = ws.receive()
+              .map { case t: Text =>
+                t.payload
+              }
+            val response1 =
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                }
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "@type": "Request",
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "destroy": ["$messageId"]
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            val stateChange2 = ws.receive()
+              .map { case t: Text =>
+                t.payload
+              }
+            val stateChange3 =
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                }
+            val response2 =
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                }
+
+            List(response1, response2, stateChange1, stateChange2, stateChange3)
+        })
+        .send(backend)
+        .body
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(5) // update flags response + email state change notif + destroy response + email state change notif + mailbox state change notif (count)
+    assertThat(response.toOption.get.filter(s => s.startsWith("{\"@type\":\"StateChange\"")).asJava)
+      .hasSize(3)
+      .noneMatch(s => s.contains("EmailDelivery"))
+  }
+
+  @Test
+  @Timeout(180)
   def dataTypesShouldDefaultToAll(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
     val accountId: AccountId = AccountId.fromUsername(BOB)
@@ -647,7 +771,7 @@ trait WebSocketContract {
     val mailboxState: String = jmapGuiceProbe.getLatestMailboxState(accountId).getValue.toString
 
     val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
-    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"EmailDelivery":"$emailState","Email":"$emailState"}}}"""
 
     assertThat(response.toOption.get.asJava)
       .hasSize(3) // email notification + mailbox notification + API response
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
index ea5461e..7c38b41 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
@@ -43,19 +43,22 @@ object StateChangeEventDTO {
     getEventId = event.eventId.getId.toString,
     getUsername = event.username.asString(),
     getMailboxState = event.mailboxState.map(_.value).map(_.toString).toJava,
-    getEmailState = event.emailState.map(_.value).map(_.toString).toJava)
+    getEmailState = event.emailState.map(_.value).map(_.toString).toJava,
+    getEmailDeliveryState = event.emailDeliveryState.map(_.value).map(_.toString).toJava)
 }
 
 case class StateChangeEventDTO(@JsonProperty("type") getType: String,
                                @JsonProperty("eventId") getEventId: String,
                                @JsonProperty("username") getUsername: String,
                                @JsonProperty("mailboxState") getMailboxState: Optional[String],
-                               @JsonProperty("emailState") getEmailState: Optional[String]) extends EventDTO {
+                               @JsonProperty("emailState") getEmailState: Optional[String],
+                               @JsonProperty("emailDeliveryState") getEmailDeliveryState: Optional[String]) extends EventDTO {
   def toDomainObject: StateChangeEvent = StateChangeEvent(
     eventId = EventId.of(getEventId),
     username = Username.of(getUsername),
     mailboxState = getMailboxState.toScala.map(State.fromStringUnchecked),
-    emailState = getEmailState.toScala.map(State.fromStringUnchecked))
+    emailState = getEmailState.toScala.map(State.fromStringUnchecked),
+    emailDeliveryState = getEmailDeliveryState.toScala.map(State.fromStringUnchecked))
 }
 
 case class JmapEventSerializer() extends EventSerializer {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
index 6e57c4f..ad68fb2 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
@@ -127,11 +127,14 @@ case class MailboxChangeListener @Inject() (@Named(InjectionKeys.JMAP) eventBus:
       eventId = EventId.random(),
       username = Username.of(emailChange.getAccountId.getIdentifier),
       emailState = Some(State.fromJava(emailChange.getState)),
+      emailDeliveryState = Some(State.fromJava(emailChange.getState))
+        .filter(_ => !emailChange.getCreated.isEmpty),
       mailboxState = None)
     case mailboxChange: MailboxChange => StateChangeEvent(
       eventId = EventId.random(),
       username = Username.of(mailboxChange.getAccountId.getIdentifier),
       emailState = None,
+      emailDeliveryState = None,
       mailboxState = Some(State.fromJava(mailboxChange.getState)))
   }
 }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index faffe49..c53792a 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -69,13 +69,15 @@ case class TypeState(changes: Map[TypeName, State]) {
 case class StateChangeEvent(eventId: EventId,
                             username: Username,
                             mailboxState: Option[State],
-                            emailState: Option[State]) extends Event {
+                            emailState: Option[State],
+                            emailDeliveryState: Option[State]) extends Event {
   def asStateChange: StateChange =
     StateChange(Map(AccountId.from(username).fold(
       failure => throw new IllegalArgumentException(failure),
       success => success) ->
       TypeState(
         MailboxTypeName.asMap(mailboxState) ++
+          EmailDeliveryTypeName.asMap(emailDeliveryState) ++
           EmailTypeName.asMap(emailState))))
 
   override val getUsername: Username = username
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
index cab2643..7f51aa8 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
@@ -21,24 +21,42 @@ package org.apache.james.jmap.change
 import org.apache.james.JsonSerializationVerifier
 import org.apache.james.core.Username
 import org.apache.james.events.Event.EventId
-import org.apache.james.jmap.change.StateChangeEventSerializerTest.{EVENT, EVENT_JSON}
+import org.apache.james.jmap.change.StateChangeEventSerializerTest.{EVENT, EVENT_JSON, EVENT_JSON_NO_DELIVERY, EVENT_NO_DELIVERY}
 import org.apache.james.jmap.core.State
 import org.apache.james.json.JsonGenericSerializer
 import org.apache.james.json.JsonGenericSerializer.UnknownTypeException
-import org.assertj.core.api.Assertions.assertThatThrownBy
+import org.assertj.core.api.Assertions.{assertThat, assertThatThrownBy}
 import org.junit.jupiter.api.Test
 
 
 object StateChangeEventSerializerTest {
   val EVENT_ID: EventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4")
   val USERNAME: Username = Username.of("bob")
-  val EVENT: StateChangeEvent = StateChangeEvent(EVENT_ID, USERNAME, Some(State.INSTANCE), Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
+  val EVENT: StateChangeEvent = StateChangeEvent(eventId = EVENT_ID,
+    username = USERNAME,
+    mailboxState = Some(State.INSTANCE),
+    emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")),
+    emailDeliveryState = Some(State.fromStringUnchecked("2d9f1b12-0000-1111-3333-0106fb53a943")))
   val EVENT_JSON: String =
     """{
       |  "eventId":"6e0dd59d-660e-4d9b-b22f-0354479f47b4",
       |  "username":"bob",
       |  "mailboxState":"2c9f1b12-b35a-43e6-9af2-0106fb53a943",
       |  "emailState":"2d9f1b12-b35a-43e6-9af2-0106fb53a943",
+      |  "emailDeliveryState":"2d9f1b12-0000-1111-3333-0106fb53a943",
+      |  "type":"org.apache.james.jmap.change.StateChangeEvent"
+      |}""".stripMargin
+  val EVENT_NO_DELIVERY: StateChangeEvent = StateChangeEvent(eventId = EVENT_ID,
+    username = USERNAME,
+    mailboxState = Some(State.INSTANCE),
+    emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")),
+    emailDeliveryState = None)
+  val EVENT_JSON_NO_DELIVERY: String =
+    """{
+      |  "eventId":"6e0dd59d-660e-4d9b-b22f-0354479f47b4",
+      |  "username":"bob",
+      |  "mailboxState":"2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+      |  "emailState":"2d9f1b12-b35a-43e6-9af2-0106fb53a943",
       |  "type":"org.apache.james.jmap.change.StateChangeEvent"
       |}""".stripMargin
 }
@@ -67,4 +85,13 @@ class StateChangeEventSerializerTest {
                        |  "type":"org.apache.james.jmap.change.Unknown"
                        |}""".stripMargin))
       .isInstanceOf(classOf[UnknownTypeException])
+
+  @Test
+  def shouldDeserializeWhenAnOptionalFieldIsMissing(): Unit =
+    assertThat(
+      JsonGenericSerializer
+        .forModules(StateChangeEventDTO.dtoModule)
+        .withoutNestedType()
+        .deserialize(EVENT_JSON_NO_DELIVERY.stripMargin))
+      .isEqualTo(EVENT_NO_DELIVERY)
 }
\ No newline at end of file


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


[james-project] 04/33: [REFACTORING] Get rid of some JUNIT 4 usages in cassandra-common tests

Posted by bt...@apache.org.
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 f33705408353fc1703c22a74b1ff162798579d9f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 10:00:28 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in cassandra-common tests
---
 .../modules/InitializationOperationsTest.java      |  7 ++--
 .../org/apache/james/utils/ConfigurablesTest.java  | 12 +++----
 .../apache/james/utils/GuiceProbeProviderTest.java | 37 ++++++++++------------
 3 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/InitializationOperationsTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/InitializationOperationsTest.java
index 44a8a3f..90f38dd 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/InitializationOperationsTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/InitializationOperationsTest.java
@@ -30,17 +30,16 @@ import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.lifecycle.api.Startable;
 import org.apache.james.utils.InitializationOperation;
 import org.apache.james.utils.InitializationOperations;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Scopes;
 import com.google.inject.multibindings.Multibinder;
 
-public class InitializationOperationsTest {
-
+class InitializationOperationsTest {
     @Test
-    public void initModulesShouldNotFailWhenBindingsInWrongOrder() throws Exception {
+    void initModulesShouldNotFailWhenBindingsInWrongOrder() throws Exception {
         Injector injector = Guice.createInjector(new StartablesModule(),
                 new UnorderedBindingsModule());
 
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java
index 01f193f..0c5421e 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java
@@ -25,20 +25,20 @@ import org.apache.commons.configuration2.HierarchicalConfiguration;
 import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.tree.ImmutableNode;
 import org.apache.james.lifecycle.api.Configurable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class ConfigurablesTest {
 
     private Startables sut;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         sut = new Startables();
     }
 
     @Test
-    public void addShouldNotStoreTwoTimesWhenSameConfigurable() {
+    void addShouldNotStoreTwoTimesWhenSameConfigurable() {
         sut.add(MyConfigurable.class);
         sut.add(MyConfigurable.class);
 
@@ -46,7 +46,7 @@ public class ConfigurablesTest {
     }
 
     @Test
-    public void configurablesShouldKeepTheAddedElementsOrder() {
+    void configurablesShouldKeepTheAddedElementsOrder() {
         sut.add(MyConfigurable.class);
         sut.add(MyConfigurable2.class);
 
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/GuiceProbeProviderTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/GuiceProbeProviderTest.java
index 294a525..dd85176 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/GuiceProbeProviderTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/GuiceProbeProviderTest.java
@@ -17,52 +17,47 @@
  * under the License.                                           *
  ****************************************************************/
 package org.apache.james.utils;
-import static  org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableSet;
 
 public class GuiceProbeProviderTest {
-
     private GuiceProbeProvider guiceProbeProvider;
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
     private GuiceProbe1 guiceProbe1;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         guiceProbe1 = new GuiceProbe1();
         guiceProbeProvider = new GuiceProbeProvider(ImmutableSet.of(guiceProbe1));
     }
 
     @Test
-    public void getProveShouldThrowExcpetionWhenNull() {
-        expectedException.expect(NullPointerException.class);
-
-        guiceProbeProvider.getProbe(null);
+    void getProveShouldThrowExcpetionWhenNull() {
+        assertThatThrownBy(() -> guiceProbeProvider.getProbe(null))
+            .isInstanceOf(NullPointerException.class);
     }
     
     @Test
-    public void getProbeShouldThrowRuntimeExceptionWhenEmpty() {
-        expectedException.expect(RuntimeException.class);
-
-        guiceProbeProvider.getProbe(GuiceProbe2.class);
+    void getProbeShouldThrowRuntimeExceptionWhenEmpty() {
+        assertThatThrownBy(() -> guiceProbeProvider.getProbe(GuiceProbe2.class))
+            .isInstanceOf(RuntimeException.class);
     }
 
     @Test
-    public void getProbeShouldReturnRightProbe() {
+    void getProbeShouldReturnRightProbe() {
         assertThat(guiceProbeProvider.getProbe(GuiceProbe1.class)).isEqualTo(guiceProbe1);
     }
 
-    class GuiceProbe1 implements GuiceProbe {
+    static class GuiceProbe1 implements GuiceProbe {
 
     }
 
-    class GuiceProbe2 implements GuiceProbe {
+    static class GuiceProbe2 implements GuiceProbe {
 
     }
 }
\ No newline at end of file


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


[james-project] 15/33: JAMES-3491 StateChangeListener should filter out unwanted events

Posted by bt...@apache.org.
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 f5954dbd53dca8f29f7c6b326269774e8a4be67e
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Wed Feb 3 11:40:26 2021 +0700

    JAMES-3491 StateChangeListener should filter out unwanted events
    
    https://tools.ietf.org/html/rfc8887
    
    ```
    4.3.5.2.  Enabling Notifications
    
      [...]
    
       *  dataTypes: "String[]|null"
    
          A list of data type names (e.g., "Mailbox" or "Email") that the
          client is interested in.  A StateChange notification will only be
          sent if the data for one of these types changes.  Other types are
          omitted from the TypeState object.  If null, changes will be
          pushed for all supported data types.
    ```
    
    We implemented this by in-memory filtering upon notification generation
---
 .../org/apache/james/jmap/change/StateChange.scala |  9 ++++-
 .../james/jmap/change/StateChangeListener.scala    | 11 +++---
 .../james/jmap/core/WebSocketTransport.scala       | 12 +++++-
 .../jmap/change/StateChangeListenerTest.scala      | 46 +++++++++++++++++++++-
 4 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index 7aa9bf1..1b400be 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -38,7 +38,14 @@ case object EmailTypeName extends TypeName {
   override def asString(): String = "Email"
 }
 
-case class TypeState(changes: Map[TypeName, State])
+case class TypeState(changes: Map[TypeName, State]) {
+
+  def filter(types: Set[TypeName]): Option[TypeState] = Option(changes.filter {
+    case (typeName, _) => types.contains(typeName)
+  })
+    .filter(_.nonEmpty)
+    .map(TypeState)
+}
 
 case class StateChangeEvent(eventId: EventId,
                             username: Username,
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
index c653a8a..57fd4f2 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
@@ -30,13 +30,14 @@ import reactor.core.scala.publisher.SMono
 import reactor.core.scheduler.Schedulers
 import reactor.netty.http.websocket.WebsocketOutbound
 
-case class StateChangeListener(outbound: WebsocketOutbound) extends ReactiveEventListener {
+case class StateChangeListener(types: Set[TypeName], outbound: WebsocketOutbound) extends ReactiveEventListener {
   override def reactiveEvent(event: Event): Publisher[Void] = event match {
     case stateChangeEvent: StateChangeEvent =>
-      val stateChange = stateChangeEvent.asStateChange
-      val jsonString = Json.stringify(ResponseSerializer.serialize(stateChange))
-      SMono(outbound.sendString(SMono.just[String](jsonString), StandardCharsets.UTF_8))
-        .subscribeOn(Schedulers.elastic)
+      val stateChange = stateChangeEvent.asStateChange.filter(types)
+      val jsonString = stateChange.map(ResponseSerializer.serialize).map(Json.stringify)
+      jsonString.map(json => SMono(outbound.sendString(SMono.just[String](json), StandardCharsets.UTF_8))
+        .subscribeOn(Schedulers.elastic))
+        .getOrElse(SMono.empty)
     case _ => SMono.empty
   }
 
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
index b86cd07..3d1fd01 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
@@ -19,7 +19,7 @@
 
 package org.apache.james.jmap.core
 
-import org.apache.james.jmap.change.TypeState
+import org.apache.james.jmap.change.{TypeName, TypeState}
 
 sealed trait WebSocketInboundMessage
 
@@ -33,4 +33,12 @@ case class WebSocketResponse(requestId: Option[RequestId], responseObject: Respo
 
 case class WebSocketError(requestId: Option[RequestId], problemDetails: ProblemDetails) extends WebSocketOutboundMessage
 
-case class StateChange(changes: Map[AccountId, TypeState]) extends WebSocketOutboundMessage
\ No newline at end of file
+case class StateChange(changes: Map[AccountId, TypeState]) extends WebSocketOutboundMessage {
+
+  def filter(types: Set[TypeName]): Option[StateChange] =
+    Option(changes.flatMap {
+      case (accountId, typeState) => typeState.filter(types).map(typeState => (accountId, typeState))
+    })
+    .filter(_.nonEmpty)
+    .map(StateChange)
+}
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
index ecd83a0..d208ca2 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
@@ -28,7 +28,7 @@ import org.apache.james.jmap.core.State
 import org.junit.jupiter.api.Test
 import org.mockito.ArgumentCaptor
 import org.mockito.ArgumentMatchers.any
-import org.mockito.Mockito.{mock, verify, when}
+import org.mockito.Mockito.{mock, verify, verifyZeroInteractions, when}
 import org.reactivestreams.Publisher
 import reactor.core.scala.publisher.SMono
 import reactor.netty.NettyOutbound
@@ -43,7 +43,7 @@ class StateChangeListenerTest {
       username = Username.of("bob"),
       mailboxState = Some(State.fromStringUnchecked("2f9f1b12-b35a-43e6-9af2-0106fb53a943")),
       emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
-    val listener = StateChangeListener(outbound)
+    val listener = StateChangeListener(Set(MailboxTypeName, EmailTypeName), outbound)
     val nettyOutbound = mock(classOf[NettyOutbound])
     when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
 
@@ -64,4 +64,46 @@ class StateChangeListenerTest {
         |}
         |""".stripMargin)
   }
+
+  @Test
+  def reactiveEventShouldOmitUnwantedTypes(): Unit = {
+    val event = StateChangeEvent(eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4"),
+      username = Username.of("bob"),
+      mailboxState = Some(State.fromStringUnchecked("2f9f1b12-b35a-43e6-9af2-0106fb53a943")),
+      emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
+    val listener = StateChangeListener(Set(MailboxTypeName), outbound)
+    val nettyOutbound = mock(classOf[NettyOutbound])
+    when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
+
+    listener.reactiveEvent(event)
+
+    val captor: ArgumentCaptor[Publisher[String]] = ArgumentCaptor.forClass(classOf[Publisher[String]])
+    verify(outbound).sendString(captor.capture(), any(classOf[Charset]))
+    assertThatJson(SMono(captor.getValue).block()).isEqualTo(
+      """
+        |{
+        |  "@type":"StateChange",
+        |  "changed":{
+        |    "81b637d8fcd2c6da6359e6963113a1170de795e4b725b84d1e0b4cfd9ec58ce9":{
+        |      "Mailbox":"2f9f1b12-b35a-43e6-9af2-0106fb53a943"
+        |    }
+        |  }
+        |}
+        |""".stripMargin)
+  }
+
+  @Test
+  def reactiveEventShouldFilterOutUnwantedEvents(): Unit = {
+    val event = StateChangeEvent(eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4"),
+      username = Username.of("bob"),
+      mailboxState = None,
+      emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
+    val listener = StateChangeListener(Set(MailboxTypeName), outbound)
+    val nettyOutbound = mock(classOf[NettyOutbound])
+    when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
+
+    listener.reactiveEvent(event)
+
+    verifyZeroInteractions(outbound)
+  }
 }


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


[james-project] 16/33: JAMES-3491 AccountId RegistrationKey

Posted by bt...@apache.org.
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 4def5f5ce41e4e9589a4e4e1b118923defaa7410
Author: Lan Khuat <kh...@gmail.com>
AuthorDate: Wed Feb 3 21:41:09 2021 +0700

    JAMES-3491 AccountId RegistrationKey
---
 .../jmap/change/AccountIdRegistrationKey.scala     | 33 ++++++++++++++
 .../jmap/change/AccountIdRegistrationKeyTest.scala | 52 ++++++++++++++++++++++
 2 files changed, 85 insertions(+)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala
new file mode 100644
index 0000000..b2b969b
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala
@@ -0,0 +1,33 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *  http://www.apache.org/licenses/LICENSE-2.0                  *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap.change
+
+import org.apache.james.events.RegistrationKey
+import org.apache.james.jmap.api.model.AccountId
+
+case class Factory() extends RegistrationKey.Factory {
+  override val forClass: Class[_ <: RegistrationKey] = classOf[AccountIdRegistrationKey]
+
+  override def fromString(asString: String): RegistrationKey = AccountIdRegistrationKey(AccountId.fromString(asString))
+}
+
+case class AccountIdRegistrationKey(accountId: AccountId) extends RegistrationKey {
+  override def asString(): String = accountId.getIdentifier
+}
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/AccountIdRegistrationKeyTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/AccountIdRegistrationKeyTest.scala
new file mode 100644
index 0000000..adfb816
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/AccountIdRegistrationKeyTest.scala
@@ -0,0 +1,52 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *  http://www.apache.org/licenses/LICENSE-2.0                  *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap.change
+
+import org.apache.james.jmap.api.model.AccountId
+import org.assertj.core.api.Assertions.{assertThat, assertThatThrownBy}
+import org.junit.jupiter.api.Test
+
+class AccountIdRegistrationKeyTest {
+  private val ID: String = "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+
+  private val FACTORY: Factory = Factory()
+
+  private val ACCOUNT_ID_REGISTRATION_KEY: AccountIdRegistrationKey = AccountIdRegistrationKey(AccountId.fromString(ID))
+
+  @Test
+  def asStringShouldReturnSerializedAccountId(): Unit = {
+    assertThat(ACCOUNT_ID_REGISTRATION_KEY.asString()).isEqualTo(ID)
+  }
+
+  @Test
+  def fromStringShouldReturnCorrespondingRegistrationKey(): Unit = {
+    assertThat(FACTORY.fromString(ID)).isEqualTo(ACCOUNT_ID_REGISTRATION_KEY)
+  }
+
+  @Test
+  def fromStringShouldThrowOnNullValues(): Unit = {
+    assertThatThrownBy(() => FACTORY.fromString(null)).isInstanceOf(classOf[IllegalArgumentException])
+  }
+
+  @Test
+  def fromStringShouldThrowOnEmptyValues(): Unit = {
+    assertThatThrownBy(() => FACTORY.fromString("")).isInstanceOf(classOf[IllegalArgumentException])
+  }
+}


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


[james-project] 10/33: [REFACTORING] Get rid of some JUNIT 4 usages in mailetcontainer-camel tests

Posted by bt...@apache.org.
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 ecee174e344836c92505de58ee90e25a730a244c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 12:27:02 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in mailetcontainer-camel tests
---
 .../AutomaticallySentMailDetectorImplTest.java     |  57 ++++++------
 .../impl/JamesMailetContextTest.java               | 102 ++++++++++-----------
 .../mailetcontainer/impl/MailetConfigImplTest.java |  20 ++--
 .../mailetcontainer/impl/matchers/AndTest.java     |  21 ++---
 .../mailetcontainer/impl/matchers/NotTest.java     |  21 ++---
 .../mailetcontainer/impl/matchers/OrTest.java      |  21 ++---
 .../mailetcontainer/impl/matchers/XorTest.java     |  24 +++--
 .../lib/AbstractStateCompositeProcessorTest.java   |   8 +-
 .../lib/AbstractStateMailetProcessorTest.java      |   2 +-
 9 files changed, 130 insertions(+), 146 deletions(-)

diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java
index 52d0071..8996565 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java
@@ -36,14 +36,13 @@ import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.base.Joiner;
 
-public class AutomaticallySentMailDetectorImplTest {
-
+class AutomaticallySentMailDetectorImplTest {
     @Test
-    public void nullSenderMailsShouldBeConsideredAsAutomaticMails() throws Exception {
+    void nullSenderMailsShouldBeConsideredAsAutomaticMails() throws Exception {
         assertThat(
             new AutomaticallySentMailDetectorImpl()
                 .isAutomaticallySent(FakeMail.builder()
@@ -53,7 +52,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void nonNullSenderMailsShouldNotBeConsideredAsAutomaticMails() throws Exception {
+    void nonNullSenderMailsShouldNotBeConsideredAsAutomaticMails() throws Exception {
         assertThat(
             new AutomaticallySentMailDetectorImpl()
                 .isAutomaticallySent(FakeMail.builder()
@@ -66,7 +65,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void ownerIsAMailingListPrefix() throws Exception {
+    void ownerIsAMailingListPrefix() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("owner-list@any.com")
@@ -76,7 +75,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void requestIsAMailingListPrefix() throws Exception {
+    void requestIsAMailingListPrefix() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("list-request@any.com")
@@ -86,7 +85,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void mailerDaemonIsReserved() throws Exception {
+    void mailerDaemonIsReserved() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("MAILER-DAEMON@any.com")
@@ -96,7 +95,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listservIsReserved() throws Exception {
+    void listservIsReserved() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("LISTSERV@any.com")
@@ -106,7 +105,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void majordomoIsReserved() throws Exception {
+    void majordomoIsReserved() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("majordomo@any.com")
@@ -116,7 +115,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listIdShouldBeDetected() throws Exception {
+    void listIdShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .name("mail")
             .sender("any@any.com")
@@ -128,7 +127,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listHelpShouldBeDetected() throws Exception {
+    void listHelpShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .name("mail")
             .sender("any@any.com")
@@ -140,7 +139,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listSubscribeShouldBeDetected() throws Exception {
+    void listSubscribeShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .name("mail")
             .sender("any@any.com")
@@ -152,7 +151,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listUnsubscribeShouldBeDetected() throws Exception {
+    void listUnsubscribeShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("any@any.com")
@@ -164,7 +163,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listPostShouldBeDetected() throws Exception {
+    void listPostShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .name("mail")
             .sender("any@any.com")
@@ -176,7 +175,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listOwnerShouldBeDetected() throws Exception {
+    void listOwnerShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .name("mail")
             .sender("any@any.com")
@@ -189,7 +188,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void listArchiveShouldBeDetected() throws Exception {
+    void listArchiveShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .name("mail")
             .sender("any@any.com")
@@ -202,7 +201,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void normalMailShouldNotBeIdentifiedAsMailingList() throws Exception {
+    void normalMailShouldNotBeIdentifiedAsMailingList() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("any@any.com")
@@ -213,7 +212,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isAutoSubmittedShouldNotMatchNonAutoSubmittedMails() throws Exception {
+    void isAutoSubmittedShouldNotMatchNonAutoSubmittedMails() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
@@ -223,7 +222,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isAutoSubmittedShouldBeDetected() throws Exception {
+    void isAutoSubmittedShouldBeDetected() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("any@any.com")
@@ -235,7 +234,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isAutoSubmittedShouldBeDetectedWhenAutoGenerated() throws Exception {
+    void isAutoSubmittedShouldBeDetectedWhenAutoGenerated() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("any@any.com")
@@ -247,7 +246,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isAutoSubmittedShouldBeDetectedWhenAutoNotified() throws Exception {
+    void isAutoSubmittedShouldBeDetectedWhenAutoNotified() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
                 .name("mail")
                 .sender("any@any.com")
@@ -259,7 +258,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isMdnSentAutomaticallyShouldBeDetected() throws Exception {
+    void isMdnSentAutomaticallyShouldBeDetected() throws Exception {
         MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
         MimeMultipart multipart = new MimeMultipart();
         MimeBodyPart scriptPart = new MimeBodyPart();
@@ -287,7 +286,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isMdnSentAutomaticallyShouldNotFilterManuallySentMdn() throws Exception {
+    void isMdnSentAutomaticallyShouldNotFilterManuallySentMdn() throws Exception {
         MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         MimeMultipart multipart = new MimeMultipart();
         MimeBodyPart scriptPart = new MimeBodyPart();
@@ -315,7 +314,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isMdnSentAutomaticallyShouldManageItsMimeType() throws Exception {
+    void isMdnSentAutomaticallyShouldManageItsMimeType() throws Exception {
         MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         MimeMultipart multipart = new MimeMultipart();
         MimeBodyPart scriptPart = new MimeBodyPart();
@@ -340,7 +339,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isMdnSentAutomaticallyShouldNotThrowOnBodyPartsWithManyLines() throws Exception {
+    void isMdnSentAutomaticallyShouldNotThrowOnBodyPartsWithManyLines() throws Exception {
         int mime4jDefaultMaxHeaderCount = 1000;
         int headerCount = mime4jDefaultMaxHeaderCount + 10;
         MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
@@ -359,7 +358,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isMdnSentAutomaticallyShouldNotThrowWhenBiggerThan1MB() throws Exception {
+    void isMdnSentAutomaticallyShouldNotThrowWhenBiggerThan1MB() throws Exception {
         MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
             .addHeaders()
             .setMultipartWithBodyParts(
@@ -378,8 +377,7 @@ public class AutomaticallySentMailDetectorImplTest {
     }
 
     @Test
-    public void isMdnSentAutomaticallyShouldDetectBigMDN() throws Exception {
-
+    void isMdnSentAutomaticallyShouldDetectBigMDN() throws Exception {
         MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         MimeMultipart multipart = new MimeMultipart();
         MimeBodyPart scriptPart = new MimeBodyPart();
@@ -409,5 +407,4 @@ public class AutomaticallySentMailDetectorImplTest {
 
         assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isTrue();
     }
-
 }
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
index 22e14fb..c0a0d1b 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
@@ -54,23 +54,19 @@ import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.google.common.collect.ImmutableList;
 
-public class JamesMailetContextTest {
+class JamesMailetContextTest {
     private static final Domain DOMAIN_COM = Domain.of("domain.com");
     private static final String USERNAME = "user";
     private static final Username USERMAIL = Username.of(USERNAME + "@" + DOMAIN_COM.name());
     private static final String PASSWORD = "password";
     private static final DNSService DNS_SERVICE = null;
-
-    @Rule
-    public final JUnitSoftAssertions softly = new JUnitSoftAssertions();
     
     private MemoryDomainList domainList;
     private MemoryUsersRepository usersRepository;
@@ -79,9 +75,9 @@ public class JamesMailetContextTest {
     private MailQueue spoolMailQueue;
     private MemoryRecipientRewriteTable recipientRewriteTable;
 
-    @Before
+    @BeforeEach
     @SuppressWarnings("unchecked")
-    public void setUp() throws Exception {
+    void setUp() throws Exception {
         domainList = spy(new MemoryDomainList(DNS_SERVICE));
         domainList.configure(DomainListConfiguration.DEFAULT);
 
@@ -99,17 +95,17 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldBeFalseOnNullUser() {
+    void isLocalUserShouldBeFalseOnNullUser() {
         assertThat(testee.isLocalUser(null)).isFalse();
     }
 
     @Test
-    public void isLocalServerShouldBeFalseWhenDomainDoNotExist() {
+    void isLocalServerShouldBeFalseWhenDomainDoNotExist() {
         assertThat(testee.isLocalServer(DOMAIN_COM)).isFalse();
     }
 
     @Test
-    public void isLocalServerShouldPropagateDomainExceptions() throws Exception {
+    void isLocalServerShouldPropagateDomainExceptions() throws Exception {
         when(domainList.getDomains()).thenThrow(new DomainListException("fail!"));
 
         assertThatThrownBy(() -> testee.isLocalServer(DOMAIN_COM))
@@ -117,7 +113,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldPropagateDomainExceptions() throws Exception {
+    void isLocalUserShouldPropagateDomainExceptions() throws Exception {
         when(domainList.getDefaultDomain()).thenThrow(new DomainListException("fail!"));
 
         assertThatThrownBy(() -> testee.isLocalUser("user"))
@@ -125,7 +121,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldPropagateUserExceptions() throws Exception {
+    void isLocalUserShouldPropagateUserExceptions() throws Exception {
         domainList.configure(DomainListConfiguration.builder()
             .defaultDomain(Domain.of("any"))
             .build());
@@ -138,7 +134,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldPropagateRrtExceptions() throws Exception {
+    void isLocalUserShouldPropagateRrtExceptions() throws Exception {
         domainList.configure(DomainListConfiguration.builder()
             .defaultDomain(Domain.of("any"))
             .build());
@@ -151,14 +147,14 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalServerShouldBeTrueWhenDomainExist() throws Exception {
+    void isLocalServerShouldBeTrueWhenDomainExist() throws Exception {
         domainList.addDomain(DOMAIN_COM);
 
         assertThat(testee.isLocalServer(DOMAIN_COM)).isTrue();
     }
 
     @Test
-    public void isLocalUserShouldBeTrueWhenUsernameExist() throws Exception {
+    void isLocalUserShouldBeTrueWhenUsernameExist() throws Exception {
         domainList.addDomain(DOMAIN_COM);
         usersRepository.addUser(USERMAIL, PASSWORD);
 
@@ -166,7 +162,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldReturnTrueWhenUsedWithLocalPartAndUserExistOnDefaultDomain() throws Exception {
+    void isLocalUserShouldReturnTrueWhenUsedWithLocalPartAndUserExistOnDefaultDomain() throws Exception {
         domainList.configure(DomainListConfiguration.builder()
             .defaultDomain(DOMAIN_COM)
             .build());
@@ -177,7 +173,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldReturnFalseWhenUsedWithLocalPartAndUserDoNotExistOnDefaultDomain() throws Exception {
+    void isLocalUserShouldReturnFalseWhenUsedWithLocalPartAndUserDoNotExistOnDefaultDomain() throws Exception {
         domainList.configure(DomainListConfiguration.builder()
             .defaultDomain(Domain.of("any"))
             .build());
@@ -189,24 +185,24 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalUserShouldBeFalseWhenUsernameDoNotExist() {
+    void isLocalUserShouldBeFalseWhenUsernameDoNotExist() {
         assertThat(testee.isLocalUser(USERMAIL.asString())).isFalse();
     }
 
     @Test
-    public void isLocalEmailShouldBeFalseWhenUsernameDoNotExist() {
+    void isLocalEmailShouldBeFalseWhenUsernameDoNotExist() {
         assertThat(testee.isLocalEmail(mailAddress)).isFalse();
     }
 
     @Test
-    public void isLocalEmailShouldBeFalseWhenUsernameDoNotExistButDomainExists() throws Exception {
+    void isLocalEmailShouldBeFalseWhenUsernameDoNotExistButDomainExists() throws Exception {
         domainList.addDomain(DOMAIN_COM);
 
         assertThat(testee.isLocalEmail(mailAddress)).isFalse();
     }
 
     @Test
-    public void isLocalEmailShouldBeTrueWhenUsernameExists() throws Exception {
+    void isLocalEmailShouldBeTrueWhenUsernameExists() throws Exception {
         domainList.addDomain(DOMAIN_COM);
         usersRepository.addUser(USERMAIL, PASSWORD);
 
@@ -214,7 +210,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void localRecipientsShouldReturnAddressWhenUserExists() throws Exception {
+    void localRecipientsShouldReturnAddressWhenUserExists() throws Exception {
         domainList.addDomain(DOMAIN_COM);
         usersRepository.addUser(USERMAIL, PASSWORD);
 
@@ -222,7 +218,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void localRecipientsShouldReturnOnlyExistingUsers() throws Exception {
+    void localRecipientsShouldReturnOnlyExistingUsers() throws Exception {
         domainList.addDomain(DOMAIN_COM);
         usersRepository.addUser(USERMAIL, PASSWORD);
 
@@ -233,24 +229,24 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void localRecipientsShouldNotReturnAddressWhenUserDoNotExists() throws Exception {
+    void localRecipientsShouldNotReturnAddressWhenUserDoNotExists() throws Exception {
         domainList.addDomain(DOMAIN_COM);
 
         assertThat(testee.localRecipients(ImmutableList.of(mailAddress))).isEmpty();
     }
 
     @Test
-    public void localRecipientsShouldNotReturnAddressWhenDomainDoNotExists() throws Exception {
+    void localRecipientsShouldNotReturnAddressWhenDomainDoNotExists() throws Exception {
         assertThat(testee.localRecipients(ImmutableList.of(mailAddress))).isEmpty();
     }
 
     @Test
-    public void isLocalEmailShouldBeFalseWhenMailIsNull() {
+    void isLocalEmailShouldBeFalseWhenMailIsNull() {
         assertThat(testee.isLocalEmail(null)).isFalse();
     }
 
     @Test
-    public void isLocalEmailShouldPropagateDomainExceptions() throws Exception {
+    void isLocalEmailShouldPropagateDomainExceptions() throws Exception {
         when(domainList.getDomains()).thenThrow(new DomainListException("fail!"));
 
         assertThatThrownBy(() -> testee.isLocalEmail(mailAddress))
@@ -258,7 +254,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalEmailShouldPropagateUserExceptions() throws Exception {
+    void isLocalEmailShouldPropagateUserExceptions() throws Exception {
         domainList.configure(DomainListConfiguration.builder()
             .defaultDomain(Domain.of("any"))
             .build());
@@ -271,7 +267,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void isLocalEmailShouldPropagateRrtExceptions() throws Exception {
+    void isLocalEmailShouldPropagateRrtExceptions() throws Exception {
         domainList.configure(DomainListConfiguration.builder()
             .defaultDomain(Domain.of("any"))
             .build());
@@ -284,7 +280,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void bounceShouldNotFailWhenNonConfiguredPostmaster() throws Exception {
+    void bounceShouldNotFailWhenNonConfiguredPostmaster() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(mailAddress)
@@ -295,7 +291,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void bouncingToNullSenderShouldBeANoop() throws Exception {
+    void bouncingToNullSenderShouldBeANoop() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(MailAddress.nullSender())
@@ -309,7 +305,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void bouncingToNoSenderShouldBeANoop() throws Exception {
+    void bouncingToNoSenderShouldBeANoop() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .addRecipient(mailAddress)
@@ -322,7 +318,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void bounceShouldEnqueueEmailWithRootState() throws Exception {
+    void bounceShouldEnqueueEmailWithRootState() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(mailAddress)
@@ -340,7 +336,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailShouldEnqueueEmailWithRootState() throws Exception {
+    void sendMailShouldEnqueueEmailWithRootState() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(mailAddress)
@@ -357,7 +353,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
+    void sendMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(mailAddress)
@@ -375,7 +371,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailShouldEnqueueEmailWithRootStateAndDelayWhenSpecified() throws Exception {
+    void sendMailShouldEnqueueEmailWithRootStateAndDelayWhenSpecified() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(mailAddress)
@@ -390,13 +386,15 @@ public class JamesMailetContextTest {
         verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture(), delayArgumentCaptor.capture(), timeUnitArgumentCaptor.capture());
         verifyNoMoreInteractions(spoolMailQueue);
 
-        softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
-        softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
-        softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
+            softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
+            softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+        });
     }
 
     @Test
-    public void sendMailShouldEnqueueEmailWithOtherStateAndDelayWhenSpecified() throws Exception {
+    void sendMailShouldEnqueueEmailWithOtherStateAndDelayWhenSpecified() throws Exception {
         MailImpl mail = MailImpl.builder()
             .name("mail1")
             .sender(mailAddress)
@@ -412,13 +410,15 @@ public class JamesMailetContextTest {
         verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture(), delayArgumentCaptor.capture(), timeUnitArgumentCaptor.capture());
         verifyNoMoreInteractions(spoolMailQueue);
 
-        softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(other);
-        softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
-        softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(other);
+            softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
+            softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+        });
     }
 
     @Test
-    public void sendMailForMessageShouldEnqueueEmailWithRootState() throws Exception {
+    void sendMailForMessageShouldEnqueueEmailWithRootState() throws Exception {
         MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
             .addFrom(mailAddress.asString())
             .addToRecipient(mailAddress.asString())
@@ -435,7 +435,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithRootState() throws Exception {
+    void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithRootState() throws Exception {
         MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
             .addFrom(mailAddress.asString())
             .addToRecipient(mailAddress.asString())
@@ -454,7 +454,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
+    void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
         MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
             .addFrom(mailAddress.asString())
             .addToRecipient(mailAddress.asString())
@@ -474,7 +474,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailForMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
+    void sendMailForMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
         MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
             .addFrom(mailAddress.asString())
             .addToRecipient(mailAddress.asString())
@@ -498,7 +498,7 @@ public class JamesMailetContextTest {
     }
 
     @Test
-    public void sendMailForMailShouldEnqueueEmailWithDefaults() throws Exception {
+    void sendMailForMailShouldEnqueueEmailWithDefaults() throws Exception {
         MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
             .addFrom(mailAddress.asString())
             .addToRecipient(mailAddress.asString())
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
index 1ad3c87..6be2e1c 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
@@ -29,19 +29,17 @@ import org.apache.commons.configuration2.XMLConfiguration;
 import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
 import org.apache.commons.configuration2.builder.fluent.Parameters;
 import org.apache.commons.configuration2.convert.DisabledListDelimiterHandler;
-import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.io.FileHandler;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MailetConfigImplTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class MailetConfigImplTest {
     private XMLConfiguration xmlConfiguration;
     private FileHandler fileHandler;
     private MailetConfigImpl config;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(XMLConfiguration.class)
             .configure(new Parameters()
                 .xml()
@@ -53,7 +51,7 @@ public class MailetConfigImplTest {
     }
 
     @Test
-    public void testDotParamsFromXML() throws Exception {
+    void testDotParamsFromXML() throws Exception {
         fileHandler.load(new ByteArrayInputStream("<mailet><mail.debug>true</mail.debug></mailet>".getBytes()));
 
         config.setConfiguration(xmlConfiguration);
@@ -64,7 +62,7 @@ public class MailetConfigImplTest {
     }
 
     @Test
-    public void testDotParamsFromConfig() throws ConfigurationException {
+    void testDotParamsFromConfig() {
         xmlConfiguration.addProperty("mail.debug", "true");
 
         config.setConfiguration(xmlConfiguration);
@@ -76,7 +74,7 @@ public class MailetConfigImplTest {
 
     // See JAMES-1232
     @Test
-    public void testParamWithComma() throws Exception {
+    void testParamWithComma() throws Exception {
         fileHandler.load(new ByteArrayInputStream("<mailet><whatever>value1,value2</whatever></mailet>".getBytes()));
 
         config.setConfiguration(xmlConfiguration);
@@ -87,7 +85,7 @@ public class MailetConfigImplTest {
     }
 
     @Test
-    public void testParamWithXmlSpace() throws Exception {
+    void testParamWithXmlSpace() throws Exception {
         fileHandler.load(new ByteArrayInputStream(
                 "<mailet><whatever xml:space=\"preserve\"> some text </whatever></mailet>".getBytes()));
 
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
index c7fa744..e621b90 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
@@ -29,20 +29,19 @@ import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class AndTest {
-
+class AndTest {
     private And testee;
     private Matcher matcher1;
     private Matcher matcher2;
     private Mail mail;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         matcher1 = mock(Matcher.class);
         matcher2 = mock(Matcher.class);
 
@@ -52,12 +51,12 @@ public class AndTest {
     }
 
     @Test
-    public void shouldNotMatchWhenNoChild() throws Exception {
+    void shouldNotMatchWhenNoChild() throws Exception {
         assertThat(testee.match(mail)).isEmpty();
     }
 
     @Test
-    public void shouldMatchWhenSingleUnderlyingMatcherMatch() throws Exception {
+    void shouldMatchWhenSingleUnderlyingMatcherMatch() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES));
 
         testee.add(matcher1);
@@ -66,7 +65,7 @@ public class AndTest {
     }
 
     @Test
-    public void shouldMatchWhenTwoUnderlyingMatcherMatch() throws Exception {
+    void shouldMatchWhenTwoUnderlyingMatcherMatch() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
         when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
 
@@ -77,7 +76,7 @@ public class AndTest {
     }
 
     @Test
-    public void shouldMatchWhenAtLeastOneUnderlyingMatcherDoNotMatch() throws Exception {
+    void shouldMatchWhenAtLeastOneUnderlyingMatcherDoNotMatch() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
         when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
 
@@ -88,7 +87,7 @@ public class AndTest {
     }
 
     @Test
-    public void shouldSupportNull() throws Exception {
+    void shouldSupportNull() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
         when(matcher2.match(mail)).thenReturn(null);
 
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
index d69bf08..a4b3737 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
@@ -27,13 +27,12 @@ import org.apache.james.core.MailAddress;
 import org.apache.james.server.core.MailImpl;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class NotTest {
-
+class NotTest {
     private Not testee;
     private Matcher matcher1;
     private Matcher matcher2;
@@ -43,8 +42,8 @@ public class NotTest {
     private MailAddress recipient3;
     private MailAddress recipient4;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         matcher1 = mock(Matcher.class);
         matcher2 = mock(Matcher.class);
 
@@ -58,12 +57,12 @@ public class NotTest {
     }
 
     @Test
-    public void shouldReturnAllAddressesWhenNoMatcherSpecified() throws Exception {
+    void shouldReturnAllAddressesWhenNoMatcherSpecified() throws Exception {
         assertThat(testee.match(mail)).containsOnly(recipient1, recipient2, recipient3, recipient4);
     }
 
     @Test
-    public void shouldNegateWhenOneMatcher() throws Exception {
+    void shouldNegateWhenOneMatcher() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
 
         testee.add(matcher1);
@@ -72,7 +71,7 @@ public class NotTest {
     }
 
     @Test
-    public void shouldNegateUnionWhenTwoMatchers() throws Exception {
+    void shouldNegateUnionWhenTwoMatchers() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
         when(matcher2.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient2));
 
@@ -83,7 +82,7 @@ public class NotTest {
     }
 
     @Test
-    public void shouldAcceptEmptyResults() throws Exception {
+    void shouldAcceptEmptyResults() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
         when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
 
@@ -94,7 +93,7 @@ public class NotTest {
     }
 
     @Test
-    public void shouldAcceptNullResults() throws Exception {
+    void shouldAcceptNullResults() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
         when(matcher2.match(mail)).thenReturn(null);
 
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
index 9827fe7..aa0926f 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
@@ -31,20 +31,19 @@ import org.apache.james.core.MailAddress;
 import org.apache.james.server.core.MailImpl;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class OrTest {
-
+class OrTest {
     private Or testee;
     private Matcher matcher1;
     private Matcher matcher2;
     private Mail mail;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         matcher1 = mock(Matcher.class);
         matcher2 = mock(Matcher.class);
 
@@ -54,12 +53,12 @@ public class OrTest {
     }
 
     @Test
-    public void shouldReturnNoResultWhenNoMatcherSpecified() throws Exception {
+    void shouldReturnNoResultWhenNoMatcherSpecified() throws Exception {
         assertThat(testee.match(mail)).isEmpty();
     }
 
     @Test
-    public void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
+    void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
 
         testee.add(matcher1);
@@ -68,7 +67,7 @@ public class OrTest {
     }
 
     @Test
-    public void shouldReturnUnionWhenTwoMatchers() throws Exception {
+    void shouldReturnUnionWhenTwoMatchers() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
         when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
 
@@ -79,7 +78,7 @@ public class OrTest {
     }
 
     @Test
-    public void shouldAcceptEmptyResults() throws Exception {
+    void shouldAcceptEmptyResults() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
         when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
 
@@ -90,7 +89,7 @@ public class OrTest {
     }
 
     @Test
-    public void shouldAcceptNullResults() throws Exception {
+    void shouldAcceptNullResults() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
         when(matcher2.match(mail)).thenReturn(null);
 
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
index 9d5eb26..9a2dc56 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
@@ -26,24 +26,22 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.apache.james.core.MailAddress;
 import org.apache.james.server.core.MailImpl;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class XorTest {
-
+class XorTest {
     private Xor testee;
     private Matcher matcher1;
     private Matcher matcher2;
     private Mail mail;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         matcher1 = mock(Matcher.class);
         matcher2 = mock(Matcher.class);
 
@@ -53,12 +51,12 @@ public class XorTest {
     }
 
     @Test
-    public void shouldReturnNoResultWhenNoMatcherSpecified() throws Exception {
+    void shouldReturnNoResultWhenNoMatcherSpecified() {
         assertThat(testee.match(mail)).isNull();
     }
 
     @Test
-    public void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
+    void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
 
         testee.add(matcher1);
@@ -67,7 +65,7 @@ public class XorTest {
     }
 
     @Test
-    public void shouldPerformXorWhenTwoMatchers() throws Exception {
+    void shouldPerformXorWhenTwoMatchers() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
         when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
 
@@ -78,9 +76,9 @@ public class XorTest {
     }
 
     @Test
-    public void shouldAcceptEmptyResults() throws Exception {
+    void shouldAcceptEmptyResults() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
-        when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
+        when(matcher2.match(mail)).thenReturn(ImmutableList.of());
 
         testee.add(matcher1);
         testee.add(matcher2);
@@ -89,7 +87,7 @@ public class XorTest {
     }
 
     @Test
-    public void shouldAcceptNullResults() throws Exception {
+    void shouldAcceptNullResults() throws Exception {
         when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
         when(matcher2.match(mail)).thenReturn(null);
 
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
index ffa1258..e1d9306 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
@@ -34,15 +34,9 @@ import org.apache.james.mailetcontainer.api.mock.MockMailProcessor;
 import org.apache.james.server.core.MailImpl;
 import org.apache.james.server.core.configuration.FileConfigurationProvider;
 import org.apache.mailet.Mail;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 public abstract class AbstractStateCompositeProcessorTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     @Test
     public void testChooseRightProcessor() throws Exception {
         AbstractStateCompositeProcessor processor = new AbstractStateCompositeProcessor() {
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
index 8cea067..bb5f33a 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
@@ -41,7 +41,7 @@ import org.apache.james.server.core.configuration.FileConfigurationProvider;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.Matcher;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public abstract class AbstractStateMailetProcessorTest {


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


[james-project] 02/33: [REFACTORING] Get rid of JUNIT 4 usages in CLI tests

Posted by bt...@apache.org.
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 3700c249d41fafcc95ed2cfe36da40b3b6f617ed
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 09:51:12 2021 +0700

    [REFACTORING] Get rid of JUNIT 4 usages in CLI tests
---
 .../java/org/apache/james/cli/ServerCmdTest.java   | 228 ++++++++++-----------
 .../org/apache/james/cli/type/CmdTypeTest.java     |  94 ++++-----
 2 files changed, 161 insertions(+), 161 deletions(-)

diff --git a/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java b/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
index 915aab4..0b8d025 100644
--- a/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
+++ b/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
@@ -46,12 +46,12 @@ import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.SerializableQuota;
 import org.apache.james.mailbox.model.SerializableQuotaLimitValue;
 import org.apache.james.rrt.lib.MappingsImpl;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class ServerCmdTest {
+class ServerCmdTest {
 
     private static final String ADDITIONAL_ARGUMENT = "additionalArgument";
 
@@ -62,8 +62,8 @@ public class ServerCmdTest {
 
     private ServerCmd testee;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         dataProbe = mock(JmxDataProbe.class);
         mailboxProbe = mock(JmxMailboxProbe.class);
         quotaProbe = mock(JmxQuotaProbe.class);
@@ -72,7 +72,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addDomainCommandShouldWork() throws Exception {
+    void addDomainCommandShouldWork() throws Exception {
         String domain = "example.com";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDDOMAIN.getCommand(), domain};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -83,7 +83,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeDomainCommandShouldWork() throws Exception {
+    void removeDomainCommandShouldWork() throws Exception {
         String domain = "example.com";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEDOMAIN.getCommand(), domain};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -94,7 +94,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void containsDomainCommandShouldWork() throws Exception {
+    void containsDomainCommandShouldWork() throws Exception {
         String domain = "example.com";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.CONTAINSDOMAIN.getCommand(), domain};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -105,7 +105,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listDomainsCommandShouldWork() throws Exception {
+    void listDomainsCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTDOMAINS.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -115,7 +115,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addUserCommandShouldWork() throws Exception {
+    void addUserCommandShouldWork() throws Exception {
         String user = "user@domain";
         String password = "password";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDUSER.getCommand(), user, password};
@@ -127,7 +127,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeUserCommandShouldWork() throws Exception {
+    void removeUserCommandShouldWork() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEUSER.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -138,7 +138,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUsersCommandShouldWork() throws Exception {
+    void listUsersCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERS.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -149,7 +149,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listMappingsCommandShouldWork() throws Exception {
+    void listMappingsCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTMAPPINGS.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -159,7 +159,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUserDomainMappingsCommandShouldWork() throws Exception {
+    void listUserDomainMappingsCommandShouldWork() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERDOMAINMAPPINGS.getCommand(), user, domain};
@@ -171,7 +171,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addAddressCommandShouldWork() throws Exception {
+    void addAddressCommandShouldWork() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String address = "bis@apache.org";
@@ -184,7 +184,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeAddressCommandShouldWork() throws Exception {
+    void removeAddressCommandShouldWork() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String address = "bis@apache.org";
@@ -197,7 +197,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addRegexMappingCommandShouldWork() throws Exception {
+    void addRegexMappingCommandShouldWork() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String regex = "bis.*@apache.org";
@@ -210,7 +210,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeRegexMappingCommandShouldWork() throws Exception {
+    void removeRegexMappingCommandShouldWork() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String regex = "bis.*@apache.org";
@@ -223,7 +223,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setPasswordMappingCommandShouldWork() throws Exception {
+    void setPasswordMappingCommandShouldWork() throws Exception {
         String user = "user@domain";
         String password = "pass";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETPASSWORD.getCommand(), user, password};
@@ -235,7 +235,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void copyMailboxMappingCommandShouldWork() throws Exception {
+    void copyMailboxMappingCommandShouldWork() throws Exception {
         String srcBean = "srcBean";
         String dstBean = "dstBean";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.COPYMAILBOX.getCommand(), srcBean, dstBean};
@@ -247,7 +247,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void deleteUserMailboxesMappingCommandShouldWork() throws Exception {
+    void deleteUserMailboxesMappingCommandShouldWork() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEUSERMAILBOXES.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -258,7 +258,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void createMailboxMappingCommandShouldWork() throws Exception {
+    void createMailboxMappingCommandShouldWork() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -271,7 +271,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void deleteMailboxMappingCommandShouldWork() throws Exception {
+    void deleteMailboxMappingCommandShouldWork() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -284,7 +284,7 @@ public class ServerCmdTest {
     }
     
     @Test
-    public void importEmlFileToMailboxCommandShouldWork() throws Exception {
+    void importEmlFileToMailboxCommandShouldWork() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -298,7 +298,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUserMailboxesMappingsCommandShouldWork() throws Exception {
+    void listUserMailboxesMappingsCommandShouldWork() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERMAILBOXES.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -309,7 +309,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getQuotaRootCommandShouldWork() throws Exception {
+    void getQuotaRootCommandShouldWork() throws Exception {
         String namespace = "#private";
         String user = "user@domain";
         String name = "INBOX";
@@ -322,7 +322,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getGlobalMaxMessageCountCommandShouldWork() throws Exception {
+    void getGlobalMaxMessageCountCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETGLOBALMAXMESSAGECOUNTQUOTA.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -332,7 +332,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getGlobalMaxStorageCommandShouldWork() throws Exception {
+    void getGlobalMaxStorageCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETGLOBALMAXSTORAGEQUOTA.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -342,7 +342,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setGlobalMaxMessageCountCommandShouldWork() throws Exception {
+    void setGlobalMaxMessageCountCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETGLOBALMAXMESSAGECOUNTQUOTA.getCommand(), "1054"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -352,7 +352,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setGlobalMaxMessageCountCommandShouldWorkWhenUnlimited() throws Exception {
+    void setGlobalMaxMessageCountCommandShouldWorkWhenUnlimited() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETGLOBALMAXMESSAGECOUNTQUOTA.getCommand(), "-1"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -362,7 +362,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setGlobalMaxMessageCountCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
+    void setGlobalMaxMessageCountCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETGLOBALMAXMESSAGECOUNTQUOTA.getCommand(), "-2"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -371,7 +371,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setGlobalMaxStorageCommandShouldWork() throws Exception {
+    void setGlobalMaxStorageCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETGLOBALMAXSTORAGEQUOTA.getCommand(), "1G"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -381,7 +381,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setGlobalMaxStorageCommandShouldWorkWhenUnlimited() throws Exception {
+    void setGlobalMaxStorageCommandShouldWorkWhenUnlimited() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETGLOBALMAXSTORAGEQUOTA.getCommand(), "-1"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -391,7 +391,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setGlobalMaxStorageCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
+    void setGlobalMaxStorageCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETGLOBALMAXSTORAGEQUOTA.getCommand(), "-2"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -400,7 +400,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setMaxMessageCountCommandShouldWork() throws Exception {
+    void setMaxMessageCountCommandShouldWork() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot, "1000"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -411,7 +411,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setMaxMessageCountCommandShouldWorkWhenUnlimited() throws Exception {
+    void setMaxMessageCountCommandShouldWorkWhenUnlimited() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot, "-1"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -422,7 +422,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setMaxMessageCountCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
+    void setMaxMessageCountCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot, "-2"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -432,7 +432,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setMaxStorageCommandShouldWork() throws Exception {
+    void setMaxStorageCommandShouldWork() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETMAXSTORAGEQUOTA.getCommand(), quotaroot, "5M"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -443,7 +443,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setMaxStorageCommandShouldWorkWhenUnlimited() throws Exception {
+    void setMaxStorageCommandShouldWorkWhenUnlimited() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETMAXSTORAGEQUOTA.getCommand(), quotaroot, "-1"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -454,7 +454,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setMaxStorageCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
+    void setMaxStorageCommandShouldThrowWhenNegativeAndNotUnlimited() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "--", CmdType.SETMAXSTORAGEQUOTA.getCommand(), quotaroot, "-2"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -464,7 +464,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getMaxMessageCountCommandShouldWork() throws Exception {
+    void getMaxMessageCountCommandShouldWork() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -475,7 +475,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getMaxStorageQuotaCommandShouldWork() throws Exception {
+    void getMaxStorageQuotaCommandShouldWork() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETMAXSTORAGEQUOTA.getCommand(), quotaroot};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -486,7 +486,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getStorageQuotaCommandShouldWork() throws Exception {
+    void getStorageQuotaCommandShouldWork() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSTORAGEQUOTA.getCommand(), quotaroot};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -497,7 +497,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getMessageCountQuotaCommandShouldWork() throws Exception {
+    void getMessageCountQuotaCommandShouldWork() throws Exception {
         String quotaroot = "#private&user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETMESSAGECOUNTQUOTA.getCommand(), quotaroot};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -508,7 +508,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void reIndexAllQuotaCommandShouldWork() throws Exception {
+    void reIndexAllQuotaCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REINDEXALL.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -518,7 +518,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void reIndexMailboxCommandShouldWork() throws Exception {
+    void reIndexMailboxCommandShouldWork() throws Exception {
         String namespace = "#private";
         String user = "btellier@apache.org";
         String name = "INBOX";
@@ -531,7 +531,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setSieveQuotaCommandShouldWork() throws Exception {
+    void setSieveQuotaCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETSIEVEQUOTA.getCommand(), "2K"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -541,7 +541,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setSieveUserQuotaCommandShouldWork() throws Exception {
+    void setSieveUserQuotaCommandShouldWork() throws Exception {
         String user = "btellier@apache.org";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETSIEVEUSERQUOTA.getCommand(), user, "1K"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -552,7 +552,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getSieveQuotaCommandShouldWork() throws Exception {
+    void getSieveQuotaCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSIEVEQUOTA.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -564,7 +564,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getSieveUserQuotaCommandShouldWork() throws Exception {
+    void getSieveUserQuotaCommandShouldWork() throws Exception {
         String user = "btellier@apache.org";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSIEVEUSERQUOTA.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -577,7 +577,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeSieveQuotaCommandShouldWork() throws Exception {
+    void removeSieveQuotaCommandShouldWork() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEQUOTA.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -587,7 +587,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeSieveUserQuotaCommandShouldWork() throws Exception {
+    void removeSieveUserQuotaCommandShouldWork() throws Exception {
         String user = "btellier@apache.org";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEUSERQUOTA.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -598,7 +598,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addDomainCommandShouldThrowOnMissingArguments() throws Exception {
+    void addDomainCommandShouldThrowOnMissingArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDDOMAIN.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -607,7 +607,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeDomainCommandShouldThrowOnMissingArguments() throws Exception {
+    void removeDomainCommandShouldThrowOnMissingArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEDOMAIN.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         
@@ -616,7 +616,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void containsDomainCommandShouldThrowOnMissingArguments() throws Exception {
+    void containsDomainCommandShouldThrowOnMissingArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.CONTAINSDOMAIN.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -625,7 +625,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addUserCommandShouldThrowOnMissingArguments() throws Exception {
+    void addUserCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDUSER.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -635,7 +635,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeUserCommandShouldThrowOnMissingArguments() throws Exception {
+    void removeUserCommandShouldThrowOnMissingArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEUSER.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -644,7 +644,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUserDomainMappingsCommandShouldThrowOnMissingArguments() throws Exception {
+    void listUserDomainMappingsCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERDOMAINMAPPINGS.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -654,7 +654,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addAddressCommandShouldThrowOnMissingArguments() throws Exception {
+    void addAddressCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDADDRESSMAPPING.getCommand(), user, domain};
@@ -665,7 +665,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeAddressCommandShouldThrowOnMissingArguments() throws Exception {
+    void removeAddressCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEADDRESSMAPPING.getCommand(), user, domain};
@@ -676,7 +676,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addRegexMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void addRegexMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDREGEXMAPPING.getCommand(), user, domain};
@@ -687,7 +687,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeRegexMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void removeRegexMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEREGEXMAPPING.getCommand(), user, domain};
@@ -698,7 +698,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setPasswordMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void setPasswordMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETPASSWORD.getCommand(), user};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -708,7 +708,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void copyMailboxMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void copyMailboxMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String srcBean = "srcBean";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.COPYMAILBOX.getCommand(), srcBean};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -718,7 +718,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void deleteUserMailboxesMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void deleteUserMailboxesMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEUSERMAILBOXES.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -727,7 +727,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void createMailboxMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void createMailboxMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.CREATEMAILBOX.getCommand(), namespace, user};
@@ -738,7 +738,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void deleteMailboxMappingCommandShouldThrowOnMissingArguments() throws Exception {
+    void deleteMailboxMappingCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEMAILBOX.getCommand(), namespace, user};
@@ -750,7 +750,7 @@ public class ServerCmdTest {
 
 
     @Test
-    public void importEmlFileToMailboxCommandShouldThrowOnMissingArguments() throws Exception {
+    void importEmlFileToMailboxCommandShouldThrowOnMissingArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -762,7 +762,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUserMailboxesMappingsCommandShouldThrowOnMissingArguments() throws Exception {
+    void listUserMailboxesMappingsCommandShouldThrowOnMissingArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERMAILBOXES.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -771,7 +771,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addDomainCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void addDomainCommandShouldThrowOnAdditionalArguments() throws Exception {
         String domain = "example.com";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDDOMAIN.getCommand(), domain, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -781,7 +781,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeDomainCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void removeDomainCommandShouldThrowOnAdditionalArguments() throws Exception {
         String domain = "example.com";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEDOMAIN.getCommand(), domain, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -791,7 +791,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void containsDomainCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void containsDomainCommandShouldThrowOnAdditionalArguments() throws Exception {
         String domain = "example.com";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.CONTAINSDOMAIN.getCommand(), domain, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -801,7 +801,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listDomainsCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void listDomainsCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTDOMAINS.getCommand(), ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -810,7 +810,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addUserCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void addUserCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String password = "password";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDUSER.getCommand(), user, password, ADDITIONAL_ARGUMENT };
@@ -821,7 +821,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeUserCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void removeUserCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEUSER.getCommand(), user, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -831,7 +831,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUsersCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void listUsersCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERS.getCommand(), ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -840,7 +840,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listMappingsCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void listMappingsCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTMAPPINGS.getCommand(), ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -849,7 +849,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUserDomainMappingsCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void listUserDomainMappingsCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERDOMAINMAPPINGS.getCommand(), user, domain, ADDITIONAL_ARGUMENT };
@@ -860,7 +860,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addAddressCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void addAddressCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String address = "bis@apache.org";
@@ -872,7 +872,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeAddressCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void removeAddressCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String address = "bis@apache.org";
@@ -884,7 +884,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addRegexMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void addRegexMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String regex = "bis.*@apache.org";
@@ -896,7 +896,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeRegexMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void removeRegexMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String domain = "domain";
         String regex = "bis.*@apache.org";
@@ -908,7 +908,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setPasswordMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void setPasswordMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String password = "pass";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETPASSWORD.getCommand(), user, password, ADDITIONAL_ARGUMENT };
@@ -919,7 +919,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void copyMailboxMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void copyMailboxMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String srcBean = "srcBean";
         String dstBean = "dstBean";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.COPYMAILBOX.getCommand(), srcBean, dstBean, ADDITIONAL_ARGUMENT };
@@ -930,7 +930,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void deleteUserMailboxesMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void deleteUserMailboxesMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEUSERMAILBOXES.getCommand(), user, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -940,7 +940,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void createMailboxMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void createMailboxMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -952,7 +952,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void deleteMailboxMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void deleteMailboxMappingCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -964,7 +964,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void importEmlFileToMailboxCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void importEmlFileToMailboxCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -977,7 +977,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void listUserMailboxesMappingsCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void listUserMailboxesMappingsCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERMAILBOXES.getCommand(), user, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -987,7 +987,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void reIndexAllCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void reIndexAllCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REINDEXALL.getCommand(), ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -996,7 +996,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void reIndexMailboxCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void reIndexMailboxCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String namespace = "#private";
         String name = "INBOX.test";
@@ -1008,7 +1008,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeSieveQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void removeSieveQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEQUOTA.getCommand(), ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -1017,7 +1017,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void removeSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void removeSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEUSERQUOTA.getCommand(), user, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -1027,7 +1027,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getSieveQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void getSieveQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSIEVEQUOTA.getCommand(), ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -1036,7 +1036,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setSieveQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void setSieveQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETSIEVEQUOTA.getCommand(), "64K", ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -1045,7 +1045,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void getSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSIEVEUSERQUOTA.getCommand(), user, ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -1055,7 +1055,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void setSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void setSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETSIEVEUSERQUOTA.getCommand(), user, "64K", ADDITIONAL_ARGUMENT };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
@@ -1065,7 +1065,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void addActiveSieveScriptCommandShouldThrowOnAdditionalArguments() throws Exception {
+    void addActiveSieveScriptCommandShouldThrowOnAdditionalArguments() throws Exception {
         String user = "user@domain";
         String scriptName = "sieve_script";
         String scriptPath = "./src/test/resources/sieve/sieve_script";
@@ -1078,7 +1078,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void executeCommandLineShouldThrowOnUnrecognizedCommands() throws Exception {
+    void executeCommandLineShouldThrowOnUnrecognizedCommands() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "wrongCommand"};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -1087,7 +1087,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void parseCommandLineShouldThrowWhenOnlyOptionAreProvided() throws Exception {
+    void parseCommandLineShouldThrowWhenOnlyOptionAreProvided() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999" };
 
         assertThatThrownBy(() -> ServerCmd.parseCommandLine(arguments))
@@ -1095,7 +1095,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void parseCommandLineShouldThrowWhenInvalidOptionIsProvided() throws Exception {
+    void parseCommandLineShouldThrowWhenInvalidOptionIsProvided() throws Exception {
         String[] arguments = { "-v", "-h", "127.0.0.1", "-p", "9999" };
 
         assertThatThrownBy(() -> ServerCmd.parseCommandLine(arguments))
@@ -1103,7 +1103,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void parseCommandLineShouldThrowWhenMandatoryOptionIsMissing() throws Exception {
+    void parseCommandLineShouldThrowWhenMandatoryOptionIsMissing() throws Exception {
         String[] arguments = { "-v", "-h", "127.0.0.1", "-p", "9999" };
 
         assertThatThrownBy(() -> ServerCmd.parseCommandLine(arguments))
@@ -1111,70 +1111,70 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void parseCommandLineShouldReturnACommandLineWithCorrectArguments() throws Exception {
+    void parseCommandLineShouldReturnACommandLineWithCorrectArguments() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(commandLine.getArgs()).containsExactly("command", "arg1", "arg2", "arg3");
     }
 
     @Test
-    public void parseCommandLineShouldReturnACommandLineWithCorrectPortOption() throws Exception {
+    void parseCommandLineShouldReturnACommandLineWithCorrectPortOption() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(commandLine.getOptionValue(ServerCmd.PORT_OPT_LONG)).isEqualTo("9999");
     }
 
     @Test
-    public void parseCommandLineShouldReturnACommandLineWithCorrectHostOption() throws Exception {
+    void parseCommandLineShouldReturnACommandLineWithCorrectHostOption() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(commandLine.getOptionValue(ServerCmd.HOST_OPT_LONG)).isEqualTo("127.0.0.1");
     }
 
     @Test
-    public void getHostShouldUseDefaultValueWhenNone() throws Exception {
+    void getHostShouldUseDefaultValueWhenNone() throws Exception {
         String[] arguments = { "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(ServerCmd.getHost(commandLine)).isEqualTo("127.0.0.1");
     }
 
     @Test
-    public void getHostShouldUseDefaultValueWhenEmpty() throws Exception {
+    void getHostShouldUseDefaultValueWhenEmpty() throws Exception {
         String[] arguments = { "-h", "", "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(ServerCmd.getHost(commandLine)).isEqualTo("127.0.0.1");
     }
 
     @Test
-    public void getHostShouldReturnValueWhenGiven() throws Exception {
+    void getHostShouldReturnValueWhenGiven() throws Exception {
         String[] arguments = { "-h", "123.4.5.6", "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(ServerCmd.getHost(commandLine)).isEqualTo("123.4.5.6");
     }
 
     @Test
-    public void getPortShouldUseDefaultValueWhenNone() throws Exception {
+    void getPortShouldUseDefaultValueWhenNone() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(ServerCmd.getPort(commandLine)).isEqualTo(9999);
     }
 
     @Test
-    public void getPortShouldUseDefaultValueWhenEmpty() throws Exception {
+    void getPortShouldUseDefaultValueWhenEmpty() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(ServerCmd.getPort(commandLine)).isEqualTo(9999);
     }
 
     @Test
-    public void getPortShouldRetrievePort() throws Exception {
+    void getPortShouldRetrievePort() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
         assertThat(ServerCmd.getPort(commandLine)).isEqualTo(9999);
     }
 
     @Test
-    public void getPortShouldThrowOnNullPortValueOption() throws Exception {
+    void getPortShouldThrowOnNullPortValueOption() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "0", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -1183,7 +1183,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getPortShouldThrowOnNegativePortValueOption() throws Exception {
+    void getPortShouldThrowOnNegativePortValueOption() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "-1", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
@@ -1192,7 +1192,7 @@ public class ServerCmdTest {
     }
 
     @Test
-    public void getPortShouldThrowOnTooHighPortValueOption() throws Exception {
+    void getPortShouldThrowOnTooHighPortValueOption() throws Exception {
         String[] arguments = { "-h", "127.0.0.1", "-p", "99999", "command", "arg1", "arg2", "arg3" };
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
diff --git a/server/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java b/server/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
index 8a32619..90f3a17 100644
--- a/server/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
+++ b/server/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
@@ -20,7 +20,7 @@ package org.apache.james.cli.type;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for the CmdType enum.
@@ -28,234 +28,234 @@ import org.junit.Test;
 public class CmdTypeTest {
 
     @Test
-    public void hasCorrectArgumentShouldBeFalseOnNegativeInput() {
+    void hasCorrectArgumentShouldBeFalseOnNegativeInput() {
         assertThat(CmdType.ADDDOMAIN.hasCorrectArguments(-1)).isFalse();
     }
     
     @Test
-    public void hasCorrectArgumentShouldBeTrueOnRightArgumentNumber() {
+    void hasCorrectArgumentShouldBeTrueOnRightArgumentNumber() {
         assertThat(CmdType.ADDDOMAIN.hasCorrectArguments(2)).isTrue();
     }
     
 
     @Test
-    public void hasCorrectArgumentShouldBeFalseOnIncorrectArgumentNumber() {
+    void hasCorrectArgumentShouldBeFalseOnIncorrectArgumentNumber() {
         assertThat(CmdType.ADDDOMAIN.hasCorrectArguments(1)).isFalse();
     }
 
     @Test 
-    public void lookupAddUserShouldReturnEnumValue() {
+    void lookupAddUserShouldReturnEnumValue() {
         assertThat(CmdType.lookup("adduser")).isEqualTo(CmdType.ADDUSER);
     }
     
     @Test 
-    public void lookupRemoveUserShouldReturnEnumValue() {
+    void lookupRemoveUserShouldReturnEnumValue() {
         assertThat(CmdType.lookup("removeuser")).isEqualTo(CmdType.REMOVEUSER);
     }
     
     @Test 
-    public void lookupListUsersShouldReturnEnumValue() {
+    void lookupListUsersShouldReturnEnumValue() {
         assertThat(CmdType.lookup("listusers")).isEqualTo(CmdType.LISTUSERS);
     }
     
     @Test 
-    public void lookupAddDomainShouldReturnEnumValue() {
+    void lookupAddDomainShouldReturnEnumValue() {
         assertThat(CmdType.lookup("adddomain")).isEqualTo(CmdType.ADDDOMAIN);
     }
     
     @Test 
-    public void lookupRemoveDomainShouldReturnEnumValue() {
+    void lookupRemoveDomainShouldReturnEnumValue() {
         assertThat(CmdType.lookup("removedomain")).isEqualTo(CmdType.REMOVEDOMAIN);
     }
     
     @Test 
-    public void lookupContainsDomainShouldReturnEnumValue() {
+    void lookupContainsDomainShouldReturnEnumValue() {
         assertThat(CmdType.lookup("containsdomain")).isEqualTo(CmdType.CONTAINSDOMAIN);
     }
     
     @Test 
-    public void lookupListDomainsShouldReturnEnumValue() {
+    void lookupListDomainsShouldReturnEnumValue() {
         assertThat(CmdType.lookup("listdomains")).isEqualTo(CmdType.LISTDOMAINS);
     }
     
     @Test 
-    public void lookupListMappingsShouldReturnEnumValue() {
+    void lookupListMappingsShouldReturnEnumValue() {
         assertThat(CmdType.lookup("listmappings")).isEqualTo(CmdType.LISTMAPPINGS);
     }
     
     @Test 
-    public void lookupListUserDomainMappingsShouldReturnEnumValue() {
+    void lookupListUserDomainMappingsShouldReturnEnumValue() {
         assertThat(CmdType.lookup("listuserdomainmappings")).isEqualTo(CmdType.LISTUSERDOMAINMAPPINGS);
     }
     
     @Test 
-    public void lookupAddAddressMappingShouldReturnEnumValue() {
+    void lookupAddAddressMappingShouldReturnEnumValue() {
         assertThat(CmdType.lookup("addaddressmapping")).isEqualTo(CmdType.ADDADDRESSMAPPING);
     }
     
     @Test 
-    public void lookupRemoveAddressMappingShouldReturnEnumValue() {
+    void lookupRemoveAddressMappingShouldReturnEnumValue() {
         assertThat(CmdType.lookup("removeaddressmapping")).isEqualTo(CmdType.REMOVEADDRESSMAPPING);
     }
     
     @Test 
-    public void lookupAddRegexMappingShouldReturnEnumValue() {
+    void lookupAddRegexMappingShouldReturnEnumValue() {
         assertThat(CmdType.lookup("addregexmapping")).isEqualTo(CmdType.ADDREGEXMAPPING);
     }
     
     @Test 
-    public void lookupRemoveRegexMappingShouldReturnEnumValue() {
+    void lookupRemoveRegexMappingShouldReturnEnumValue() {
         assertThat(CmdType.lookup("removeregexmapping")).isEqualTo(CmdType.REMOVEREGEXMAPPING);
     }
     
     @Test 
-    public void lookupSetPasswordShouldReturnEnumValue() {
+    void lookupSetPasswordShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setpassword")).isEqualTo(CmdType.SETPASSWORD);
     }
     
     @Test 
-    public void lookupCopyMailboxShouldReturnEnumValue() {
+    void lookupCopyMailboxShouldReturnEnumValue() {
         assertThat(CmdType.lookup("copymailbox")).isEqualTo(CmdType.COPYMAILBOX);
     }
     
     @Test 
-    public void lookupDeleteUserMailboxesShouldReturnEnumValue() {
+    void lookupDeleteUserMailboxesShouldReturnEnumValue() {
         assertThat(CmdType.lookup("deleteusermailboxes")).isEqualTo(CmdType.DELETEUSERMAILBOXES);
     }
 
     @Test 
-    public void lookupCreateMailboxShouldReturnEnumValue() {
+    void lookupCreateMailboxShouldReturnEnumValue() {
         assertThat(CmdType.lookup("createmailbox")).isEqualTo(CmdType.CREATEMAILBOX);
     }
 
     @Test 
-    public void lookupListUserMailboxesShouldReturnEnumValue() {
+    void lookupListUserMailboxesShouldReturnEnumValue() {
         assertThat(CmdType.lookup("listusermailboxes")).isEqualTo(CmdType.LISTUSERMAILBOXES);
     }
 
     @Test 
-    public void lookupDeleteMailboxShouldReturnEnumValue() {
+    void lookupDeleteMailboxShouldReturnEnumValue() {
         assertThat(CmdType.lookup("deletemailbox")).isEqualTo(CmdType.DELETEMAILBOX);
     }
 
     @Test
-    public void lookupImportEmlFileToMailboxShouldReturnEnumValue() {
+    void lookupImportEmlFileToMailboxShouldReturnEnumValue() {
         assertThat(CmdType.lookup("ImportEml"))
             .isEqualTo(CmdType.IMPORTEML);
     }
 
     @Test
-    public void lookupSetGlobalMaxStorageQuotaShouldReturnEnumValue() {
+    void lookupSetGlobalMaxStorageQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setglobalmaxstoragequota")).isEqualTo(CmdType.SETGLOBALMAXSTORAGEQUOTA);
     }
 
     @Test
-    public void lookupSetGlobalMaxMessageCountQuotaShouldReturnEnumValue() {
+    void lookupSetGlobalMaxMessageCountQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setglobalmaxmessagecountquota")).isEqualTo(CmdType.SETGLOBALMAXMESSAGECOUNTQUOTA);
     }
 
     @Test
-    public void lookupGetGlobalMaxStorageQuotaShouldReturnEnumValue() {
+    void lookupGetGlobalMaxStorageQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getglobalmaxstoragequota")).isEqualTo(CmdType.GETGLOBALMAXSTORAGEQUOTA);
     }
 
     @Test
-    public void lookupGetGlobalMaxMessageCountQuotaShouldReturnEnumValue() {
+    void lookupGetGlobalMaxMessageCountQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getglobalmaxmessagecountquota")).isEqualTo(CmdType.GETGLOBALMAXMESSAGECOUNTQUOTA);
     }
 
     @Test
-    public void lookupSetMaxStorageQuotaShouldReturnEnumValue() {
+    void lookupSetMaxStorageQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setmaxstoragequota")).isEqualTo(CmdType.SETMAXSTORAGEQUOTA);
     }
 
     @Test
-    public void lookupSetMaxMessageCountQuotaShouldReturnEnumValue() {
+    void lookupSetMaxMessageCountQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setmaxmessagecountquota")).isEqualTo(CmdType.SETMAXMESSAGECOUNTQUOTA);
     }
 
     @Test
-    public void lookupGetMaxStorageQuotaShouldReturnEnumValue() {
+    void lookupGetMaxStorageQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getmaxstoragequota")).isEqualTo(CmdType.GETMAXSTORAGEQUOTA);
     }
 
     @Test
-    public void lookupGetMaxMessageCountQuotaShouldReturnEnumValue() {
+    void lookupGetMaxMessageCountQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getmaxmessagecountquota")).isEqualTo(CmdType.GETMAXMESSAGECOUNTQUOTA);
     }
 
     @Test
-    public void lookupGetStorageQuotaShouldReturnEnumValue() {
+    void lookupGetStorageQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getstoragequota")).isEqualTo(CmdType.GETSTORAGEQUOTA);
     }
 
     @Test
-    public void lookupGetMessageCountQuotaShouldReturnEnumValue() {
+    void lookupGetMessageCountQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getmessagecountquota")).isEqualTo(CmdType.GETMESSAGECOUNTQUOTA);
     }
 
     @Test
-    public void lookupReIndexMailboxShouldReturnEnumValue() {
+    void lookupReIndexMailboxShouldReturnEnumValue() {
         assertThat(CmdType.lookup("reindexall")).isEqualTo(CmdType.REINDEXALL);
     }
 
     @Test
-    public void lookupReIndexAllShouldReturnEnumValue() {
+    void lookupReIndexAllShouldReturnEnumValue() {
         assertThat(CmdType.lookup("reindexmailbox")).isEqualTo(CmdType.REINDEXMAILBOX);
     }
 
     @Test
-    public void lookupGetSieveQuotaShouldReturnEnumValue() {
+    void lookupGetSieveQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getsievequota")).isEqualTo(CmdType.GETSIEVEQUOTA);
     }
 
     @Test
-    public void lookupGetSieveUserQuotaShouldReturnEnumValue() {
+    void lookupGetSieveUserQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("getsieveuserquota")).isEqualTo(CmdType.GETSIEVEUSERQUOTA);
     }
 
     @Test
-    public void lookupSetSieveQuotaShouldReturnEnumValue() {
+    void lookupSetSieveQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setsievequota")).isEqualTo(CmdType.SETSIEVEQUOTA);
     }
 
     @Test
-    public void lookupSetSieveUserQuotaShouldReturnEnumValue() {
+    void lookupSetSieveUserQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("setsieveuserquota")).isEqualTo(CmdType.SETSIEVEUSERQUOTA);
     }
 
     @Test
-    public void lookupRemoveSieveQuotaShouldReturnEnumValue() {
+    void lookupRemoveSieveQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("removesievequota")).isEqualTo(CmdType.REMOVESIEVEQUOTA);
     }
 
     @Test
-    public void lookupRemoveSieveUserQuotaShouldReturnEnumValue() {
+    void lookupRemoveSieveUserQuotaShouldReturnEnumValue() {
         assertThat(CmdType.lookup("removesieveuserquota")).isEqualTo(CmdType.REMOVESIEVEUSERQUOTA);
     }
 
     @Test
-    public void addSieveScriptShouldReturnEnumValue() {
+    void addSieveScriptShouldReturnEnumValue() {
         assertThat(CmdType.lookup("addactivesievescript")).isEqualTo(CmdType.ADDACTIVESIEVESCRIPT);
     }
 
     @Test 
-    public void lookupEmptyStringShouldReturnNull() {
+    void lookupEmptyStringShouldReturnNull() {
         assertThat(CmdType.lookup("")).isNull();
     }
 
     @Test 
-    public void lookupUnknownStringShouldReturnNull() {
+    void lookupUnknownStringShouldReturnNull() {
         assertThat(CmdType.lookup("error")).isNull();
     }
 
     @Test 
-    public void lookupNullShouldReturnNull() {
+    void lookupNullShouldReturnNull() {
         assertThat(CmdType.lookup(null)).isNull();
     }
     
     @Test
-    public void usageShouldOutputCommandNamesAndArguments() {
+    void usageShouldOutputCommandNamesAndArguments() {
         assertThat(CmdType.CREATEMAILBOX.getUsage()).isEqualTo("CreateMailbox <namespace> <user> <name>");
     }
     


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


[james-project] 24/33: JAMES-3491 WebSocketPushEnable defaults to `all`

Posted by bt...@apache.org.
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 fe9e7ce4246ea4199522962592e391ee5e41992f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 11:21:12 2021 +0700

    JAMES-3491 WebSocketPushEnable defaults to `all`
    
    https://tools.ietf.org/html/rfc8887 4.3.5.2.
    
    ```
    If null, changes will be
    pushed for all supported data types.
    ```
---
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 93 +++++++++++++++++++---
 .../org/apache/james/jmap/change/StateChange.scala |  4 +
 .../james/jmap/core/WebSocketTransport.scala       |  2 +-
 .../apache/james/jmap/routes/WebSocketRoutes.scala |  4 +-
 4 files changed, 88 insertions(+), 15 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index f47f734..e1fcb87 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -466,18 +466,87 @@ trait WebSocketContract {
                  |}""".stripMargin))
 
             List(
-            ws.receive()
-              .map { case t: Text =>
-                t.payload
-              },
-            ws.receive()
-              .map { case t: Text =>
-                t.payload
-              },
-            ws.receive()
-              .map { case t: Text =>
-                t.payload
-              })
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                })
+        })
+        .send(backend)
+        .body
+
+    Thread.sleep(100)
+
+    val jmapGuiceProbe: JmapGuiceProbe = server.getProbe(classOf[JmapGuiceProbe])
+    val emailState: String = jmapGuiceProbe.getLatestEmailState(accountId).getValue.toString
+    val mailboxState: String = jmapGuiceProbe.getLatestMailboxState(accountId).getValue.toString
+
+    val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(3) // email notification + mailbox notification + API response
+      .contains(mailboxStateChange, emailStateChange)
+  }
+
+  @Test
+  def dataTypesShouldDefaultToAll(server: GuiceJamesServer): Unit = {
+    val bobPath = MailboxPath.inbox(BOB)
+    val accountId: AccountId = AccountId.fromUsername(BOB)
+    val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+
+    Thread.sleep(100)
+
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": null
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "@type": "Request",
+                 |  "requestId": "req-36",
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "create": {
+                 |        "aaaaaa":{
+                 |          "mailboxIds": {
+                 |             "${mailboxId.serialize}": true
+                 |          }
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            List(
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                })
         })
         .send(backend)
         .body
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index 101b592..73ab7e2 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -24,6 +24,10 @@ import org.apache.james.events.Event
 import org.apache.james.events.Event.EventId
 import org.apache.james.jmap.core.{AccountId, State, StateChange}
 
+object TypeName {
+  val ALL: Set[TypeName] = Set(EmailTypeName, MailboxTypeName)
+}
+
 sealed trait TypeName {
   def asMap(maybeState: Option[State]): Map[TypeName, State] =
     maybeState.map(state => Map[TypeName, State](this -> state))
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
index dd40f12..90ca138 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
@@ -43,4 +43,4 @@ case class StateChange(changes: Map[AccountId, TypeState]) extends WebSocketOutb
     .map(StateChange)
 }
 
-case class WebSocketPushEnable(dataTypes: Set[TypeName]) extends WebSocketInboundMessage
\ No newline at end of file
+case class WebSocketPushEnable(dataTypes: Option[Set[TypeName]]) extends WebSocketInboundMessage
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
index bd038a5..d6d2c40 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
@@ -30,7 +30,7 @@ import javax.inject.{Inject, Named}
 import org.apache.james.events.{EventBus, Registration}
 import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
 import org.apache.james.jmap.JMAPUrls.JMAP_WS
-import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener}
+import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener, TypeName}
 import org.apache.james.jmap.core.{ProblemDetails, RequestId, WebSocketError, WebSocketOutboundMessage, WebSocketPushEnable, WebSocketRequest, WebSocketResponse}
 import org.apache.james.jmap.http.rfc8621.InjectionKeys
 import org.apache.james.jmap.http.{Authenticator, UserProvisioning}
@@ -129,7 +129,7 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
               .`then`()
           case pushEnable: WebSocketPushEnable =>
             SMono(eventBus.register(
-                StateChangeListener(pushEnable.dataTypes, clientContext.outbound),
+                StateChangeListener(pushEnable.dataTypes.getOrElse(TypeName.ALL), clientContext.outbound),
                 AccountIdRegistrationKey.of(clientContext.session.getUser)))
               .doOnNext(newRegistration => clientContext.withRegistration(newRegistration))
               .`then`()


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


[james-project] 07/33: [REFACTORING] Get rid of some JUNIT 4 usages in mailbox-plugin-spamassassin tests

Posted by bt...@apache.org.
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 8e6e7d387fc6fd65e57c91a548b4b8055255a0b5
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 10:07:56 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in mailbox-plugin-spamassassin tests
---
 .../spamassassin/SpamAssassinConfigurationLoaderTest.java     | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/server/container/guice/mailbox-plugin-spamassassin/src/test/java/org/apache/james/modules/spamassassin/SpamAssassinConfigurationLoaderTest.java b/server/container/guice/mailbox-plugin-spamassassin/src/test/java/org/apache/james/modules/spamassassin/SpamAssassinConfigurationLoaderTest.java
index fff2bc4..7c056b1 100644
--- a/server/container/guice/mailbox-plugin-spamassassin/src/test/java/org/apache/james/modules/spamassassin/SpamAssassinConfigurationLoaderTest.java
+++ b/server/container/guice/mailbox-plugin-spamassassin/src/test/java/org/apache/james/modules/spamassassin/SpamAssassinConfigurationLoaderTest.java
@@ -23,30 +23,29 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.commons.configuration2.PropertiesConfiguration;
 import org.apache.james.mailbox.spamassassin.SpamAssassinConfiguration;
 import org.apache.james.util.Host;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class SpamAssassinConfigurationLoaderTest {
-
     @Test
-    public void isEnableShouldReturnFalseWhenDisable() {
+    void isEnableShouldReturnFalseWhenDisable() {
         SpamAssassinConfiguration configuration = SpamAssassinConfigurationLoader.disable();
         assertThat(configuration.isEnable()).isFalse();
     }
 
     @Test
-    public void isEnableShouldReturnTrueWhenEnable() {
+    void isEnableShouldReturnTrueWhenEnable() {
         SpamAssassinConfiguration configuration = SpamAssassinConfigurationLoader.fromProperties(new PropertiesConfiguration());
         assertThat(configuration.isEnable()).isTrue();
     }
 
     @Test
-    public void hostShouldReturnDefaultWhenConfigurationIsEmpty() {
+    void hostShouldReturnDefaultWhenConfigurationIsEmpty() {
         SpamAssassinConfiguration configuration = SpamAssassinConfigurationLoader.fromProperties(new PropertiesConfiguration());
         assertThat(configuration.getHost().get()).isEqualTo(Host.from(SpamAssassinConfigurationLoader.DEFAULT_HOST, SpamAssassinConfigurationLoader.DEFAULT_PORT));
     }
 
     @Test
-    public void hostShouldReturnCustomWhenConfigurationIsProvided() {
+    void hostShouldReturnCustomWhenConfigurationIsProvided() {
         PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
         String host = "10.69.1.123";
         propertiesConfiguration.addProperty("spamassassin.host", host);


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


[james-project] 12/33: [REFACTORING] Get rid of some JUNIT 4 usages in mailrepository-memory tests

Posted by bt...@apache.org.
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 2520ab639f624cb04cca42259e67ec4885d61e48
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 12:32:31 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in mailrepository-memory tests
---
 .../memory/MemoryMailRepositoryStoreTest.java      | 62 +++++++++++-----------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryStoreTest.java b/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryStoreTest.java
index 7f8692e..2ed4997 100644
--- a/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryStoreTest.java
+++ b/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryStoreTest.java
@@ -36,10 +36,10 @@ import org.apache.james.server.core.configuration.FileConfigurationProvider;
 import org.apache.james.server.core.filesystem.FileSystemImpl;
 import org.apache.james.util.concurrency.ConcurrentTestRunner;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class MemoryMailRepositoryStoreTest {
+class MemoryMailRepositoryStoreTest {
     private static final MailRepositoryUrl MEMORY1_REPO = MailRepositoryUrl.from("memory1://repo");
     private static final MailRepositoryUrl UNKNOWN_PROTOCOL_REPO = MailRepositoryUrl.from("toto://repo");
     private static final MailRepositoryUrl MEMORY2_REPO = MailRepositoryUrl.from("memory2://repo");
@@ -52,8 +52,8 @@ public class MemoryMailRepositoryStoreTest {
     private FileSystemImpl fileSystem;
     private Configuration configuration;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         loader = new SimpleMailRepositoryLoader();
         configuration = Configuration.builder()
             .workingDirectory("../")
@@ -69,31 +69,32 @@ public class MemoryMailRepositoryStoreTest {
         repositoryStore.init();
     }
 
-    @Test(expected = MailRepositoryStore.UnsupportedRepositoryStoreException.class)
-    public void selectingANonRegisteredProtocolShouldFail() {
-        repositoryStore.select(MailRepositoryUrl.from("proto://repo"));
+    @Test
+    void selectingANonRegisteredProtocolShouldFail() {
+        assertThatThrownBy(() -> repositoryStore.select(MailRepositoryUrl.from("proto://repo")))
+            .isInstanceOf(MailRepositoryStore.UnsupportedRepositoryStoreException.class);
     }
 
     @Test
-    public void selectingARegisteredProtocolShouldWork() {
+    void selectingARegisteredProtocolShouldWork() {
         assertThat(repositoryStore.select(MEMORY1_REPO))
             .isInstanceOf(MemoryMailRepository.class);
     }
 
     @Test
-    public void selectingTwiceARegisteredProtocolWithSameDestinationShouldReturnTheSameResult() {
+    void selectingTwiceARegisteredProtocolWithSameDestinationShouldReturnTheSameResult() {
         assertThat(repositoryStore.select(MEMORY1_REPO))
             .isEqualTo(repositoryStore.select(MEMORY1_REPO));
     }
 
     @Test
-    public void selectingTwiceARegisteredProtocolWithDifferentDestinationShouldReturnDifferentResults() {
+    void selectingTwiceARegisteredProtocolWithDifferentDestinationShouldReturnDifferentResults() {
         assertThat(repositoryStore.select(MEMORY1_REPO))
             .isNotEqualTo(repositoryStore.select(MailRepositoryUrl.from("memory1://repo1")));
     }
 
     @Test
-    public void configureShouldThrowWhenNonValidClassesAreProvided() throws Exception {
+    void configureShouldThrowWhenNonValidClassesAreProvided() throws Exception {
         MailRepositoryStoreConfiguration storeConfiguration = MailRepositoryStoreConfiguration.parse(
             new FileConfigurationProvider(fileSystem, configuration).getConfiguration("fakemailrepositorystore"));
 
@@ -107,7 +108,7 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void configureShouldNotThrowOnEmptyConfiguration() throws Exception {
+    void configureShouldNotThrowOnEmptyConfiguration() throws Exception {
         MailRepositoryStoreConfiguration configuration = MailRepositoryStoreConfiguration.parse(new BaseHierarchicalConfiguration());
 
         repositoryStore = new MemoryMailRepositoryStore(urlStore, loader, configuration);
@@ -116,12 +117,12 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getUrlsShouldBeEmptyIfNoSelectWerePerformed() {
+    void getUrlsShouldBeEmptyIfNoSelectWerePerformed() {
         assertThat(repositoryStore.getUrls()).isEmpty();
     }
 
     @Test
-    public void getUrlsShouldReturnUsedUrls() {
+    void getUrlsShouldReturnUsedUrls() {
         MailRepositoryUrl url1 = MailRepositoryUrl.from("memory1://repo1");
         MailRepositoryUrl url2 = MailRepositoryUrl.from("memory1://repo2");
         MailRepositoryUrl url3 = MailRepositoryUrl.from("memory1://repo3");
@@ -132,19 +133,19 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getUrlsResultsShouldNotBeDuplicated() {
+    void getUrlsResultsShouldNotBeDuplicated() {
         repositoryStore.select(MEMORY1_REPO);
         repositoryStore.select(MEMORY1_REPO);
         assertThat(repositoryStore.getUrls()).containsExactly(MEMORY1_REPO);
     }
 
     @Test
-    public void getPathsShouldBeEmptyIfNoSelectWerePerformed() {
+    void getPathsShouldBeEmptyIfNoSelectWerePerformed() {
         assertThat(repositoryStore.getPaths()).isEmpty();
     }
 
     @Test
-    public void getPathsShouldReturnUsedUrls() {
+    void getPathsShouldReturnUsedUrls() {
         MailRepositoryPath path1 = MailRepositoryPath.from("repo1");
         MailRepositoryPath path2 = MailRepositoryPath.from("repo1");
         MailRepositoryPath path3 = MailRepositoryPath.from("repo1");
@@ -155,27 +156,27 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getPathsResultsShouldNotBeDuplicatedWithTheSameProtocol() {
+    void getPathsResultsShouldNotBeDuplicatedWithTheSameProtocol() {
         repositoryStore.select(MEMORY1_REPO);
         repositoryStore.select(MEMORY1_REPO);
         assertThat(repositoryStore.getPaths()).containsExactly(PATH_REPO);
     }
 
     @Test
-    public void getPathsResultsShouldNotBeDuplicatedWithDifferentProtocols() {
+    void getPathsResultsShouldNotBeDuplicatedWithDifferentProtocols() {
         repositoryStore.select(MEMORY1_REPO);
         repositoryStore.select(MEMORY2_REPO);
         assertThat(repositoryStore.getPaths()).containsExactly(PATH_REPO);
     }
 
     @Test
-    public void getShouldReturnEmptyWhenUrlNotInUse() {
+    void getShouldReturnEmptyWhenUrlNotInUse() {
         assertThat(repositoryStore.get(MEMORY1_REPO))
             .isEmpty();
     }
 
     @Test
-    public void getShouldReturnRepositoryWhenUrlExists() {
+    void getShouldReturnRepositoryWhenUrlExists() {
         urlStore.add(MEMORY1_REPO);
 
         assertThat(repositoryStore.get(MEMORY1_REPO))
@@ -183,7 +184,7 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getByPathShouldReturnRepositoryWhenUrlExists() {
+    void getByPathShouldReturnRepositoryWhenUrlExists() {
         urlStore.add(MEMORY1_REPO);
 
         assertThat(repositoryStore.getByPath(MEMORY1_REPO.getPath()))
@@ -191,7 +192,7 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getShouldReturnPreviouslyCreatedMailRepository() {
+    void getShouldReturnPreviouslyCreatedMailRepository() {
         MailRepository mailRepository = repositoryStore.select(MEMORY1_REPO);
 
         assertThat(repositoryStore.get(MEMORY1_REPO))
@@ -199,13 +200,13 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getByPathShouldReturnEmptyWhenUrlNotInUse() {
+    void getByPathShouldReturnEmptyWhenUrlNotInUse() {
         assertThat(repositoryStore.getByPath(PATH_REPO))
             .isEmpty();
     }
 
     @Test
-    public void getByPathShouldReturnPreviouslyCreatedMatchingMailRepository() {
+    void getByPathShouldReturnPreviouslyCreatedMatchingMailRepository() {
         MailRepository mailRepository = repositoryStore.select(MEMORY1_REPO);
 
         assertThat(repositoryStore.getByPath(PATH_REPO))
@@ -213,7 +214,7 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getByPathShouldReturnPreviouslyCreatedMatchingMailRepositories() {
+    void getByPathShouldReturnPreviouslyCreatedMatchingMailRepositories() {
         MailRepository mailRepositoryFile = repositoryStore.select(MEMORY1_REPO);
         MailRepository mailRepositoryArbitrary = repositoryStore.select(MEMORY2_REPO);
 
@@ -223,7 +224,7 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void getByPathShouldReturnEmptyWhenNoMailRepositoriesAreMatching() {
+    void getByPathShouldReturnEmptyWhenNoMailRepositoriesAreMatching() {
         repositoryStore.select(MEMORY1_REPO);
 
         assertThat(repositoryStore.getByPath(MailRepositoryPath.from("unknown")))
@@ -231,7 +232,7 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void selectShouldNotReturnDifferentResultsWhenUsedInAConcurrentEnvironment() throws Exception {
+    void selectShouldNotReturnDifferentResultsWhenUsedInAConcurrentEnvironment() throws Exception {
         MailRepositoryUrl url = MailRepositoryUrl.from("memory1://repo");
         int threadCount = 10;
 
@@ -251,10 +252,9 @@ public class MemoryMailRepositoryStoreTest {
     }
 
     @Test
-    public void selectShouldNotAddUrlWhenProtocolDoNotExist() {
+    void selectShouldNotAddUrlWhenProtocolDoNotExist() {
         assertThatThrownBy(() -> repositoryStore.select(UNKNOWN_PROTOCOL_REPO));
 
         assertThat(urlStore.listDistinct()).isEmpty();
     }
-
 }


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


[james-project] 26/33: JAMES-3491 Enabling push should not reject unhandled data types

Posted by bt...@apache.org.
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 ebc6e0e3aa62c210b5bd00c1a3711c9ef3495081
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 12:09:18 2021 +0700

    JAMES-3491 Enabling push should not reject unhandled data types
    
    Rejection of specified data types we do not yet send notifications for would cause a breaking behaviours in clients registrating them.
---
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 70 ++++++++++++++++++++++
 .../org/apache/james/jmap/change/StateChange.scala | 17 +++++-
 .../james/jmap/json/ResponseSerializer.scala       |  7 ++-
 3 files changed, 92 insertions(+), 2 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index 750c12f..5fd55a0 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -502,6 +502,76 @@ trait WebSocketContract {
   }
 
   @Test
+  // For client compatibility purposes
+  def specifiedUnHandledDataTypesShouldNotBeRejected(server: GuiceJamesServer): Unit = {
+    val bobPath = MailboxPath.inbox(BOB)
+    val accountId: AccountId = AccountId.fromUsername(BOB)
+    val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+
+    Thread.sleep(100)
+
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["Mailbox", "Email", "VacationResponse", "Thread", "Identity", "EmailSubmission", "EmailDelivery"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "@type": "Request",
+                 |  "requestId": "req-36",
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "create": {
+                 |        "aaaaaa":{
+                 |          "mailboxIds": {
+                 |             "${mailboxId.serialize}": true
+                 |          }
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            List(
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                })
+        })
+        .send(backend)
+        .body
+
+    Thread.sleep(100)
+
+    val jmapGuiceProbe: JmapGuiceProbe = server.getProbe(classOf[JmapGuiceProbe])
+    val emailState: String = jmapGuiceProbe.getLatestEmailState(accountId).getValue.toString
+    val mailboxState: String = jmapGuiceProbe.getLatestMailboxState(accountId).getValue.toString
+
+    val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(3) // email notification + mailbox notification + API response
+      .contains(mailboxStateChange, emailStateChange)
+  }
+
+  @Test
   def dataTypesShouldDefaultToAll(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
     val accountId: AccountId = AccountId.fromUsername(BOB)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index 73ab7e2..faffe49 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -25,7 +25,7 @@ import org.apache.james.events.Event.EventId
 import org.apache.james.jmap.core.{AccountId, State, StateChange}
 
 object TypeName {
-  val ALL: Set[TypeName] = Set(EmailTypeName, MailboxTypeName)
+  val ALL: Set[TypeName] = Set(EmailTypeName, MailboxTypeName, ThreadTypeName, IdentityTypeName, EmailSubmissionTypeName, EmailDeliveryTypeName)
 }
 
 sealed trait TypeName {
@@ -41,6 +41,21 @@ case object MailboxTypeName extends TypeName {
 case object EmailTypeName extends TypeName {
   override val asString: String = "Email"
 }
+case object ThreadTypeName extends TypeName {
+  override val asString: String = "Thread"
+}
+case object IdentityTypeName extends TypeName {
+  override val asString: String = "Identity"
+}
+case object EmailSubmissionTypeName extends TypeName {
+  override val asString: String = "EmailSubmission"
+}
+case object EmailDeliveryTypeName extends TypeName {
+  override val asString: String = "EmailDelivery"
+}
+case object VacationResponseTypeName extends TypeName {
+  override val asString: String = "VacationResponse"
+}
 
 case class TypeState(changes: Map[TypeName, State]) {
 
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
index b1454c6..042d4d8 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
@@ -25,7 +25,7 @@ import java.net.URL
 import eu.timepit.refined.refineV
 import io.netty.handler.codec.http.HttpResponseStatus
 import org.apache.james.core.Username
-import org.apache.james.jmap.change.{EmailTypeName, MailboxTypeName, TypeName, TypeState}
+import org.apache.james.jmap.change.{EmailDeliveryTypeName, EmailSubmissionTypeName, EmailTypeName, IdentityTypeName, MailboxTypeName, ThreadTypeName, TypeName, TypeState, VacationResponseTypeName}
 import org.apache.james.jmap.core
 import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
 import org.apache.james.jmap.core.Id.IdConstraint
@@ -189,6 +189,11 @@ object ResponseSerializer {
   private implicit val typeNameReads: Reads[TypeName] = {
     case JsString(MailboxTypeName.asString) => JsSuccess(MailboxTypeName)
     case JsString(EmailTypeName.asString) => JsSuccess(EmailTypeName)
+    case JsString(ThreadTypeName.asString) => JsSuccess(ThreadTypeName)
+    case JsString(IdentityTypeName.asString) => JsSuccess(IdentityTypeName)
+    case JsString(EmailSubmissionTypeName.asString) => JsSuccess(EmailSubmissionTypeName)
+    case JsString(EmailDeliveryTypeName.asString) => JsSuccess(EmailDeliveryTypeName)
+    case JsString(VacationResponseTypeName.asString) => JsSuccess(VacationResponseTypeName)
     case _ => JsError("Expecting a JsString as typeName")
   }
   private implicit val webSocketPushEnableReads: Reads[WebSocketPushEnable] = Json.reads[WebSocketPushEnable]


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


[james-project] 29/33: JAMES-3491 Add VacationResponse push notification support

Posted by bt...@apache.org.
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 438191a3bc3d7d4569395a586ac68c0fb97f90e4
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 16:01:17 2021 +0700

    JAMES-3491 Add VacationResponse push notification support
---
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 55 ++++++++++++++++++++++
 .../james/jmap/change/JmapEventSerializer.scala    |  3 ++
 .../james/jmap/change/MailboxChangeListener.scala  |  2 +
 .../org/apache/james/jmap/change/StateChange.scala |  9 +++-
 .../jmap/method/VacationResponseSetMethod.scala    | 24 ++++++++--
 .../change/StateChangeEventSerializerTest.scala    |  5 +-
 .../jmap/change/StateChangeListenerTest.scala      | 12 +++--
 7 files changed, 101 insertions(+), 9 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index c8897ba..b8f443a 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -515,6 +515,61 @@ trait WebSocketContract {
 
   @Test
   @Timeout(180)
+  def pushShouldHandleVacationResponses(server: GuiceJamesServer): Unit = {
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["VacationResponse"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "@type": "Request",
+                 |  "requestId": "req-36",
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail", "urn:ietf:params:jmap:vacationresponse"],
+                 |  "methodCalls": [
+                 |    ["VacationResponse/set", {
+                 |      "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+                 |      "update": {
+                 |        "singleton": {
+                 |          "isEnabled": true,
+                 |          "fromDate": "2014-10-30T14:12:00Z",
+                 |          "toDate": "2014-11-30T14:12:00Z",
+                 |          "subject": "I am in vacation",
+                 |          "textBody": "I'm currently enjoying life. Please disturb me later",
+                 |          "htmlBody": "I'm currently enjoying <b>life</b>. <br/>Please disturb me later"
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            List(
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                })
+        })
+        .send(backend)
+        .body
+
+    assertThat(response.toOption.get.asJava).hasSize(2) // vacation notification + API response
+    assertThat(response.toOption.get.filter(s => s.contains(""""@type":"StateChange"""")).asJava)
+      .hasSize(1)
+      .allMatch(s => s.contains("VacationResponse"))
+  }
+
+  @Test
+  @Timeout(180)
   // For client compatibility purposes
   def specifiedUnHandledDataTypesShouldNotBeRejected(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
index 7c38b41..b794bc2 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
@@ -44,18 +44,21 @@ object StateChangeEventDTO {
     getUsername = event.username.asString(),
     getMailboxState = event.mailboxState.map(_.value).map(_.toString).toJava,
     getEmailState = event.emailState.map(_.value).map(_.toString).toJava,
+    getVacationResponseState = event.vacationResponseState.map(_.value).map(_.toString).toJava,
     getEmailDeliveryState = event.emailDeliveryState.map(_.value).map(_.toString).toJava)
 }
 
 case class StateChangeEventDTO(@JsonProperty("type") getType: String,
                                @JsonProperty("eventId") getEventId: String,
                                @JsonProperty("username") getUsername: String,
+                               @JsonProperty("vacationResponseState") getVacationResponseState: Optional[String],
                                @JsonProperty("mailboxState") getMailboxState: Optional[String],
                                @JsonProperty("emailState") getEmailState: Optional[String],
                                @JsonProperty("emailDeliveryState") getEmailDeliveryState: Optional[String]) extends EventDTO {
   def toDomainObject: StateChangeEvent = StateChangeEvent(
     eventId = EventId.of(getEventId),
     username = Username.of(getUsername),
+    vacationResponseState = getVacationResponseState.toScala.map(State.fromStringUnchecked),
     mailboxState = getMailboxState.toScala.map(State.fromStringUnchecked),
     emailState = getEmailState.toScala.map(State.fromStringUnchecked),
     emailDeliveryState = getEmailDeliveryState.toScala.map(State.fromStringUnchecked))
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
index ad68fb2..8a5f7e2 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
@@ -126,6 +126,7 @@ case class MailboxChangeListener @Inject() (@Named(InjectionKeys.JMAP) eventBus:
     case emailChange: EmailChange => StateChangeEvent(
       eventId = EventId.random(),
       username = Username.of(emailChange.getAccountId.getIdentifier),
+      vacationResponseState = None,
       emailState = Some(State.fromJava(emailChange.getState)),
       emailDeliveryState = Some(State.fromJava(emailChange.getState))
         .filter(_ => !emailChange.getCreated.isEmpty),
@@ -133,6 +134,7 @@ case class MailboxChangeListener @Inject() (@Named(InjectionKeys.JMAP) eventBus:
     case mailboxChange: MailboxChange => StateChangeEvent(
       eventId = EventId.random(),
       username = Username.of(mailboxChange.getAccountId.getIdentifier),
+      vacationResponseState = None,
       emailState = None,
       emailDeliveryState = None,
       mailboxState = Some(State.fromJava(mailboxChange.getState)))
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index c53792a..08c2811 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -68,6 +68,7 @@ case class TypeState(changes: Map[TypeName, State]) {
 
 case class StateChangeEvent(eventId: EventId,
                             username: Username,
+                            vacationResponseState: Option[State],
                             mailboxState: Option[State],
                             emailState: Option[State],
                             emailDeliveryState: Option[State]) extends Event {
@@ -76,13 +77,17 @@ case class StateChangeEvent(eventId: EventId,
       failure => throw new IllegalArgumentException(failure),
       success => success) ->
       TypeState(
-        MailboxTypeName.asMap(mailboxState) ++
+        VacationResponseTypeName.asMap(vacationResponseState) ++
+          MailboxTypeName.asMap(mailboxState) ++
           EmailDeliveryTypeName.asMap(emailDeliveryState) ++
           EmailTypeName.asMap(emailState))))
 
   override val getUsername: Username = username
 
-  override val isNoop: Boolean = mailboxState.isEmpty && emailState.isEmpty
+  override val isNoop: Boolean = mailboxState.isEmpty &&
+    emailState.isEmpty &&
+    vacationResponseState.isEmpty &&
+    emailDeliveryState.isEmpty
 
   override val getEventId: EventId = eventId
 }
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala
index 4f0ff2a..feccf06 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala
@@ -19,11 +19,17 @@
 
 package org.apache.james.jmap.method
 
+import java.util.UUID
+
 import eu.timepit.refined.auto._
-import javax.inject.Inject
+import javax.inject.{Inject, Named}
+import org.apache.james.events.Event.EventId
+import org.apache.james.events.EventBus
+import org.apache.james.jmap.InjectionKeys
 import org.apache.james.jmap.api.model.AccountId
 import org.apache.james.jmap.api.vacation.{VacationPatch, VacationRepository}
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL, JMAP_VACATION_RESPONSE}
+import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeEvent}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_VACATION_RESPONSE}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.SetError.SetErrorDescription
 import org.apache.james.jmap.core.{Invocation, State}
@@ -70,7 +76,8 @@ object VacationResponseSetMethod {
   val VACATION_RESPONSE_PATCH_OBJECT_KEY = "singleton"
 }
 
-class VacationResponseSetMethod @Inject()(vacationRepository: VacationRepository,
+class VacationResponseSetMethod @Inject()(@Named(InjectionKeys.JMAP) eventBus: EventBus,
+                                          vacationRepository: VacationRepository,
                                           val metricFactory: MetricFactory,
                                           val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[VacationResponseSetRequest] {
   override val methodName: MethodName = MethodName("VacationResponse/set")
@@ -79,6 +86,17 @@ class VacationResponseSetMethod @Inject()(vacationRepository: VacationRepository
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: VacationResponseSetRequest): SMono[InvocationWithContext] = {
     update(mailboxSession, request)
       .map(updateResult => createResponse(invocation.invocation, request, updateResult))
+      .flatMap(next => {
+        val event = StateChangeEvent(eventId = EventId.random(),
+          mailboxState = None,
+          emailState = None,
+          emailDeliveryState = None,
+          username = mailboxSession.getUser,
+          vacationResponseState = Some(State(UUID.randomUUID())))
+        val accountId = AccountId.fromUsername(mailboxSession.getUser)
+        SMono(eventBus.dispatch(event, AccountIdRegistrationKey(accountId)))
+          .`then`(SMono.just(next))
+      })
       .map(InvocationWithContext(_, invocation.processingContext))
   }
 
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
index 7f51aa8..07da1c5 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeEventSerializerTest.scala
@@ -36,6 +36,7 @@ object StateChangeEventSerializerTest {
     username = USERNAME,
     mailboxState = Some(State.INSTANCE),
     emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")),
+    vacationResponseState = Some(State.fromStringUnchecked("2d9f1b12-3333-4444-5555-0106fb53a943")),
     emailDeliveryState = Some(State.fromStringUnchecked("2d9f1b12-0000-1111-3333-0106fb53a943")))
   val EVENT_JSON: String =
     """{
@@ -44,13 +45,15 @@ object StateChangeEventSerializerTest {
       |  "mailboxState":"2c9f1b12-b35a-43e6-9af2-0106fb53a943",
       |  "emailState":"2d9f1b12-b35a-43e6-9af2-0106fb53a943",
       |  "emailDeliveryState":"2d9f1b12-0000-1111-3333-0106fb53a943",
+      |  "vacationResponseState":"2d9f1b12-3333-4444-5555-0106fb53a943",
       |  "type":"org.apache.james.jmap.change.StateChangeEvent"
       |}""".stripMargin
   val EVENT_NO_DELIVERY: StateChangeEvent = StateChangeEvent(eventId = EVENT_ID,
     username = USERNAME,
     mailboxState = Some(State.INSTANCE),
     emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")),
-    emailDeliveryState = None)
+    emailDeliveryState = None,
+    vacationResponseState = None)
   val EVENT_JSON_NO_DELIVERY: String =
     """{
       |  "eventId":"6e0dd59d-660e-4d9b-b22f-0354479f47b4",
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
index efa5775..2b504bf 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
@@ -40,7 +40,9 @@ class StateChangeListenerTest {
     val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = Some(mailboxState),
-      emailState = Some(emailState))
+      emailState = Some(emailState),
+      vacationResponseState = None,
+      emailDeliveryState = None)
     val listener = StateChangeListener(Set(MailboxTypeName, EmailTypeName), sink)
 
     SMono(listener.reactiveEvent(event)).subscribeOn(Schedulers.elastic()).block()
@@ -58,7 +60,9 @@ class StateChangeListenerTest {
     val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = Some(mailboxState),
-      emailState = Some(emailState))
+      emailState = Some(emailState),
+      vacationResponseState = None,
+      emailDeliveryState = None)
     val listener = StateChangeListener(Set(MailboxTypeName), sink)
 
     SMono(listener.reactiveEvent(event)).subscribeOn(Schedulers.elastic()).block()
@@ -75,7 +79,9 @@ class StateChangeListenerTest {
     val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = None,
-      emailState = Some(emailState))
+      emailState = Some(emailState),
+      vacationResponseState = None,
+      emailDeliveryState = None)
     val listener = StateChangeListener(Set(MailboxTypeName), sink)
 
     SMono(listener.reactiveEvent(event)).subscribeOn(Schedulers.elastic()).block()


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


[james-project] 30/33: JAMES-3491 Document that we implement WebSocket transport for JMAP (RFC-8887)

Posted by bt...@apache.org.
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 8fbd9fd09471fb32c34308c9a98273cc270cdb44
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 16:12:55 2021 +0700

    JAMES-3491 Document that we implement WebSocket transport for JMAP (RFC-8887)
---
 docs/modules/servers/pages/distributed/configure/jmap.adoc | 3 ++-
 src/site/xdoc/server/config-jmap.xml                       | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/docs/modules/servers/pages/distributed/configure/jmap.adoc b/docs/modules/servers/pages/distributed/configure/jmap.adoc
index 8c29504..78f47c7 100644
--- a/docs/modules/servers/pages/distributed/configure/jmap.adoc
+++ b/docs/modules/servers/pages/distributed/configure/jmap.adoc
@@ -81,7 +81,8 @@ The public key can be referenced as `jwt.publickeypem.url` of the `jmap.properti
 == Annotated specification
 
 The [annotated documentation](https://github.com/apache/james-project/tree/master/server/protocols/jmap-rfc-8621/doc/specs/spec)
-presents the limits of the JMAP RFC-8621 implementation part of the Apache James project.
+presents the limits of the JMAP RFC-8621 implementation part of the Apache James project. We furthermore implement
+[JSON Meta Application Protocol (JMAP) Subprotocol for WebSocket](https://tools.ietf.org/html/rfc8887).
 
 Some methods / types are not yet implemented, some implementations are naive, and the PUSH is not supported yet.
 
diff --git a/src/site/xdoc/server/config-jmap.xml b/src/site/xdoc/server/config-jmap.xml
index b006481..703e436 100644
--- a/src/site/xdoc/server/config-jmap.xml
+++ b/src/site/xdoc/server/config-jmap.xml
@@ -107,7 +107,8 @@
 
             <subsection name="Annotated specification">
                 <p>The <a href="https://github.com/apache/james-project/tree/master/server/protocols/jmap-rfc-8621/doc/specs/spec">annotated documentation</a>
-                presents the limits of the JMAP RFC-8621 implementation part of the Apache James project.</p>
+                presents the limits of the JMAP RFC-8621 implementation part of the Apache James project. We furthermore implement
+                    <a href="https://tools.ietf.org/html/rfc8887">JSON Meta Application Protocol (JMAP) Subprotocol for WebSocket</a>.</p>
 
                 <p>Some methods / types are not yet implemented, some implementations are naive, and the PUSH is not supported yet.</p>
 


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


[james-project] 09/33: [REFACTORING] Get rid of some JUNIT 4 usages in server-mailets tests

Posted by bt...@apache.org.
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 cbe33c239c5079e7380d9f6014a45a26281756b9
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 12:19:18 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in server-mailets tests
---
 .../RecipientRewriteTableProcessorTest.java        |  58 +++----
 .../mailets/RecipientRewriteTableTest.java         |  38 +++--
 .../transport/mailets/ResourceLocatorTest.java     |  15 +-
 .../james/transport/mailets/WithPriorityTest.java  |  26 ++--
 .../mailets/WithStorageDirectiveTest.java          |  38 +++--
 .../mailets/delivery/LocalDeliveryTest.java        |  14 +-
 .../mailets/delivery/MailDispatcherTest.java       |  30 ++--
 .../mailets/delivery/SieveIntegrationTest.java     | 170 ++++++++++-----------
 .../mailets/delivery/SimpleMailStoreTest.java      |  17 +--
 .../mailets/jsieve/DiscardActionTest.java          |  13 +-
 .../managesieve/ManageSieveMailetTestCase.java     |  98 ++++++------
 .../redirect/LoadedOnceInitParametersTest.java     |   7 +-
 .../redirect/NotifyMailetInitParametersTest.java   |  99 ++++++------
 .../mailets/redirect/NotifyMailetsMessageTest.java |  61 ++++----
 .../redirect/RedirectMailetInitParametersTest.java |  15 +-
 .../mailets/redirect/SpecialAddressTest.java       |  27 ++--
 ...dressesArrayToMailAddressListConverterTest.java |  14 +-
 .../mailets/remote/delivery/BouncerTest.java       |  48 +++---
 .../remote/delivery/DeliveryRetryHelperTest.java   |  18 +--
 .../mailets/remote/delivery/MailDelivrerTest.java  |  54 +++----
 .../remote/delivery/RemoteDeliveryRunningTest.java |  19 ++-
 .../remote/delivery/RemoteDeliveryTest.java        |  20 +--
 .../transport/matchers/AtLeastPriorityTest.java    |  16 +-
 .../transport/matchers/AtMostPriorityTest.java     |  16 +-
 .../james/transport/matchers/HasPriorityTest.java  |  12 +-
 .../transport/matchers/InSpammerBlacklistTest.java |  12 +-
 .../transport/matchers/IsMarkedAsSpamTest.java     |  23 ++-
 .../james/transport/matchers/IsOverQuotaTest.java  |  20 +--
 .../transport/matchers/IsSenderInRRTLoopTest.java  |  22 +--
 .../matchers/RemoteAddrInNetworkTest.java          |  14 +-
 .../matchers/RemoteAddrNotInNetworkTest.java       |  18 +--
 .../james/transport/util/RecipientsUtilsTest.java  |  21 ++-
 .../james/transport/util/ReplyToUtilsTest.java     |  11 +-
 .../james/transport/util/SenderUtilsTest.java      |  13 +-
 .../apache/james/transport/util/SizeUtilsTest.java |  23 ++-
 .../apache/james/transport/util/TosUtilsTest.java  |  21 ++-
 36 files changed, 557 insertions(+), 584 deletions(-)

diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
index 746ebef..1fa6964 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
@@ -20,8 +20,10 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.Collection;
@@ -42,14 +44,12 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class RecipientRewriteTableProcessorTest {
+class RecipientRewriteTableProcessorTest {
     private static final String NONEDOMAIN = "nonedomain";
     private static final String INVALID_MAIL_ADDRESS = "server-dev@";
 
@@ -58,15 +58,14 @@ public class RecipientRewriteTableProcessorTest {
     private MappingsImpl mappings;
     private FakeMailContext mailetContext;
     private MailAddress nonDomainWithDefaultLocal;
-
-    @Mock DomainList domainList;
-    @Mock org.apache.james.rrt.api.RecipientRewriteTable virtualTableStore;
-
+    private DomainList domainList;
+    private org.apache.james.rrt.api.RecipientRewriteTable virtualTableStore;
     private RecipientRewriteTableProcessor processor;
 
-    @Before
-    public void setup() throws Exception {
-        MockitoAnnotations.initMocks(this);
+    @BeforeEach
+    void setup() throws Exception {
+        domainList = mock(DomainList.class);
+        virtualTableStore = mock(org.apache.james.rrt.api.RecipientRewriteTable.class);
         mailetContext = FakeMailContext.defaultContext();
         processor = new RecipientRewriteTableProcessor(virtualTableStore, domainList, mailetContext);
         mail = FakeMail.builder().name("mail").sender(MailAddressFixture.ANY_AT_JAMES).build();
@@ -78,7 +77,7 @@ public class RecipientRewriteTableProcessorTest {
         nonDomainWithDefaultLocal = new MailAddress(NONEDOMAIN + "@" + MailAddressFixture.JAMES_LOCAL);
     }
 
-    @Test(expected = MessagingException.class)
+    @Test
     public void handleMappingsShouldThrowExceptionWhenMappingsContainAtLeastOneNoneDomainObjectButCannotGetDefaultDomain() throws Exception {
         when(domainList.getDefaultDomain()).thenThrow(DomainListException.class);
         mappings = MappingsImpl.builder()
@@ -87,11 +86,13 @@ public class RecipientRewriteTableProcessorTest {
                 .add(MailAddressFixture.OTHER_AT_JAMES.toString())
                 .build();
 
-        processor.handleMappings(mappings, FakeMail.builder().name("mail").sender(MailAddressFixture.ANY_AT_JAMES).build(), MailAddressFixture.OTHER_AT_JAMES);
+        assertThatThrownBy(() ->
+                processor.handleMappings(mappings, FakeMail.builder().name("mail").sender(MailAddressFixture.ANY_AT_JAMES).build(), MailAddressFixture.OTHER_AT_JAMES))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void handleMappingsShouldDoNotCareDefaultDomainWhenMappingsDoesNotContainAnyNoneDomainObject() throws Exception {
+    void handleMappingsShouldDoNotCareDefaultDomainWhenMappingsDoesNotContainAnyNoneDomainObject() throws Exception {
         when(domainList.getDefaultDomain()).thenThrow(DomainListException.class);
         mappings = MappingsImpl.builder()
                 .add(MailAddressFixture.ANY_AT_JAMES.toString())
@@ -102,7 +103,7 @@ public class RecipientRewriteTableProcessorTest {
     }
 
     @Test
-    public void handleMappingsShouldReturnTheMailAddressBelongToLocalServer() throws Exception {
+    void handleMappingsShouldReturnTheMailAddressBelongToLocalServer() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
         mappings = MappingsImpl.builder()
                 .add(MailAddressFixture.ANY_AT_JAMES.toString())
@@ -116,7 +117,7 @@ public class RecipientRewriteTableProcessorTest {
     }
 
     @Test
-    public void handleMappingsShouldReturnTheOnlyMailAddressBelongToLocalServer() throws Exception {
+    void handleMappingsShouldReturnTheOnlyMailAddressBelongToLocalServer() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES2_APACHE_ORG));
 
         mappings = MappingsImpl.builder()
@@ -132,7 +133,7 @@ public class RecipientRewriteTableProcessorTest {
     }
 
     @Test
-    public void handleMappingsShouldRemoveMappingElementWhenCannotCreateMailAddress() throws Exception {
+    void handleMappingsShouldRemoveMappingElementWhenCannotCreateMailAddress() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
         mappings = MappingsImpl.builder()
                 .add(MailAddressFixture.ANY_AT_JAMES.toString())
@@ -147,7 +148,7 @@ public class RecipientRewriteTableProcessorTest {
     }
 
     @Test
-    public void handleMappingsShouldForwardEmailToRemoteServer() throws Exception {
+    void handleMappingsShouldForwardEmailToRemoteServer() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
 
         mappings = MappingsImpl.builder()
@@ -170,7 +171,7 @@ public class RecipientRewriteTableProcessorTest {
     }
 
     @Test
-    public void handleMappingsShouldNotForwardAnyEmailToRemoteServerWhenNoMoreReomoteAddress() throws Exception {
+    void handleMappingsShouldNotForwardAnyEmailToRemoteServerWhenNoMoreReomoteAddress() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
 
         mappings = MappingsImpl.builder()
@@ -184,7 +185,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void handleMappingWithOnlyLocalRecipient() throws Exception {
+    void handleMappingWithOnlyLocalRecipient() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
 
         mappings = MappingsImpl.builder()
@@ -199,7 +200,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void handleMappingWithOnlyRemoteRecipient() throws Exception {
+    void handleMappingWithOnlyRemoteRecipient() throws Exception {
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
 
         mappings = MappingsImpl.builder()
@@ -221,7 +222,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void processShouldNotRewriteRecipientWhenVirtualTableStoreReturnNullMappings() throws Exception {
+    void processShouldNotRewriteRecipientWhenVirtualTableStoreReturnNullMappings() throws Exception {
         when(virtualTableStore.getResolvedMappings(any(String.class), any(Domain.class))).thenReturn(null);
 
         mail = FakeMail.builder()
@@ -236,7 +237,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void processShouldSendMailToAllErrorRecipientsWhenErrorMappingException() throws Exception {
+    void processShouldSendMailToAllErrorRecipientsWhenErrorMappingException() throws Exception {
         when(virtualTableStore.getResolvedMappings(eq("other"), eq(Domain.of(MailAddressFixture.JAMES_LOCAL)))).thenThrow(ErrorMappingException.class);
 
         mail = FakeMail.builder()
@@ -261,7 +262,7 @@ public class RecipientRewriteTableProcessorTest {
     }
 
     @Test
-    public void processShouldNotDuplicateRewrittenMailAddresses() throws Exception {
+    void processShouldNotDuplicateRewrittenMailAddresses() throws Exception {
         when(virtualTableStore.getResolvedMappings(eq("other"), eq(Domain.of(MailAddressFixture.JAMES_LOCAL))))
             .thenReturn(MappingsImpl.builder()
                 .add(Mapping.alias(MailAddressFixture.ANY_AT_LOCAL.asString()))
@@ -281,7 +282,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void processShouldSendMailToAllErrorRecipientsWhenRecipientRewriteTableException() throws Exception {
+    void processShouldSendMailToAllErrorRecipientsWhenRecipientRewriteTableException() throws Exception {
         when(virtualTableStore.getResolvedMappings(eq("other"), eq(Domain.of(MailAddressFixture.JAMES_LOCAL)))).thenThrow(RecipientRewriteTableException.class);
 
         mail = FakeMail.builder()
@@ -306,7 +307,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void processShouldNotSendMailWhenNoErrorRecipients() throws Exception {
+    void processShouldNotSendMailWhenNoErrorRecipients() throws Exception {
         when(virtualTableStore.getResolvedMappings(any(String.class), any(Domain.class))).thenReturn(null);
 
         mail = FakeMail.builder()
@@ -321,7 +322,7 @@ public class RecipientRewriteTableProcessorTest {
     }
     
     @Test
-    public void processShouldResetMailStateToGhostWhenCanNotBuildNewRecipient() throws Exception {
+    void processShouldResetMailStateToGhostWhenCanNotBuildNewRecipient() throws Exception {
         when(virtualTableStore.getResolvedMappings(any(String.class), any(Domain.class))).thenReturn(mappings);
         when(domainList.getDefaultDomain()).thenReturn(Domain.of(MailAddressFixture.JAMES_LOCAL));
 
@@ -336,5 +337,4 @@ public class RecipientRewriteTableProcessorTest {
         assertThat(mail.getState()).isEqualTo(Mail.GHOST);
         assertThat(mail.getRecipients()).isEmpty();
     }
-
 }
\ No newline at end of file
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableTest.java
index b79eda6..a085170 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableTest.java
@@ -19,6 +19,8 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
 
 import javax.mail.internet.MimeMessage;
 
@@ -29,32 +31,25 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class RecipientRewriteTableTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class RecipientRewriteTableTest {
     private RecipientRewriteTable mailet;
-
-    @Mock org.apache.james.rrt.api.RecipientRewriteTable virtualTableStore;
-    @Mock DomainList domainList;
-
     private FakeMail mail;
     private MimeMessage message;
     private FakeMailetConfig mailetConfig;
-    private MailetContext mailetContext;
 
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
+    @BeforeEach
+    void setUp() throws Exception {
+        DomainList domainList = mock(DomainList.class);
+        org.apache.james.rrt.api.RecipientRewriteTable virtualTableStore = mock(org.apache.james.rrt.api.RecipientRewriteTable.class);
         
         mailet = new RecipientRewriteTable(virtualTableStore, domainList);
 
         message = MimeMessageUtil.defaultMimeMessage();
 
-        mailetContext = FakeMailContext.defaultContext();
+        MailetContext mailetContext = FakeMailContext.defaultContext();
 
         mailetConfig = FakeMailetConfig.builder()
             .mailetName("vut")
@@ -65,22 +60,23 @@ public class RecipientRewriteTableTest {
     }
 
     @Test
-    public void getMailetInfoShouldReturnCorrectInformation() throws Exception {
+    void getMailetInfoShouldReturnCorrectInformation() {
         assertThat(mailet.getMailetInfo()).isEqualTo("RecipientRewriteTable Mailet");
     }
 
-    @Test(expected = NullPointerException.class)
-    public void serviceShouldThrowExceptionWithNullMail() throws Exception {
-        mailet.service(null);
+    @Test
+    public void serviceShouldThrowExceptionWithNullMail() {
+        assertThatThrownBy(() -> mailet.service(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void serviceShouldDoNothingIfAbsentMessageInMail() throws Exception {
+    void serviceShouldDoNothingIfAbsentMessageInMail() throws Exception {
         mailet.service(mail);
     }
     
     @Test
-    public void serviceShouldWork() throws Exception {
+    void serviceShouldWork() throws Exception {
         mailet.init(mailetConfig);
         mail = FakeMail.builder()
             .name("name")
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
index 8aebfe4..c630e90 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -32,11 +33,10 @@ import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.transport.mailets.jsieve.ResourceLocator;
 import org.apache.james.user.api.UsersRepository;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ResourceLocatorTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class ResourceLocatorTest {
     public static final String RECEIVER_LOCALHOST = "receiver@localhost";
     public static final Username USERNAME = Username.of(RECEIVER_LOCALHOST);
     private SieveRepository sieveRepository;
@@ -44,7 +44,7 @@ public class ResourceLocatorTest {
     private MailAddress mailAddress;
     private UsersRepository usersRepository;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         sieveRepository = mock(SieveRepository.class);
         usersRepository = mock(UsersRepository.class);
@@ -52,12 +52,13 @@ public class ResourceLocatorTest {
         mailAddress = new MailAddress(RECEIVER_LOCALHOST);
     }
 
-    @Test(expected = ScriptNotFoundException.class)
+    @Test
     public void resourceLocatorImplShouldPropagateScriptNotFound() throws Exception {
         when(sieveRepository.getActive(USERNAME)).thenThrow(new ScriptNotFoundException());
         when(usersRepository.getUsername(mailAddress)).thenReturn(Username.of(RECEIVER_LOCALHOST));
 
-        resourceLocator.get(mailAddress);
+        assertThatThrownBy(() -> resourceLocator.get(mailAddress))
+            .isInstanceOf(ScriptNotFoundException.class);
     }
 
     @Test
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithPriorityTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithPriorityTest.java
index 76fbdaf..b8b3628 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithPriorityTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithPriorityTest.java
@@ -30,21 +30,21 @@ import org.apache.mailet.MailetConfig;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class WithPriorityTest {
+class WithPriorityTest {
 
     private static final Attribute PROPERTY_PRIORITY = new Attribute(MailPrioritySupport.MAIL_PRIORITY, AttributeValue.of(7));
     private WithPriority mailet;
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() {
         mailet = new WithPriority();
     }
 
     @Test
-    public void getMailetInfoShouldReturnExpectedContent() {
+    void getMailetInfoShouldReturnExpectedContent() {
         String expected = "With Priority Mailet";
 
         String actual = mailet.getMailetInfo();
@@ -53,7 +53,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void initShouldNotThrowWhenValidPriority() {
+    void initShouldNotThrowWhenValidPriority() {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
             .mailetContext(FakeMailContext.defaultContext())
             .setProperty("priority", "7")
@@ -64,7 +64,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void initShouldThrowWhenInvalidPriority() {
+    void initShouldThrowWhenInvalidPriority() {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
             .mailetContext(FakeMailContext.defaultContext())
             .setProperty("priority", "-1")
@@ -75,7 +75,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void initShouldThrowWhenPriorityIsNotANumber() {
+    void initShouldThrowWhenPriorityIsNotANumber() {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
                 .mailetContext(FakeMailContext.defaultContext())
                 .setProperty("priority", "k")
@@ -86,7 +86,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void initShouldThrowWhenPriorityIsEmpty() {
+    void initShouldThrowWhenPriorityIsEmpty() {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
                 .mailetContext(FakeMailContext.defaultContext())
                 .setProperty("priority", "")
@@ -97,7 +97,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void initShouldThrowWhenNoPriority() {
+    void initShouldThrowWhenNoPriority() {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
                 .mailetContext(FakeMailContext.defaultContext())
                 .build();
@@ -107,7 +107,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void serviceShouldSetMailPriorityWhenNone() throws Exception {
+    void serviceShouldSetMailPriorityWhenNone() throws Exception {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
             .mailetContext(FakeMailContext.defaultContext())
             .setProperty("priority", PROPERTY_PRIORITY.getValue().value().toString())
@@ -121,7 +121,7 @@ public class WithPriorityTest {
     }
 
     @Test
-    public void serviceShouldSetMailPriorityWhenPriorityExists() throws Exception {
+    void serviceShouldSetMailPriorityWhenPriorityExists() throws Exception {
         MailetConfig mockedMailetConfig = FakeMailetConfig.builder()
             .mailetContext(FakeMailContext.defaultContext())
             .setProperty("priority", PROPERTY_PRIORITY.getValue().value().toString())
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithStorageDirectiveTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithStorageDirectiveTest.java
index e2a6a36..5338cb8 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithStorageDirectiveTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/WithStorageDirectiveTest.java
@@ -30,33 +30,29 @@ import org.apache.mailet.AttributeValue;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class WithStorageDirectiveTest {
+class WithStorageDirectiveTest {
     private static final DomainList NO_DOMAIN_LIST = null;
 
     private WithStorageDirective testee;
 
-    @Rule
-    public JUnitSoftAssertions softly = new JUnitSoftAssertions();
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         testee = new WithStorageDirective(MemoryUsersRepository.withVirtualHosting(NO_DOMAIN_LIST));
     }
 
     @Test
-    public void initShouldThrowWhenNoTargetFolderEntry() {
+    void initShouldThrowWhenNoTargetFolderEntry() {
         assertThatThrownBy(() -> testee.init(FakeMailetConfig.builder()
             .build()))
             .isInstanceOf(IllegalStateException.class);
     }
 
     @Test
-    public void initShouldThrowWhenEmptyTargetFolderEntry() {
+    void initShouldThrowWhenEmptyTargetFolderEntry() {
         assertThatThrownBy(() -> testee.init(FakeMailetConfig.builder()
             .setProperty(WithStorageDirective.TARGET_FOLDER_NAME, "")
             .build()))
@@ -64,7 +60,7 @@ public class WithStorageDirectiveTest {
     }
 
     @Test
-    public void serviceShouldAddDeliveryPathForRecipients() throws Exception {
+    void serviceShouldAddDeliveryPathForRecipients() throws Exception {
         String targetFolderName = "Spam";
         testee.init(FakeMailetConfig.builder()
             .setProperty(WithStorageDirective.TARGET_FOLDER_NAME, targetFolderName)
@@ -79,14 +75,14 @@ public class WithStorageDirectiveTest {
 
         AttributeName recipient1 = AttributeName.of("DeliveryPath_recipient1@localhost");
         AttributeName recipient2 = AttributeName.of("DeliveryPath_recipient2@localhost");
-        softly.assertThat(mail.attributes())
+        assertThat(mail.attributes())
             .containsOnly(
                 new Attribute(recipient1, AttributeValue.of(targetFolderName)),
                 new Attribute(recipient2, AttributeValue.of(targetFolderName)));
     }
 
     @Test
-    public void serviceShouldNotThrowWhenNoRecipients() throws Exception {
+    void serviceShouldNotThrowWhenNoRecipients() throws Exception {
         String targetFolderName = "Spam";
         testee.init(FakeMailetConfig.builder()
             .setProperty(WithStorageDirective.TARGET_FOLDER_NAME, targetFolderName)
@@ -104,7 +100,7 @@ public class WithStorageDirectiveTest {
     }
 
     @Test
-    public void serviceShouldOverridePreviousStorageDirectives() throws Exception {
+    void serviceShouldOverridePreviousStorageDirectives() throws Exception {
         AttributeName name1 = AttributeName.of("DeliveryPath_recipient1@localhost");
         AttributeName name2 = AttributeName.of("DeliveryPath_recipient2@localhost");
         AttributeValue<String> targetFolderName = AttributeValue.of("Spam");
@@ -122,10 +118,12 @@ public class WithStorageDirectiveTest {
 
         testee.service(mail);
 
-        softly.assertThat(mail.attributes())
-            .containsExactlyInAnyOrder(attribute1, attribute2);
-        softly.assertThat(mail.getAttribute(name1)).contains(attribute1);
-        softly.assertThat(mail.getAttribute(name2)).contains(attribute2);
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(mail.attributes())
+                .containsExactlyInAnyOrder(attribute1, attribute2);
+            softly.assertThat(mail.getAttribute(name1)).contains(attribute1);
+            softly.assertThat(mail.getAttribute(name2)).contains(attribute2);
+        });
     }
 
 }
\ No newline at end of file
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
index 44716b2..75a3b3a 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
@@ -47,13 +47,13 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 
 import reactor.core.publisher.Mono;
 
-public class LocalDeliveryTest {
+class LocalDeliveryTest {
 
     public static final String RECEIVER_DOMAIN_COM = "receiver@domain.com";
     private UsersRepository usersRepository;
@@ -62,8 +62,8 @@ public class LocalDeliveryTest {
     private LocalDelivery testee;
     private MailboxSession session;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         usersRepository = mock(UsersRepository.class);
         mailboxManager = mock(MailboxManager.class);
 
@@ -83,7 +83,7 @@ public class LocalDeliveryTest {
     }
 
     @Test
-    public void mailShouldBeWellDeliveredByDefaultToUserWhenVirtualHostingIsTurnedOn() throws Exception {
+    void mailShouldBeWellDeliveredByDefaultToUserWhenVirtualHostingIsTurnedOn() throws Exception {
         // Given
         Username username = Username.of("receiver@domain.com");
         MailboxPath inbox = MailboxPath.inbox(username);
@@ -105,7 +105,7 @@ public class LocalDeliveryTest {
     }
 
     @Test
-    public void mailShouldBeWellDeliveredByDefaultToUserWhenVirtualHostingIsTurnedOff() throws Exception {
+    void mailShouldBeWellDeliveredByDefaultToUserWhenVirtualHostingIsTurnedOff() throws Exception {
         // Given
         Username username = Username.of("receiver");
         MailboxPath inbox = MailboxPath.inbox(username);
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
index 82275b7..59b7644 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
@@ -42,13 +42,13 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.google.common.collect.ArrayListMultimap;
 
-public class MailDispatcherTest {
+class MailDispatcherTest {
     private static final String TEST_HEADER_NAME = "X-HEADER";
     private static final String VALUE_FOR_USER_1 = "value for user 1";
     private static final String VALUE_FOR_USER_2 = "value for user 2";
@@ -58,14 +58,14 @@ public class MailDispatcherTest {
     private FakeMailContext fakeMailContext;
     private MailStore mailStore;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         fakeMailContext = FakeMailContext.defaultContext();
         mailStore = mock(MailStore.class);
     }
 
     @Test
-    public void dispatchShouldStoreMail() throws Exception {
+    void dispatchShouldStoreMail() throws Exception {
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
             .mailStore(mailStore)
@@ -87,7 +87,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldConsumeMailIfSpecified() throws Exception {
+    void dispatchShouldConsumeMailIfSpecified() throws Exception {
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
             .mailStore(mailStore)
@@ -106,7 +106,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldNotConsumeMailIfNotSpecified() throws Exception {
+    void dispatchShouldNotConsumeMailIfNotSpecified() throws Exception {
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
             .mailStore(mailStore)
@@ -126,7 +126,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void errorsShouldBeWellHandled() throws Exception {
+    void errorsShouldBeWellHandled() throws Exception {
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
             .mailStore(mailStore)
@@ -162,7 +162,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldUpdateReturnPath() throws Exception {
+    void dispatchShouldUpdateReturnPath() throws Exception {
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
             .mailStore(mailStore)
@@ -186,7 +186,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldNotAddSpecificHeaderIfRecipientDoesNotMatch() throws Exception {
+    void dispatchShouldNotAddSpecificHeaderIfRecipientDoesNotMatch() throws Exception {
         AccumulatorHeaderMailStore accumulatorTestHeaderMailStore = new AccumulatorHeaderMailStore(TEST_HEADER_NAME);
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
@@ -209,7 +209,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldAddSpecificHeaderIfRecipientMatches() throws Exception {
+    void dispatchShouldAddSpecificHeaderIfRecipientMatches() throws Exception {
         AccumulatorHeaderMailStore accumulatorTestHeaderMailStore = new AccumulatorHeaderMailStore(TEST_HEADER_NAME);
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
@@ -232,7 +232,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldNotAddSpecificHeaderToOtherRecipients() throws Exception {
+    void dispatchShouldNotAddSpecificHeaderToOtherRecipients() throws Exception {
         AccumulatorHeaderMailStore accumulatorTestHeaderMailStore = new AccumulatorHeaderMailStore(TEST_HEADER_NAME);
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
@@ -257,7 +257,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldAddSpecificHeaderToEachRecipients() throws Exception {
+    void dispatchShouldAddSpecificHeaderToEachRecipients() throws Exception {
         AccumulatorHeaderMailStore accumulatorTestHeaderMailStore = new AccumulatorHeaderMailStore(TEST_HEADER_NAME);
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
@@ -283,7 +283,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldNotAlterOriginalMessageWhenPerRecipientHeaderDoesNotExist() throws Exception {
+    void dispatchShouldNotAlterOriginalMessageWhenPerRecipientHeaderDoesNotExist() throws Exception {
         AccumulatorHeaderMailStore accumulatorTestHeaderMailStore = new AccumulatorHeaderMailStore(TEST_HEADER_NAME);
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
@@ -306,7 +306,7 @@ public class MailDispatcherTest {
     }
 
     @Test
-    public void dispatchShouldNotAlterOriginalMessageWhenPerRecipientHeaderExists() throws Exception {
+    void dispatchShouldNotAlterOriginalMessageWhenPerRecipientHeaderExists() throws Exception {
         AccumulatorHeaderMailStore accumulatorTestHeaderMailStore = new AccumulatorHeaderMailStore(TEST_HEADER_NAME);
         MailDispatcher testee = MailDispatcher.builder()
             .mailetContext(fakeMailContext)
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
index ee72e3a..a0ce6b0 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
@@ -47,11 +47,11 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 
-public class SieveIntegrationTest {
+class SieveIntegrationTest {
 
     private static final String LOCAL_PART = "receiver";
     private static final String RECEIVER_DOMAIN_COM = LOCAL_PART + "@domain.com";
@@ -79,8 +79,8 @@ public class SieveIntegrationTest {
     private ResourceLocator resourceLocator;
     private FakeMailContext fakeMailContext;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         resourceLocator = mock(ResourceLocator.class);
         usersRepository = mock(UsersRepository.class);
         fakeMailContext = FakeMailContext.builder().logger(mock(Logger.class)).build();
@@ -90,7 +90,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void serviceShouldNotModifyEmailWhenErrorRetrievingScript() throws Exception {
+    void serviceShouldNotModifyEmailWhenErrorRetrievingScript() throws Exception {
         when(usersRepository.supportVirtualHosting()).thenReturn(true);
         when(usersRepository.getUsername(new MailAddress(RECEIVER_DOMAIN_COM))).thenReturn(Username.of(RECEIVER_DOMAIN_COM));
         when(resourceLocator.get(new MailAddress(RECEIVER_DOMAIN_COM))).thenThrow(new ScriptNotFoundException());
@@ -103,7 +103,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void mailShouldBeWellDeliveredByDefaultToUserWhenVirtualHostingIsTurnedOn() throws Exception {
+    void mailShouldBeWellDeliveredByDefaultToUserWhenVirtualHostingIsTurnedOn() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/keep.script");
         when(usersRepository.supportVirtualHosting()).thenReturn(true);
         when(usersRepository.getUsername(new MailAddress(RECEIVER_DOMAIN_COM))).thenReturn(Username.of(RECEIVER_DOMAIN_COM));
@@ -115,7 +115,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void mailShouldBeWellDeliveredByDefaultToUserWhenvirtualHostingIsTurnedOff() throws Exception {
+    void mailShouldBeWellDeliveredByDefaultToUserWhenvirtualHostingIsTurnedOff() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/keep.script");
         when(usersRepository.supportVirtualHosting()).thenReturn(false);
         when(usersRepository.getUsername(new MailAddress("receiver@localhost"))).thenReturn(Username.of("receiver"));
@@ -127,7 +127,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void keepScriptShouldWork() throws Exception {
+    void keepScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/keep.script");
 
         FakeMail mail = createMail();
@@ -137,7 +137,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void discardScriptShouldWork() throws Exception {
+    void discardScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/discard.script");
 
         FakeMail mail = createMail();
@@ -147,7 +147,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void fileintoScriptShouldWork() throws Exception {
+    void fileintoScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/fileinto.script");
 
         FakeMail mail = createMail();
@@ -157,7 +157,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void allOfAllFalseScriptShouldWork() throws Exception {
+    void allOfAllFalseScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/allofAllFalse.script");
 
         FakeMail mail = createMail();
@@ -167,7 +167,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void allOfOneFalseScriptShouldWork() throws Exception {
+    void allOfOneFalseScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/allofOneFalse.script");
 
         FakeMail mail = createMail();
@@ -177,7 +177,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void allOfAllTrueScriptShouldWork() throws Exception {
+    void allOfAllTrueScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/allofAllTrue.script");
 
         FakeMail mail = createMail();
@@ -187,7 +187,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void anyOfAllFalseScriptShouldWork() throws Exception {
+    void anyOfAllFalseScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/anyofAllFalse.script");
 
         FakeMail mail = createMail();
@@ -197,7 +197,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void falseScriptShouldWork() throws Exception {
+    void falseScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/false.script");
 
         FakeMail mail = createMail();
@@ -207,7 +207,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void trueScriptShouldWork() throws Exception {
+    void trueScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/true.script");
 
         FakeMail mail = createMail();
@@ -217,7 +217,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void notFalseScriptShouldWork() throws Exception {
+    void notFalseScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/notFalse.script");
 
         FakeMail mail = createMail();
@@ -227,7 +227,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void notTrueScriptShouldWork() throws Exception {
+    void notTrueScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/notTrue.script");
 
         FakeMail mail = createMail();
@@ -237,7 +237,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void anyOfOneFalseScriptShouldWork() throws Exception {
+    void anyOfOneFalseScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/anyofOneFalse.script");
 
         FakeMail mail = createMail();
@@ -247,7 +247,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void anyOfAllTrueScriptShouldWork() throws Exception {
+    void anyOfAllTrueScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/anyofAllTrue.script");
 
         FakeMail mail = createMail();
@@ -257,7 +257,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void stopScriptShouldWork() throws Exception {
+    void stopScriptShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/stop.script");
 
         FakeMail mail = createMail();
@@ -267,7 +267,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void headerScriptShouldWorkIfHeaderIsAbsent() throws Exception {
+    void headerScriptShouldWorkIfHeaderIsAbsent() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/header.script");
 
         FakeMail mail = createMail();
@@ -277,7 +277,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void headerInstructionShouldSupportFoldedEncodedHeaders() throws Exception {
+    void headerInstructionShouldSupportFoldedEncodedHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/headerEncodedFolded.script");
 
         FakeMail mail = FakeMail.builder()
@@ -296,7 +296,7 @@ public class SieveIntegrationTest {
 
 
     @Test
-    public void headerScriptShouldWorkIfHeaderIsPresent() throws Exception {
+    void headerScriptShouldWorkIfHeaderIsPresent() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/header.script");
 
         FakeMail mail = createMailWithSubject("JAMES-1620 revolution");
@@ -306,7 +306,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void sizeOverScriptShouldWorkIfUnderLimit() throws Exception {
+    void sizeOverScriptShouldWorkIfUnderLimit() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/sizeOver.script");
 
         FakeMail mail = createMail();
@@ -317,7 +317,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void sizeUnderScriptShouldWorkIfUnderLimit() throws Exception {
+    void sizeUnderScriptShouldWorkIfUnderLimit() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/sizeUnder.script");
 
         FakeMail mail = createMail();
@@ -328,7 +328,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void sizeOverScriptShouldWorkIfOverLimit() throws Exception {
+    void sizeOverScriptShouldWorkIfOverLimit() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/sizeOver.script");
 
         FakeMail mail = createMail();
@@ -339,7 +339,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void sizeUnderScriptShouldWorkIfOverLimit() throws Exception {
+    void sizeUnderScriptShouldWorkIfOverLimit() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/sizeUnder.script");
 
         FakeMail mail = createMail();
@@ -350,7 +350,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressLocalPartShouldWork() throws Exception {
+    void addressLocalPartShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressLocalPart.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source@any.com"));
@@ -361,7 +361,7 @@ public class SieveIntegrationTest {
 
 
     @Test
-    public void addressLocalPartShouldOnlyMatchLocalPart() throws Exception {
+    void addressLocalPartShouldOnlyMatchLocalPart() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressLocalPart.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source1@domain.com"));
@@ -372,7 +372,7 @@ public class SieveIntegrationTest {
 
 
     @Test
-    public void addressDomainShouldWork() throws Exception {
+    void addressDomainShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressDomain.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source1@domain.com"));
@@ -382,7 +382,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressDomainShouldOnlyMatchLocalPart() throws Exception {
+    void addressDomainShouldOnlyMatchLocalPart() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressDomain.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source@domain.org"));
@@ -392,7 +392,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressBccAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressBccAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllBcc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source@domain.com"));
@@ -402,7 +402,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressBccAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressBccAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllBcc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Bcc", "source@domain.com"));
@@ -412,7 +412,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressBccAllShouldNotMatchOtherAddress() throws Exception {
+    void addressBccAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllBcc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Bcc", "source2@domain.com"));
@@ -422,7 +422,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressBccAllShouldNotMatchOtherDomain() throws Exception {
+    void addressBccAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllBcc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Bcc", "source@domain.org"));
@@ -432,7 +432,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void redirectShouldWork() throws Exception {
+    void redirectShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/redirect.script");
 
         FakeMail mail = createMail();
@@ -449,7 +449,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressCcAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressCcAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllCc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-From", "source@domain.com"));
@@ -459,7 +459,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressCcAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressCcAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllCc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source@domain.com"));
@@ -469,7 +469,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressCcAllShouldNotMatchOtherAddress() throws Exception {
+    void addressCcAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllCc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source2@domain.com"));
@@ -479,7 +479,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressCcAllShouldNotMatchOtherDomain() throws Exception {
+    void addressCcAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllCc.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source@domain.org"));
@@ -489,7 +489,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressFromAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressFromAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllFrom.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Cc", "source@domain.com"));
@@ -499,7 +499,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressFromAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressFromAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllFrom.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("From", "source@domain.com"));
@@ -509,7 +509,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressFromAllShouldNotMatchOtherAddress() throws Exception {
+    void addressFromAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllFrom.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("From", "source2@domain.com"));
@@ -519,7 +519,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressFromAllShouldNotMatchOtherDomain() throws Exception {
+    void addressFromAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllFrom.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("From", "source@domain.org"));
@@ -529,7 +529,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressToAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressToAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllTo.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resent-To", "source@domain.com"));
@@ -539,7 +539,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressToAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressToAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllTo.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("To", "source@domain.com"));
@@ -549,7 +549,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressToAllShouldNotMatchOtherAddress() throws Exception {
+    void addressToAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllTo.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("To", "source2@domain.com"));
@@ -559,7 +559,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressToAllShouldNotMatchOtherDomain() throws Exception {
+    void addressToAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllTo.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("To", "source@domain.org"));
@@ -569,7 +569,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressSenderAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressSenderAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllSender.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("To", "source@domain.com"));
@@ -579,7 +579,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressSenderAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressSenderAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllSender.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Sender", "source@domain.com"));
@@ -589,7 +589,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressSenderAllShouldNotMatchOtherAddress() throws Exception {
+    void addressSenderAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllSender.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Sender", "source2@domain.com"));
@@ -599,7 +599,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressSenderAllShouldNotMatchOtherDomain() throws Exception {
+    void addressSenderAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllSender.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Sender", "source@domain.org"));
@@ -609,7 +609,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_FromAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressResent_FromAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-From.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("From", "source@domain.com"));
@@ -619,7 +619,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_FromAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressResent_FromAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-From.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-From", "source@domain.com"));
@@ -629,7 +629,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_FromAllShouldNotMatchOtherAddress() throws Exception {
+    void addressResent_FromAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-From.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-From", "source2@domain.com"));
@@ -639,7 +639,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_FromAllShouldNotMatchOtherDomain() throws Exception {
+    void addressResent_FromAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-From.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-From", "source@domain.org"));
@@ -649,7 +649,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_ToAllShouldNotMatchOtherHeaders() throws Exception {
+    void addressResent_ToAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-To.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("To", "source@domain.com"));
@@ -659,7 +659,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_ToAllShouldMatchSpecifiedAddress() throws Exception {
+    void addressResent_ToAllShouldMatchSpecifiedAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-To.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-To", "source@domain.com"));
@@ -669,7 +669,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_ToAllShouldNotMatchOtherAddress() throws Exception {
+    void addressResent_ToAllShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-To.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-To", "source2@domain.com"));
@@ -679,7 +679,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void addressResent_ToAllShouldNotMatchOtherDomain() throws Exception {
+    void addressResent_ToAllShouldNotMatchOtherDomain() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllResend-To.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("Resend-To", "source@domain.org"));
@@ -689,7 +689,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void envelopeFromShouldWork() throws Exception {
+    void envelopeFromShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/envelopeFrom.script");
 
         FakeMail mail = createMailWithSubjectAndHeaders("Default", new Header("From", "source@domain.com"));
@@ -699,7 +699,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void envelopeFromShouldNotMatchOtherAddress() throws Exception {
+    void envelopeFromShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/envelopeFromOtherSender.script");
 
         FakeMail mail = createMail();
@@ -709,7 +709,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void envelopeToShouldWork() throws Exception {
+    void envelopeToShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/envelopeTo.script");
 
         FakeMail mail = createMail();
@@ -719,7 +719,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void envelopeToShouldNotMatchOtherAddress() throws Exception {
+    void envelopeToShouldNotMatchOtherAddress() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/envelopeToOtherReceiver.script");
 
         FakeMail mail = createMail();
@@ -729,7 +729,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyRawShouldNotMatchNotContainedData() throws Exception {
+    void bodyRawShouldNotMatchNotContainedData() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyRawInvalid.script");
 
         FakeMail mail = createMail();
@@ -739,7 +739,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyRawShouldMatchContent() throws Exception {
+    void bodyRawShouldMatchContent() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyRawMatch.script");
 
         FakeMail mail = createMail();
@@ -749,7 +749,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyContentShouldMatchContent() throws Exception {
+    void bodyContentShouldMatchContent() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyContentMatch.script");
 
         FakeMail mail = createMail();
@@ -759,7 +759,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyContentShouldNotMatchNotContainedData() throws Exception {
+    void bodyContentShouldNotMatchNotContainedData() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyContentInvalid.script");
 
         FakeMail mail = createMail();
@@ -769,7 +769,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyContentShouldNotMatchWhenWrongContentType() throws Exception {
+    void bodyContentShouldNotMatchWhenWrongContentType() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyContentWrongContentType.script");
 
         FakeMail mail = createMail();
@@ -779,7 +779,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyTextShouldNotMatchNotContainedData() throws Exception {
+    void bodyTextShouldNotMatchNotContainedData() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyTextInvalid.script");
 
         FakeMail mail = createMail();
@@ -789,7 +789,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void bodyTextShouldMatchContent() throws Exception {
+    void bodyTextShouldMatchContent() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/bodyTextMatch.script");
 
         FakeMail mail = createMail();
@@ -799,7 +799,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void doubleVacationShouldNotBeExecutedAndReceiverShouldHaveANotificationAboutSieveError() throws Exception {
+    void doubleVacationShouldNotBeExecutedAndReceiverShouldHaveANotificationAboutSieveError() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/doubleVacation.script");
 
         FakeMail mail = createMail();
@@ -817,7 +817,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationShouldWork() throws Exception {
+    void vacationShouldWork() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/vacationReason.script");
 
         FakeMail mail = createMail();
@@ -834,7 +834,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationShouldNotSendNotificationToMailingLists() throws Exception {
+    void vacationShouldNotSendNotificationToMailingLists() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/vacationReason.script");
         Mail mail = createMail();
         mail.getMessage().addHeader("List-Id", "0123456789");
@@ -846,7 +846,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationShouldNotGenerateNotificationIfTooOld() throws Exception {
+    void vacationShouldNotGenerateNotificationIfTooOld() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationReason.script", DATE_OLD, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -857,7 +857,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationShouldNotCancelFileIntoActionIfNotExecuted() throws Exception {
+    void vacationShouldNotCancelFileIntoActionIfNotExecuted() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationReasonAndFileInto.script", DATE_OLD, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -868,7 +868,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationDaysParameterShouldFilterTooOldDates() throws Exception {
+    void vacationDaysParameterShouldFilterTooOldDates() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationDaysReason.script", DATE_DEFAULT, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -879,7 +879,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationDaysParameterShouldKeepDatesInRange() throws Exception {
+    void vacationDaysParameterShouldKeepDatesInRange() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationDaysReason.script", DATE_CLOSE, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -895,7 +895,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationShouldNotCancelFileIntoActionIfExecuted() throws Exception {
+    void vacationShouldNotCancelFileIntoActionIfExecuted() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationReasonAndFileInto.script", DATE_DEFAULT, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -911,7 +911,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationFromSubjectShouldWork() throws Exception {
+    void vacationFromSubjectShouldWork() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationSubjectFromReason.script", DATE_DEFAULT, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -927,7 +927,7 @@ public class SieveIntegrationTest {
     }
 
     @Test
-    public void vacationDaysAddressesShouldWork() throws Exception {
+    void vacationDaysAddressesShouldWork() throws Exception {
         prepareTestUsingScriptAndDates("org/apache/james/transport/mailets/delivery/vacationDaysAddressesReason.script", DATE_CLOSE, DATE_NEW);
 
         FakeMail mail = createMail();
@@ -943,7 +943,7 @@ public class SieveIntegrationTest {
     }
     
     @Test
-    public void sieveErrorNotificationEmailsShouldNotBeProcessed() throws Exception {
+    void sieveErrorNotificationEmailsShouldNotBeProcessed() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/keep.script");
 
         FakeMail mail = createMail();
@@ -974,7 +974,7 @@ public class SieveIntegrationTest {
         return createMailWithSubjectAndHeaders(subject);
     }
 
-    private FakeMail createMailWithSubjectAndHeaders(String subject, MimeMessageBuilder.Header... headers) throws MessagingException, IOException {
+    private FakeMail createMailWithSubjectAndHeaders(String subject, MimeMessageBuilder.Header... headers) throws MessagingException {
         return FakeMail.builder()
             .name("name")
             .mimeMessage(
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
index 3155b6e..d6d707c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
@@ -35,19 +35,18 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SimpleMailStoreTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class SimpleMailStoreTest {
     public static final String FOLDER = "FOLDER";
     private SimpleMailStore testee;
     private MailboxAppender mailboxAppender;
     private UsersRepository usersRepository;
     private MimeMessage mimeMessage;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         mailboxAppender = mock(MailboxAppender.class);
         usersRepository = mock(UsersRepository.class);
         testee = SimpleMailStore.builder()
@@ -65,7 +64,7 @@ public class SimpleMailStoreTest {
     }
 
     @Test
-    public void storeMailShouldUseFullMailAddressWhenSupportsVirtualHosting() throws Exception {
+    void storeMailShouldUseFullMailAddressWhenSupportsVirtualHosting() throws Exception {
         MailAddress recipient = MailAddressFixture.OTHER_AT_JAMES;
         when(usersRepository.getUsername(recipient)).thenReturn(Username.of(recipient.asString()));
         FakeMail mail = FakeMail.builder()
@@ -78,7 +77,7 @@ public class SimpleMailStoreTest {
     }
 
     @Test
-    public void storeMailShouldUseLocalPartWhenSupportsVirtualHosting() throws Exception {
+    void storeMailShouldUseLocalPartWhenSupportsVirtualHosting() throws Exception {
         MailAddress recipient = MailAddressFixture.OTHER_AT_JAMES;
         when(usersRepository.getUsername(recipient)).thenReturn(Username.of(recipient.getLocalPart()));
         FakeMail mail = FakeMail.builder()
@@ -91,7 +90,7 @@ public class SimpleMailStoreTest {
     }
 
     @Test
-    public void storeMailShouldUseFullMailAddressWhenErrorReadingUsersRepository() throws Exception {
+    void storeMailShouldUseFullMailAddressWhenErrorReadingUsersRepository() throws Exception {
         MailAddress recipient = MailAddressFixture.OTHER_AT_JAMES;
         when(usersRepository.getUsername(recipient)).thenThrow(new UsersRepositoryException("Any message"));
         FakeMail mail = FakeMail.builder()
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/jsieve/DiscardActionTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/jsieve/DiscardActionTest.java
index e09c118..add99ae 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/jsieve/DiscardActionTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/jsieve/DiscardActionTest.java
@@ -26,12 +26,11 @@ import static org.mockito.Mockito.when;
 
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
-
-public class DiscardActionTest {
+import org.junit.jupiter.api.Test;
 
+class DiscardActionTest {
     @Test
-    public void removeRecipientShouldWorkWhenOnlyOneRecipient() throws Exception {
+    void removeRecipientShouldWorkWhenOnlyOneRecipient() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .recipients(MailAddressFixture.ANY_AT_JAMES)
@@ -45,7 +44,7 @@ public class DiscardActionTest {
     }
 
     @Test
-    public void removeRecipientShouldNotThrowWhenRecipientIsAbsent() throws Exception {
+    void removeRecipientShouldNotThrowWhenRecipientIsAbsent() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .recipients(MailAddressFixture.ANY_AT_JAMES)
@@ -59,7 +58,7 @@ public class DiscardActionTest {
     }
 
     @Test
-    public void removeRecipientShouldNotThrowWhenRecipientIsNull() throws Exception {
+    void removeRecipientShouldNotThrowWhenRecipientIsNull() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .recipients(MailAddressFixture.ANY_AT_JAMES)
@@ -73,7 +72,7 @@ public class DiscardActionTest {
     }
 
     @Test
-    public void removeRecipientShouldRemoveOnlyTheConcernedRecipient() throws Exception {
+    void removeRecipientShouldRemoveOnlyTheConcernedRecipient() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES)
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
index 8b9f721..dc1fd8d 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
@@ -55,8 +55,8 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.Lists;
 
@@ -76,8 +76,8 @@ public class ManageSieveMailetTestCase {
     private UsersRepository usersRepository;
     private FakeMailContext fakeMailContext;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         sieveRepository = mock(SieveRepository.class);
         sieveParser = mock(SieveParser.class);
         usersRepository = mock(UsersRepository.class);
@@ -86,7 +86,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCapabilityUnauthorised() throws Exception {
+    void testCapabilityUnauthorised() throws Exception {
         MimeMessage message = prepareMimeMessage("CAPABILITY");
         Mail mail = createUnauthenticatedMail(message);
         when(sieveParser.getExtensions()).thenReturn(Lists.newArrayList("a", "b", "c"));
@@ -101,7 +101,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCapability() throws Exception {
+    void testCapability() throws Exception {
         MimeMessage message = prepareMimeMessage("CAPABILITY");
         Mail mail = createUnauthenticatedMail(message);
         when(sieveParser.getExtensions()).thenReturn(Lists.newArrayList("a", "b", "c"));
@@ -118,7 +118,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCapabilityExtraArguments() throws Exception {
+    void testCapabilityExtraArguments() throws Exception {
         MimeMessage message = prepareMimeMessage("CAPABILITY");
         Mail mail = createUnauthenticatedMail(message);
         message.setSubject("CAPABILITY extra");
@@ -128,7 +128,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScriptinvalidLiteral() throws Exception {
+    void testPutScriptinvalidLiteral() throws Exception {
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -136,7 +136,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScript() throws Exception {
+    void testPutScript() throws Exception {
         when(sieveParser.parse(anyString())).thenReturn(Lists.newArrayList("warning1", "warning2"));
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {100+}");
         Mail mail = createAuthentificatedMail(message);
@@ -145,7 +145,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScriptInvalidLiteral() throws Exception {
+    void testPutScriptInvalidLiteral() throws Exception {
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -153,7 +153,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScriptExtraArgs() throws Exception {
+    void testPutScriptExtraArgs() throws Exception {
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {10+} extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -161,7 +161,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScriptSyntaxError() throws Exception {
+    void testPutScriptSyntaxError() throws Exception {
         doThrow(new SyntaxException("error message")).when(sieveParser).parse(SYNTAX_EXCEPTION);
         MimeMessage message = prepareMessageWithAttachment(SYNTAX_EXCEPTION, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {10+}");
         Mail mail = createAuthentificatedMail(message);
@@ -170,7 +170,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScriptNoScript() throws Exception {
+    void testPutScriptNoScript() throws Exception {
         MimeMessage message = prepareMimeMessage("PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -178,7 +178,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testPutScriptNoScriptName() throws Exception {
+    void testPutScriptNoScriptName() throws Exception {
         MimeMessage message = prepareMimeMessage("PUTSCRIPT");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -186,7 +186,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testGetScriptNonAuthorized() throws Exception {
+    void testGetScriptNonAuthorized() throws Exception {
         MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -194,7 +194,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testGetScript() throws Exception {
+    void testGetScript() throws Exception {
         when(sieveRepository.getScript(USERNAME, SCRIPT_NAME)).thenReturn(new ByteArrayInputStream(SCRIPT_CONTENT.getValue().getBytes(StandardCharsets.UTF_8)));
         MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
@@ -204,7 +204,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testGetScriptExtraArgs() throws Exception {
+    void testGetScriptExtraArgs() throws Exception {
         MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -212,7 +212,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testGetScriptNoScript() throws Exception {
+    void testGetScriptNoScript() throws Exception {
         doThrow(new ScriptNotFoundException()).when(sieveRepository).getScript(USERNAME, SCRIPT_NAME);
         MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
@@ -222,7 +222,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testGetScriptNoScriptName() throws Exception {
+    void testGetScriptNoScriptName() throws Exception {
         ScriptContent scriptContent = new ScriptContent("line1\r\nline2");
         sieveRepository.putScript(USERNAME, SCRIPT_NAME, scriptContent);
         MimeMessage message = prepareMimeMessage("GETSCRIPT");
@@ -234,7 +234,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCheckScriptUnauthorised() throws Exception {
+    void testCheckScriptUnauthorised() throws Exception {
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "CHECKSCRIPT {10+}");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -242,7 +242,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCheckScript() throws Exception {
+    void testCheckScript() throws Exception {
         when(sieveParser.parse(anyString())).thenReturn(Lists.newArrayList("warning1", "warning2"));
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "CHECKSCRIPT {100+}");
         Mail mail = createAuthentificatedMail(message);
@@ -251,7 +251,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCheckScriptExtraArgs() throws Exception {
+    void testCheckScriptExtraArgs() throws Exception {
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "CHECKSCRIPT {10+} extra");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -259,7 +259,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCheckScriptSyntaxError() throws Exception {
+    void testCheckScriptSyntaxError() throws Exception {
         doThrow(new SyntaxException("error message")).when(sieveParser).parse(SYNTAX_EXCEPTION);
         MimeMessage message = prepareMessageWithAttachment(SYNTAX_EXCEPTION, "CHECKSCRIPT {10+}");
         Mail mail = createAuthentificatedMail(message);
@@ -268,7 +268,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCheckScriptNoSize() throws Exception {
+    void testCheckScriptNoSize() throws Exception {
         MimeMessage message = prepareMimeMessage("CHECKSCRIPT");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -276,7 +276,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testCheckScriptNoScript() throws Exception {
+    void testCheckScriptNoScript() throws Exception {
         MimeMessage message = prepareMimeMessage("CHECKSCRIPT {10+}");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -284,7 +284,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testDeleteScriptUnauthenticated() throws Exception {
+    void testDeleteScriptUnauthenticated() throws Exception {
         MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -292,7 +292,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testDeleteScript() throws Exception {
+    void testDeleteScript() throws Exception {
         MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -300,7 +300,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testDeleteScriptExtraArgs() throws Exception {
+    void testDeleteScriptExtraArgs() throws Exception {
         MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -308,7 +308,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testDeleteScriptNoScriptName() throws Exception {
+    void testDeleteScriptNoScriptName() throws Exception {
         MimeMessage message = prepareMimeMessage("DELETESCRIPT");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -316,7 +316,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testHaveSpaceUnauthenticated() throws Exception {
+    void testHaveSpaceUnauthenticated() throws Exception {
         MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -324,7 +324,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testHaveSpace() throws Exception {
+    void testHaveSpace() throws Exception {
         MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -332,7 +332,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testHaveSpaceExtraArgs() throws Exception {
+    void testHaveSpaceExtraArgs() throws Exception {
         MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1 extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -340,7 +340,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testHaveSpaceNoScriptName() throws Exception {
+    void testHaveSpaceNoScriptName() throws Exception {
         MimeMessage message = prepareMimeMessage("HAVESPACE");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -348,7 +348,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testHaveSpaceNoScriptSize() throws Exception {
+    void testHaveSpaceNoScriptSize() throws Exception {
         MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -356,7 +356,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testHaveSpaceInvalidScriptSize() throws Exception {
+    void testHaveSpaceInvalidScriptSize() throws Exception {
         MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" X");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -364,7 +364,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testListScriptsUnauthorised() throws Exception {
+    void testListScriptsUnauthorised() throws Exception {
         MimeMessage message = prepareMimeMessage("LISTSCRIPTS");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -372,7 +372,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testListScripts() throws Exception {
+    void testListScripts() throws Exception {
         when(sieveRepository.listScripts(USERNAME)).thenReturn(Lists.newArrayList(new ScriptSummary(new ScriptName("scriptName2"), true), new ScriptSummary(new ScriptName("scriptName1"), false)));
         MimeMessage message = prepareMimeMessage("LISTSCRIPTS");
         Mail mail = createAuthentificatedMail(message);
@@ -381,7 +381,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testListScriptsExtraArgs() throws Exception {
+    void testListScriptsExtraArgs() throws Exception {
         MimeMessage message = prepareMimeMessage("LISTSCRIPTS extra");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -389,7 +389,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testRenameScriptsUnauthorised() throws Exception {
+    void testRenameScriptsUnauthorised() throws Exception {
         sieveRepository.putScript(USERNAME, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\" \"" + NEW_SCRIPT_NAME + "\"");
         Mail mail = createUnauthenticatedMail(message);
@@ -398,7 +398,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testRenameScripts() throws Exception {
+    void testRenameScripts() throws Exception {
         sieveRepository.putScript(USERNAME, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\" \"" + NEW_SCRIPT_NAME + "\"");
         Mail mail = createAuthentificatedMail(message);
@@ -407,7 +407,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testRenameScriptsExtraArgs() throws Exception {
+    void testRenameScriptsExtraArgs() throws Exception {
         sieveRepository.putScript(USERNAME, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\" \"" + NEW_SCRIPT_NAME + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
@@ -416,7 +416,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testRenameScriptsNoScriptName() throws Exception {
+    void testRenameScriptsNoScriptName() throws Exception {
         sieveRepository.putScript(USERNAME, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT");
         Mail mail = createUnauthenticatedMail(message);
@@ -425,7 +425,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testRenameScriptsNoNewScriptName() throws Exception {
+    void testRenameScriptsNoNewScriptName() throws Exception {
         sieveRepository.putScript(USERNAME, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\"");
         Mail mail = createUnauthenticatedMail(message);
@@ -434,7 +434,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testSetActiveUnauthorised() throws Exception {
+    void testSetActiveUnauthorised() throws Exception {
         MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -442,7 +442,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testSetActive() throws Exception {
+    void testSetActive() throws Exception {
         MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -450,7 +450,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testSetActiveExtraArgs() throws Exception {
+    void testSetActiveExtraArgs() throws Exception {
         MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -458,7 +458,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void testSetActiveNoScriptName() throws Exception {
+    void testSetActiveNoScriptName() throws Exception {
         MimeMessage message = prepareMimeMessage("SETACTIVE");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -466,7 +466,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void manageSieveMailetShouldIgnoreNullSender() throws Exception {
+    void manageSieveMailetShouldIgnoreNullSender() throws Exception {
         MimeMessage message = prepareMimeMessage("SETACTIVE");
         Mail mail = FakeMail.builder()
             .name("name")
@@ -481,7 +481,7 @@ public class ManageSieveMailetTestCase {
     }
 
     @Test
-    public final void manageSieveMailetShouldIgnoreMailWhenNoSender() throws Exception {
+    void manageSieveMailetShouldIgnoreMailWhenNoSender() throws Exception {
         MimeMessage message = prepareMimeMessage("SETACTIVE");
         Mail mail = FakeMail.builder()
             .name("name")
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/LoadedOnceInitParametersTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/LoadedOnceInitParametersTest.java
index c989a5e..b1c4f1e 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/LoadedOnceInitParametersTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/LoadedOnceInitParametersTest.java
@@ -23,12 +23,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
-import org.junit.Test;
-
-public class LoadedOnceInitParametersTest {
+import org.junit.jupiter.api.Test;
 
+class LoadedOnceInitParametersTest {
     @Test
-    public void fromShouldTakeValueFromInitParameters() {
+    void fromShouldTakeValueFromInitParameters() {
         InitParameters expectedParameters = new MyInitParameters();
 
         InitParameters parameters = LoadedOnceInitParameters.from(expectedParameters);
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetInitParametersTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetInitParametersTest.java
index a0dfb17..055100a 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetInitParametersTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetInitParametersTest.java
@@ -23,30 +23,27 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
-import javax.mail.MessagingException;
-
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
-
-public class NotifyMailetInitParametersTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class NotifyMailetInitParametersTest {
     private GenericMailet mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new GenericMailet() {
             
             @Override
-            public void service(Mail mail) throws MessagingException {
+            public void service(Mail mail) {
             }
         };
     }
 
     @Test
-    public void getPassThroughShouldReturnTrueWhenSetToTrue() throws Exception {
+    void getPassThroughShouldReturnTrueWhenSetToTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("passThrough", "true")
@@ -59,7 +56,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getPassThroughShouldReturnFalseWhenSetToFalse() throws Exception {
+    void getPassThroughShouldReturnFalseWhenSetToFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("passThrough", "false")
@@ -72,7 +69,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getPassThroughShouldReturnTrueWhenNotSet() throws Exception {
+    void getPassThroughShouldReturnTrueWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -84,7 +81,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getFakeDomainCheckShouldReturnTrueWhenSetToTrue() throws Exception {
+    void getFakeDomainCheckShouldReturnTrueWhenSetToTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("fakeDomainCheck", "true")
@@ -97,7 +94,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getFakeDomainCheckShouldReturnFalseWhenSetToFalse() throws Exception {
+    void getFakeDomainCheckShouldReturnFalseWhenSetToFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("fakeDomainCheck", "false")
@@ -110,7 +107,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getFakeDomainCheckShouldReturnFalseWhenNotSet() throws Exception {
+    void getFakeDomainCheckShouldReturnFalseWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -122,7 +119,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getInLineTypeShouldReturnValueWhenSet() throws Exception {
+    void getInLineTypeShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("inline", "unaltered")
@@ -135,7 +132,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getInLineTypeShouldReturnNoneWhenNotSet() throws Exception {
+    void getInLineTypeShouldReturnNoneWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -147,7 +144,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getAttachmentTypeShouldReturnValueWhenSet() throws Exception {
+    void getAttachmentTypeShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("attachment", "unaltered")
@@ -160,7 +157,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getAttachmentTypeShouldReturnMessageWhenNotSet() throws Exception {
+    void getAttachmentTypeShouldReturnMessageWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -172,7 +169,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getMessageShouldReturnNoticeValueWhenSet() throws Exception {
+    void getMessageShouldReturnNoticeValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("notice", "my notice")
@@ -185,7 +182,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getMessageShouldReturnMessageValueWhenSet() throws Exception {
+    void getMessageShouldReturnMessageValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("message", "my message")
@@ -198,7 +195,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getMessageShouldReturnDefaultMessageWhenNoticeAndMessageNotSet() throws Exception {
+    void getMessageShouldReturnDefaultMessageWhenNoticeAndMessageNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -210,7 +207,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getSubjectShouldReturnNull() throws Exception {
+    void getSubjectShouldReturnNull() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -222,7 +219,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getSubjectPrefixShouldReturnValueWhenSet() throws Exception {
+    void getSubjectPrefixShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("prefix", "my prefix")
@@ -235,7 +232,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getSubjectPrefixShouldReturnDefaultValueWhenNotSet() throws Exception {
+    void getSubjectPrefixShouldReturnDefaultValueWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -247,7 +244,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isAttachErrorShouldReturnTrueWhenSetToTrue() throws Exception {
+    void isAttachErrorShouldReturnTrueWhenSetToTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("attachError", "true")
@@ -260,7 +257,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isAttachErrorShouldReturnFalseWhenSetToFalse() throws Exception {
+    void isAttachErrorShouldReturnFalseWhenSetToFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("attachError", "false")
@@ -273,7 +270,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isAttachErrorShouldReturnFalseWhenNotSet() throws Exception {
+    void isAttachErrorShouldReturnFalseWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -285,7 +282,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isReplyShouldReturnTrue() throws Exception {
+    void isReplyShouldReturnTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -297,7 +294,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnValueWhenSet() throws Exception {
+    void getRecipientsShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("recipients", "user@james.org, user2@james.org")
@@ -310,7 +307,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnAbsentWhenEmpty() throws Exception {
+    void getRecipientsShouldReturnAbsentWhenEmpty() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("recipients", "")
@@ -323,7 +320,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnAbsentWhenNotSet() throws Exception {
+    void getRecipientsShouldReturnAbsentWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -335,7 +332,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getToShouldReturnValueWhenSet() throws Exception {
+    void getToShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("to", "user@james.org, user2@james.org")
@@ -348,7 +345,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getToShouldReturnAbsentWhenEmpty() throws Exception {
+    void getToShouldReturnAbsentWhenEmpty() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("to", "")
@@ -361,7 +358,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getToShouldReturnAbsentWhenNotSet() throws Exception {
+    void getToShouldReturnAbsentWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -373,7 +370,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReversePathShouldReturnValueWhenSet() throws Exception {
+    void getReversePathShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("reversePath", "user@james.org, user2@james.org")
@@ -386,7 +383,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReversePathShouldReturnAbsentWhenEmpty() throws Exception {
+    void getReversePathShouldReturnAbsentWhenEmpty() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("reversePath", "")
@@ -399,7 +396,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReversePathShouldReturnAbsentWhenNotSet() throws Exception {
+    void getReversePathShouldReturnAbsentWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -411,7 +408,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getSenderShouldReturnValueWhenSet() throws Exception {
+    void getSenderShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("sender", "user@james.org, user2@james.org")
@@ -424,7 +421,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getSenderShouldReturnAbsentWhenEmpty() throws Exception {
+    void getSenderShouldReturnAbsentWhenEmpty() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("sender", "")
@@ -437,7 +434,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getSenderShouldReturnAbsentWhenNotSet() throws Exception {
+    void getSenderShouldReturnAbsentWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -449,7 +446,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReplyToShouldReturnValueWhenSet() throws Exception {
+    void getReplyToShouldReturnValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("replyTo", "user@james.org, user2@james.org")
@@ -462,7 +459,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReplyToShouldReturnreplytoValueWhenSet() throws Exception {
+    void getReplyToShouldReturnreplytoValueWhenSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("replyto", "user@james.org, user2@james.org")
@@ -475,7 +472,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReplyToShouldReturnAbsentWhenEmpty() throws Exception {
+    void getReplyToShouldReturnAbsentWhenEmpty() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("replyTo", "")
@@ -488,7 +485,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void getReplyToShouldReturnAbsentWhenNotSet() throws Exception {
+    void getReplyToShouldReturnAbsentWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -500,7 +497,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isDebugShouldReturnTrueWhenSetToTrue() throws Exception {
+    void isDebugShouldReturnTrueWhenSetToTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("debug", "true")
@@ -513,7 +510,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isDebugShouldReturnFalseWhenSetToFalse() throws Exception {
+    void isDebugShouldReturnFalseWhenSetToFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("debug", "false")
@@ -526,7 +523,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isDebugShouldReturnFalseWhenNotSet() throws Exception {
+    void isDebugShouldReturnFalseWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
@@ -538,7 +535,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isStaticShouldReturnTrueWhenSetToTrue() throws Exception {
+    void isStaticShouldReturnTrueWhenSetToTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("static", "true")
@@ -551,7 +548,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isStaticShouldReturnFalseWhenSetToFalse() throws Exception {
+    void isStaticShouldReturnFalseWhenSetToFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .setProperty("static", "false")
@@ -564,7 +561,7 @@ public class NotifyMailetInitParametersTest {
     }
 
     @Test
-    public void isStaticShouldReturnFalseWhenNotSet() throws Exception {
+    void isStaticShouldReturnFalseWhenNotSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("mailet")
                 .build();
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
index f8d99ac..c295bfc 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
@@ -36,27 +36,26 @@ import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class NotifyMailetsMessageTest {
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class NotifyMailetsMessageTest {
     private TimeZone timeZone;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         timeZone = TimeZone.getDefault();
         TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
     }
 
-    @After
-    public void tearDown() {
+    @AfterEach
+    void tearDown() {
         TimeZone.setDefault(timeZone);
     }
 
     @Test
-    public void generateMessageShouldReturnTheMessageWhenSimpleMimeMessage() throws Exception {
+    void generateMessageShouldReturnTheMessageWhenSimpleMimeMessage() throws Exception {
         FakeMail mail = FakeMail.builder()
                 .name("name")
                 .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
@@ -71,7 +70,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddErrorMessageWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddErrorMessageWhenMimeMessageAsSome() throws Exception {
         FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder());
         String myErrorMessage = "my error message";
         mail.setErrorMessage(myErrorMessage);
@@ -84,7 +83,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddSubjectWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddSubjectWhenMimeMessageAsSome() throws Exception {
         FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
             .setSubject("my subject"));
 
@@ -94,7 +93,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddSentDateWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddSentDateWhenMimeMessageAsSome() throws Exception {
         MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         message.setSentDate(Date.from(Instant.parse("2016-09-08T14:25:52.000Z")));
         FakeMail mail = FakeMail.from(message);
@@ -105,7 +104,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddRecipientsWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddRecipientsWhenMimeMessageAsSome() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
@@ -119,7 +118,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddFromWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddFromWhenMimeMessageAsSome() throws Exception {
         FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
             .addFrom("user@james.org"));
 
@@ -130,7 +129,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddToWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddToWhenMimeMessageAsSome() throws Exception {
         FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
             .addToRecipient("user@james.org", "user2@james.org"));
 
@@ -142,7 +141,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddCCWhenMimeMessageAsSome() throws Exception {
+    void generateMessageShouldAddCCWhenMimeMessageAsSome() throws Exception {
         FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
             .addCcRecipient("user@james.org", "user2@james.org"));
 
@@ -154,7 +153,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldAddSizeWhenPossible() throws Exception {
+    void generateMessageShouldAddSizeWhenPossible() throws Exception {
         FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder());
         mail.setMessageSize(6);
 
@@ -164,7 +163,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldSpecifySizeInAReadableWay() throws Exception {
+    void generateMessageShouldSpecifySizeInAReadableWay() throws Exception {
         String content = "MIME-Version: 1.0\r\n" +
             "Content-Type: text/plain; charset=utf-8\r\n" +
             "\r\n" +
@@ -180,7 +179,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void getMessageInternalSizeShouldTransformMessagingErrorIntoEmpty() throws MessagingException {
+    void getMessageInternalSizeShouldTransformMessagingErrorIntoEmpty() throws MessagingException {
         Mail mail = mock(Mail.class);
         when(mail.getMessageSize()).thenThrow(new MessagingException());
 
@@ -189,7 +188,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void getMessageInternalSizeShouldTransformZeroSizeIntoEmpty() throws MessagingException {
+    void getMessageInternalSizeShouldTransformZeroSizeIntoEmpty() throws MessagingException {
         Mail mail = mock(Mail.class);
         when(mail.getMessageSize()).thenReturn(0L);
 
@@ -198,7 +197,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void getMessageInternalSizeShouldTransformNegativeIntoEmpty() throws MessagingException {
+    void getMessageInternalSizeShouldTransformNegativeIntoEmpty() throws MessagingException {
         Mail mail = mock(Mail.class);
         when(mail.getMessageSize()).thenReturn(-1L);
 
@@ -207,7 +206,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void getMessageInternalSizeShouldReturnSizeWhenAvailable() throws MessagingException {
+    void getMessageInternalSizeShouldReturnSizeWhenAvailable() throws MessagingException {
         long size = 42L;
 
         Mail mail = mock(Mail.class);
@@ -218,7 +217,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldDecodeEncodedSubject() throws Exception {
+    void generateMessageShouldDecodeEncodedSubject() throws Exception {
         String content = "MIME-Version: 1.0\r\n" +
             "Subject: =?UTF-8?Q?Cl=c3=b4ture_&_Paie_du_mois?=\r\n" +
             "Content-Type: text/plain; charset=utf-8\r\n" +
@@ -233,7 +232,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldDecodeEncodedFrom() throws Exception {
+    void generateMessageShouldDecodeEncodedFrom() throws Exception {
         String content = "MIME-Version: 1.0\r\n" +
             "From: =?UTF-8?Q?=F0=9F=90=83@linagora.com?=\r\n" +
             "Content-Type: text/plain; charset=utf-8\r\n" +
@@ -249,7 +248,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldDecodeEncodedTo() throws Exception {
+    void generateMessageShouldDecodeEncodedTo() throws Exception {
         String content = "MIME-Version: 1.0\r\n" +
             "To: =?UTF-8?Q?=F0=9F=9A=BE@linagora.com?=\r\n" +
             "Content-Type: text/plain; charset=utf-8\r\n" +
@@ -265,7 +264,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void generateMessageShouldDecodeEncodedCc() throws Exception {
+    void generateMessageShouldDecodeEncodedCc() throws Exception {
         String content = "MIME-Version: 1.0\r\n" +
             "Cc: =?UTF-8?Q?=F0=9F=9A=B2@linagora.com?=\r\n" +
             "Content-Type: text/plain; charset=utf-8\r\n" +
@@ -281,7 +280,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void safelyDecodeShouldReturnTextNotEncodedUnmodified() throws Exception {
+    void safelyDecodeShouldReturnTextNotEncodedUnmodified() {
         String text = "Why not unicode for Llama";
 
         assertThat(NotifyMailetsMessage.safelyDecode(text))
@@ -289,13 +288,13 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void safelyDecodeShouldCorrectlyDecodeQuotedPrintable() throws Exception {
+    void safelyDecodeShouldCorrectlyDecodeQuotedPrintable() {
         assertThat(NotifyMailetsMessage.safelyDecode("=?UTF-8?Q?=E2=99=A5=F0=9F=9A=B2?="))
             .isEqualTo("♥🚲");
     }
 
     @Test
-    public void safelyDecodeShouldReturnInvalidEncodedTextUnmodified() throws Exception {
+    void safelyDecodeShouldReturnInvalidEncodedTextUnmodified() {
         String invalidEncodedText = "=?UTF-8?Q?=E2=99=A5=FX=9F=9A=B2?=";
 
         assertThat(NotifyMailetsMessage.safelyDecode(invalidEncodedText))
@@ -303,7 +302,7 @@ public class NotifyMailetsMessageTest {
     }
 
     @Test
-    public void safelyDecodeShouldReturnEncodedTextUnmodifiedWhenUnknownCharset() throws Exception {
+    void safelyDecodeShouldReturnEncodedTextUnmodifiedWhenUnknownCharset() {
         String encodedTextWithUnknownCharset = "=?UTF-9?Q?=E2=99=A5=F0=9F=9A=B2?=";
 
         assertThat(NotifyMailetsMessage.safelyDecode(encodedTextWithUnknownCharset))
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParametersTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParametersTest.java
index 208bd35..5f3b11c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParametersTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParametersTest.java
@@ -23,24 +23,21 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
-import javax.mail.MessagingException;
-
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RedirectMailetInitParametersTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class RedirectMailetInitParametersTest {
     private GenericMailet mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new GenericMailet() {
             
             @Override
-            public void service(Mail mail) throws MessagingException {
+            public void service(Mail mail) {
             }
         };
     }
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
index 6a4bf2c..ed6e81c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
@@ -22,62 +22,61 @@ package org.apache.james.transport.mailets.redirect;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.core.MailAddress;
-import org.junit.Test;
-
-public class SpecialAddressTest {
+import org.junit.jupiter.api.Test;
 
+class SpecialAddressTest {
     @Test
-    public void senderSpecialAddressShouldMatchExpectedValue() {
+    void senderSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.SENDER).isEqualTo("sender@address.marker");
     }
 
     @Test
-    public void reverserPathSpecialAddressShouldMatchExpectedValue() {
+    void reverserPathSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.REVERSE_PATH).isEqualTo("reverse.path@address.marker");
     }
 
     @Test
-    public void fromSpecialAddressShouldMatchExpectedValue() {
+    void fromSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.FROM).isEqualTo("from@address.marker");
     }
 
     @Test
-    public void replyToSpecialAddressShouldMatchExpectedValue() {
+    void replyToSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.REPLY_TO).isEqualTo("reply.to@address.marker");
     }
 
     @Test
-    public void toSpecialAddressShouldMatchExpectedValue() {
+    void toSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.TO).isEqualTo("to@address.marker");
     }
 
     @Test
-    public void recipientsSpecialAddressShouldMatchExpectedValue() {
+    void recipientsSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.RECIPIENTS).isEqualTo("recipients@address.marker");
     }
 
     @Test
-    public void deleteSpecialAddressShouldMatchExpectedValue() {
+    void deleteSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.DELETE).isEqualTo("delete@address.marker");
     }
 
     @Test
-    public void unalteredSpecialAddressShouldMatchExpectedValue() {
+    void unalteredSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.UNALTERED).isEqualTo("unaltered@address.marker");
     }
 
     @Test
-    public void nullSpecialAddressShouldMatchExpectedValue() {
+    void nullSpecialAddressShouldMatchExpectedValue() {
         assertThat(SpecialAddress.AddressMarker.NULL).isEqualTo("null@address.marker");
     }
 
     @Test
-    public void isSpecialAddressShouldReturnTrueWhenMatchingSpecialDomain() throws Exception {
+    void isSpecialAddressShouldReturnTrueWhenMatchingSpecialDomain() throws Exception {
         assertThat(SpecialAddress.isSpecialAddress(new MailAddress("user", "address.marker"))).isTrue();
     }
 
     @Test
-    public void isSpecialAddressShouldReturnFalseWhenNotMatchingSpecialDomain() throws Exception {
+    void isSpecialAddressShouldReturnFalseWhenNotMatchingSpecialDomain() throws Exception {
         assertThat(SpecialAddress.isSpecialAddress(new MailAddress("user", "james.org"))).isFalse();
     }
 }
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/AddressesArrayToMailAddressListConverterTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/AddressesArrayToMailAddressListConverterTest.java
index b54f940..319be48 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/AddressesArrayToMailAddressListConverterTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/AddressesArrayToMailAddressListConverterTest.java
@@ -24,33 +24,31 @@ import static org.assertj.core.api.Assertions.assertThat;
 import javax.mail.Address;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.remote.delivery.AddressesArrayToMailAddressListConverter;
 import org.apache.mailet.base.MailAddressFixture;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AddressesArrayToMailAddressListConverterTest {
-
     private static final String WRONG_INTERNET_ADDRESS = "!!";
 
     @Test
-    public void getAddressesAsMailAddressShouldReturnEmptyOnNull() {
+    void getAddressesAsMailAddressShouldReturnEmptyOnNull() {
         assertThat(AddressesArrayToMailAddressListConverter.getAddressesAsMailAddress(null)).isEmpty();
     }
 
     @Test
-    public void getAddressesAsMailAddressShouldReturnEmptyOnEmpty() {
+    void getAddressesAsMailAddressShouldReturnEmptyOnEmpty() {
         assertThat(AddressesArrayToMailAddressListConverter.getAddressesAsMailAddress(new Address[]{})).isEmpty();
     }
 
     @Test
-    public void getAddressesAsMailAddressShouldWorkWithSingleValue() throws Exception {
+    void getAddressesAsMailAddressShouldWorkWithSingleValue() throws Exception {
         assertThat(AddressesArrayToMailAddressListConverter.getAddressesAsMailAddress(new Address[]{
             new InternetAddress(MailAddressFixture.ANY_AT_JAMES.toString())}))
             .containsOnly(MailAddressFixture.ANY_AT_JAMES);
     }
 
     @Test
-    public void getAddressesAsMailAddressShouldWorkWithTwoValues() throws Exception {
+    void getAddressesAsMailAddressShouldWorkWithTwoValues() throws Exception {
         assertThat(AddressesArrayToMailAddressListConverter.getAddressesAsMailAddress(new Address[]{
             new InternetAddress(MailAddressFixture.ANY_AT_JAMES.toString()),
             new InternetAddress(MailAddressFixture.OTHER_AT_JAMES.toString())}))
@@ -58,7 +56,7 @@ public class AddressesArrayToMailAddressListConverterTest {
     }
 
     @Test
-    public void getAddressesAsMailAddressShouldFilterErrorMailAddress() throws Exception {
+    void getAddressesAsMailAddressShouldFilterErrorMailAddress() throws Exception {
         assertThat(AddressesArrayToMailAddressListConverter.getAddressesAsMailAddress(new Address[]{
             new InternetAddress(MailAddressFixture.ANY_AT_JAMES.toString()),
             new InternetAddress(WRONG_INTERNET_ADDRESS)}))
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/BouncerTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/BouncerTest.java
index c759b9d..86b7e9c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/BouncerTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/BouncerTest.java
@@ -41,12 +41,12 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.sun.mail.smtp.SMTPSendFailedException;
 
-public class BouncerTest {
+class BouncerTest {
     private static final String HELLO_NAME = "hello_name";
     private static final FakeMailetConfig DEFAULT_REMOTE_DELIVERY_CONFIG = FakeMailetConfig.builder()
         .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -56,13 +56,13 @@ public class BouncerTest {
 
     private FakeMailContext mailetContext;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         mailetContext = FakeMailContext.defaultContext();
     }
 
     @Test
-    public void bounceShouldCallMailetContextBounceByDefault() throws Exception {
+    void bounceShouldCallMailetContextBounceByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -85,7 +85,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldIncludeMessagingExceptionMessageByDefault() throws Exception {
+    void bounceShouldIncludeMessagingExceptionMessageByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -111,7 +111,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldCustomizeSendFailedExceptionByDefault() throws Exception {
+    void bounceShouldCustomizeSendFailedExceptionByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -137,7 +137,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldCustomizeUnknownHostExceptionByDefault() throws Exception {
+    void bounceShouldCustomizeUnknownHostExceptionByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -164,7 +164,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldCustomizeConnectionExceptionByDefault() throws Exception {
+    void bounceShouldCustomizeConnectionExceptionByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -190,7 +190,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldCustomizeSocketExceptionByDefault() throws Exception {
+    void bounceShouldCustomizeSocketExceptionByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -216,7 +216,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldCustomizeNestedMessagingExceptionByDefault() throws Exception {
+    void bounceShouldCustomizeNestedMessagingExceptionByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -242,7 +242,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldNotBounceWithNoSenderByDefault() throws Exception {
+    void bounceShouldNotBounceWithNoSenderByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -258,7 +258,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldSupportExceptionWithoutMessagesByDefault() throws Exception {
+    void bounceShouldSupportExceptionWithoutMessagesByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -281,7 +281,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldNotSupportMessagingExceptionWithoutMessagesByDefault() throws Exception {
+    void bounceShouldNotSupportMessagingExceptionWithoutMessagesByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -304,7 +304,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldWorkWhenProcessorSpecified() throws Exception {
+    void bounceShouldWorkWhenProcessorSpecified() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -330,7 +330,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldNotBounceWhenNoSenderWhenProcessorSpecified() throws Exception {
+    void bounceShouldNotBounceWhenNoSenderWhenProcessorSpecified() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -348,7 +348,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldDisplayAddressByDefault() throws Exception {
+    void bounceShouldDisplayAddressByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -373,7 +373,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldDisplayAddressesByDefault() throws Exception {
+    void bounceShouldDisplayAddressesByDefault() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             DEFAULT_REMOTE_DELIVERY_CONFIG,
             mock(DomainList.class));
@@ -399,7 +399,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldWorkWhenProcessorSpecifiedAndNoExceptionMessage() throws Exception {
+    void bounceShouldWorkWhenProcessorSpecifiedAndNoExceptionMessage() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -424,7 +424,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldAttachErrorCodeWhenSmtpError() throws Exception {
+    void bounceShouldAttachErrorCodeWhenSmtpError() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -454,7 +454,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldNotAttachErrorCodeWhenNotMessagingException() throws Exception {
+    void bounceShouldNotAttachErrorCodeWhenNotMessagingException() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -480,7 +480,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldNotAttachErrorCodeWhenNotSmtpError() throws Exception {
+    void bounceShouldNotAttachErrorCodeWhenNotSmtpError() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
@@ -506,7 +506,7 @@ public class BouncerTest {
     }
 
     @Test
-    public void bounceShouldAttachNullErrorMessageWhenNoException() throws Exception {
+    void bounceShouldAttachNullErrorMessageWhenNoException() throws Exception {
         RemoteDeliveryConfiguration configuration = new RemoteDeliveryConfiguration(
             FakeMailetConfig.builder()
                 .setProperty(RemoteDeliveryConfiguration.HELO_NAME, HELLO_NAME)
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRetryHelperTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRetryHelperTest.java
index 545f77d..30c8ce0 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRetryHelperTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRetryHelperTest.java
@@ -21,24 +21,22 @@ package org.apache.james.transport.mailets.remote.delivery;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.james.transport.mailets.remote.delivery.DeliveryRetriesHelper;
 import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeValue;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
-
-public class DeliveryRetryHelperTest {
+import org.junit.jupiter.api.Test;
 
+class DeliveryRetryHelperTest {
     private static final Attribute INVALID_ATTRIBUTE = new Attribute(DeliveryRetriesHelper.DELIVERY_RETRY_COUNT, AttributeValue.of("invalid"));
 
     @Test
-    public void retrieveRetriesShouldBeZeroByDefault() throws Exception {
+    void retrieveRetriesShouldBeZeroByDefault() throws Exception {
         assertThat(DeliveryRetriesHelper.retrieveRetries(FakeMail.defaultFakeMail()))
             .isEqualTo(0);
     }
 
     @Test
-    public void retrieveRetriesShouldBeZeroAfterInit() throws Exception {
+    void retrieveRetriesShouldBeZeroAfterInit() throws Exception {
         FakeMail mail = FakeMail.defaultFakeMail();
 
         DeliveryRetriesHelper.initRetries(mail);
@@ -48,7 +46,7 @@ public class DeliveryRetryHelperTest {
     }
 
     @Test
-    public void retrieveRetriesShouldBeOneAfterIncrement() throws Exception {
+    void retrieveRetriesShouldBeOneAfterIncrement() throws Exception {
         FakeMail mail = FakeMail.defaultFakeMail();
 
         DeliveryRetriesHelper.initRetries(mail);
@@ -59,7 +57,7 @@ public class DeliveryRetryHelperTest {
     }
 
     @Test
-    public void incrementRetriesShouldWorkOnNonInitializedMails() throws Exception {
+    void incrementRetriesShouldWorkOnNonInitializedMails() throws Exception {
         FakeMail mail = FakeMail.defaultFakeMail();
 
         DeliveryRetriesHelper.incrementRetries(mail);
@@ -69,7 +67,7 @@ public class DeliveryRetryHelperTest {
     }
 
     @Test
-    public void retrieveRetriesShouldBeZeroOnInvalidValue() throws Exception {
+    void retrieveRetriesShouldBeZeroOnInvalidValue() throws Exception {
         FakeMail mail = FakeMail.builder().name("name").attribute(INVALID_ATTRIBUTE).build();
 
         assertThat(DeliveryRetriesHelper.retrieveRetries(mail))
@@ -77,7 +75,7 @@ public class DeliveryRetryHelperTest {
     }
 
     @Test
-    public void incrementRetriesShouldWorkOnInvalidMails() throws Exception {
+    void incrementRetriesShouldWorkOnInvalidMails() throws Exception {
         FakeMail mail = FakeMail.builder().name("name").attribute(INVALID_ATTRIBUTE).build();
 
         DeliveryRetriesHelper.incrementRetries(mail);
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerTest.java
index 4f76eca..8b9da07 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerTest.java
@@ -43,15 +43,15 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.UnmodifiableIterator;
 import com.sun.mail.smtp.SMTPSenderFailedException;
 
 @SuppressWarnings("deprecation")
-public class MailDelivrerTest {
+class MailDelivrerTest {
     public static final String MX1_HOSTNAME = "mx1." + MailAddressFixture.JAMES2_APACHE_ORG;
     public static final String MX2_HOSTNAME = "mx2." + MailAddressFixture.JAMES2_APACHE_ORG;
     public static final String SMTP_URI2 = "protocol://userid:password@host:119/file1";
@@ -64,7 +64,7 @@ public class MailDelivrerTest {
     private DnsHelper dnsHelper;
     private MailDelivrerToHost mailDelivrerToHost;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         bouncer = mock(Bouncer.class);
         dnsHelper = mock(DnsHelper.class);
@@ -78,7 +78,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldReturnTemporaryFailureByDefault() throws Exception {
+    void handleSenderFailedExceptionShouldReturnTemporaryFailureByDefault() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         SendFailedException sfe = new SendFailedException();
@@ -88,7 +88,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldReturnTemporaryFailureWhenNotServerException() throws Exception {
+    void handleSenderFailedExceptionShouldReturnTemporaryFailureWhenNotServerException() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         SendFailedException sfe = new SMTPSenderFailedException(new InternetAddress(MailAddressFixture.OTHER_AT_JAMES.asString()), "Comand", 400, "An temporary error");
@@ -98,7 +98,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldReturnPermanentFailureWhenServerException() throws Exception {
+    void handleSenderFailedExceptionShouldReturnPermanentFailureWhenServerException() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         SendFailedException sfe = new SMTPSenderFailedException(new InternetAddress(MailAddressFixture.OTHER_AT_JAMES.asString()), "Comand", 505, "An temporary error");
@@ -108,7 +108,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldReturnPermanentFailureWhenInvalidAndNotValidUnsent() throws Exception {
+    void handleSenderFailedExceptionShouldReturnPermanentFailureWhenInvalidAndNotValidUnsent() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -125,7 +125,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldReturnTemporaryFailureWhenValidUnsent() throws Exception {
+    void handleSenderFailedExceptionShouldReturnTemporaryFailureWhenValidUnsent() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -142,7 +142,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldReturnTemporaryFailureWhenInvalidAndValidUnsent() throws Exception {
+    void handleSenderFailedExceptionShouldReturnTemporaryFailureWhenInvalidAndValidUnsent() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -159,7 +159,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldSetRecipientToInvalidWhenOnlyInvalid() throws Exception {
+    void handleSenderFailedExceptionShouldSetRecipientToInvalidWhenOnlyInvalid() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -176,7 +176,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldSetRecipientToValidUnsentWhenOnlyValidUnsent() throws Exception {
+    void handleSenderFailedExceptionShouldSetRecipientToValidUnsentWhenOnlyValidUnsent() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -193,7 +193,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldSetRecipientToValidUnsentWhenValidUnsentAndInvalid() throws Exception {
+    void handleSenderFailedExceptionShouldSetRecipientToValidUnsentWhenValidUnsentAndInvalid() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -210,7 +210,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void handleSenderFailedExceptionShouldBounceInvalidAddressesOnBothInvalidAndValidUnsent() throws Exception {
+    void handleSenderFailedExceptionShouldBounceInvalidAddressesOnBothInvalidAndValidUnsent() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         Address[] validSent = {};
@@ -228,7 +228,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldReturnTemporaryFailureOnTemporaryResolutionException() throws Exception {
+    void deliverShouldReturnTemporaryFailureOnTemporaryResolutionException() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         when(dnsHelper.retrieveHostAddressIterator(MailAddressFixture.JAMES_APACHE_ORG)).thenThrow(new TemporaryResolutionException());
@@ -239,7 +239,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldReturnTemporaryErrorWhenFirstDNSProblem() throws Exception {
+    void deliverShouldReturnTemporaryErrorWhenFirstDNSProblem() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> empty = ImmutableList.<HostAddress>of().iterator();
@@ -251,7 +251,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldReturnTemporaryErrorWhenToleratedDNSProblem() throws Exception {
+    void deliverShouldReturnTemporaryErrorWhenToleratedDNSProblem() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
         DeliveryRetriesHelper.incrementRetries(mail);
 
@@ -264,7 +264,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldReturnPermanentErrorWhenLimitDNSProblemReached() throws Exception {
+    void deliverShouldReturnPermanentErrorWhenLimitDNSProblemReached() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
         DeliveryRetriesHelper.incrementRetries(mail);
         DeliveryRetriesHelper.incrementRetries(mail);
@@ -279,7 +279,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldReturnPermanentErrorWhenLimitDNSProblemExceeded() throws Exception {
+    void deliverShouldReturnPermanentErrorWhenLimitDNSProblemExceeded() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         DeliveryRetriesHelper.incrementRetries(mail);
@@ -296,7 +296,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldWork() throws Exception {
+    void deliverShouldWork() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> dnsEntries = ImmutableList.of(
@@ -312,7 +312,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldAbortWhenServerError() throws Exception {
+    void deliverShouldAbortWhenServerError() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> dnsEntries = ImmutableList.of(
@@ -328,7 +328,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldAbortWithTemporaryWhenMessagingExceptionCauseUnknown() throws Exception {
+    void deliverShouldAbortWithTemporaryWhenMessagingExceptionCauseUnknown() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> dnsEntries = ImmutableList.of(
@@ -344,7 +344,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldTryTwiceOnIOException() throws Exception {
+    void deliverShouldTryTwiceOnIOException() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> dnsEntries = ImmutableList.of(
@@ -362,7 +362,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldAbortWhenServerErrorSFE() throws Exception {
+    void deliverShouldAbortWhenServerErrorSFE() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> dnsEntries = ImmutableList.of(
@@ -378,7 +378,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldAttemptDeliveryOnlyOnceIfNoMoreValidUnsent() throws Exception {
+    void deliverShouldAttemptDeliveryOnlyOnceIfNoMoreValidUnsent() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
 
         UnmodifiableIterator<HostAddress> dnsEntries = ImmutableList.of(
@@ -394,7 +394,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldAttemptDeliveryOnBothMXIfStillRecipients() throws Exception {
+    void deliverShouldAttemptDeliveryOnBothMXIfStillRecipients() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
         Address[] validSent = {};
         Address[] validUnsent = {new InternetAddress(MailAddressFixture.OTHER_AT_JAMES.asString())};
@@ -418,7 +418,7 @@ public class MailDelivrerTest {
     }
 
     @Test
-    public void deliverShouldWorkIfOnlyMX2Valid() throws Exception {
+    void deliverShouldWorkIfOnlyMX2Valid() throws Exception {
         Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build();
         Address[] validSent = {};
         Address[] validUnsent = {new InternetAddress(MailAddressFixture.OTHER_AT_JAMES.asString())};
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryRunningTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryRunningTest.java
index b059efa..cb39c37 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryRunningTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryRunningTest.java
@@ -34,22 +34,22 @@ import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.james.queue.api.MailQueueName;
 import org.apache.james.transport.mailets.RemoteDelivery;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import reactor.core.publisher.Flux;
 
-public class RemoteDeliveryRunningTest {
+class RemoteDeliveryRunningTest {
     private static final MailQueueName QUEUE_NAME = MailQueueName.of("queueName");
 
     private RemoteDelivery remoteDelivery;
     private MailQueue mailQueue;
     private CountDownLatch countDownLatch;
 
-    @Before
+    @BeforeEach
     @SuppressWarnings("unchecked")
-    public void setUp() throws Exception {
+    void setUp() throws Exception {
         countDownLatch = new CountDownLatch(1);
         MailQueueFactory<MailQueue> mailQueueFactory = mock(MailQueueFactory.class);
         remoteDelivery = new RemoteDelivery(mock(DNSService.class), mock(DomainList.class), mailQueueFactory,
@@ -60,7 +60,7 @@ public class RemoteDeliveryRunningTest {
     }
 
     @Test
-    public void remoteDeliveryShouldStart() throws Exception {
+    void remoteDeliveryShouldStart() throws Exception {
         when(mailQueue.deQueue()).thenAnswer(invocation -> {
             countDownLatch.countDown();
             Thread.sleep(TimeUnit.SECONDS.toMillis(2));
@@ -75,9 +75,8 @@ public class RemoteDeliveryRunningTest {
         verify(mailQueue).deQueue();
     }
 
-    @After
-    public void tearDown() {
+    @AfterEach
+    void tearDown() {
         remoteDelivery.destroy();
     }
-
 }
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryTest.java
index cfcc648..947e052 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remote/delivery/RemoteDeliveryTest.java
@@ -47,8 +47,8 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -97,7 +97,7 @@ public class RemoteDeliveryTest {
     private RemoteDelivery remoteDelivery;
     private ManageableMailQueue mailQueue;
 
-    @Before
+    @BeforeEach
     public void setUp() throws ConfigurationException {
         MailQueueFactory<? extends ManageableMailQueue> queueFactory = new MemoryMailQueueFactory(new RawMailQueueItemDecoratorFactory());
         mailQueue = queueFactory.createQueue(RemoteDeliveryConfiguration.DEFAULT_OUTGOING_QUEUE_NAME);
@@ -109,7 +109,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldAddEmailToSpool() throws Exception {
+    void remoteDeliveryShouldAddEmailToSpool() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .build());
 
@@ -128,7 +128,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldSplitMailsByServerWhenNoGateway() throws Exception {
+    void remoteDeliveryShouldSplitMailsByServerWhenNoGateway() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .build());
 
@@ -154,7 +154,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldNotSplitMailsByServerWhenGateway() throws Exception {
+    void remoteDeliveryShouldNotSplitMailsByServerWhenGateway() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .setProperty(RemoteDeliveryConfiguration.GATEWAY, MailAddressFixture.JAMES_LOCAL)
             .build());
@@ -177,7 +177,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldGhostMails() throws Exception {
+    void remoteDeliveryShouldGhostMails() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .build());
 
@@ -188,7 +188,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldAddPriorityIfSpecified() throws Exception {
+    void remoteDeliveryShouldAddPriorityIfSpecified() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .setProperty(RemoteDeliveryConfiguration.USE_PRIORITY, "true")
             .build());
@@ -208,7 +208,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldNotForwardMailsWithNoRecipients() throws Exception {
+    void remoteDeliveryShouldNotForwardMailsWithNoRecipients() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .build());
 
@@ -220,7 +220,7 @@ public class RemoteDeliveryTest {
     }
 
     @Test
-    public void remoteDeliveryShouldNotForwardMailsWithNoRecipientsWithGateway() throws Exception {
+    void remoteDeliveryShouldNotForwardMailsWithNoRecipientsWithGateway() throws Exception {
         remoteDelivery.init(FakeMailetConfig.builder()
             .setProperty(RemoteDeliveryConfiguration.GATEWAY, MailAddressFixture.JAMES_LOCAL)
             .build());
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtLeastPriorityTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtLeastPriorityTest.java
index ff7960d..9b71246 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtLeastPriorityTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtLeastPriorityTest.java
@@ -30,10 +30,10 @@ import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeValue;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class AtLeastPriorityTest {
+class AtLeastPriorityTest {
     protected AtLeastPriority matcher;
     protected MailAddress testRecipient;
     private final String condition = "5";
@@ -46,8 +46,8 @@ public class AtLeastPriorityTest {
         return fakeMail;
     }
 
-    @Before
-    public void setup() throws MessagingException {
+    @BeforeEach
+    void setup() throws MessagingException {
         this.matcher = new AtLeastPriority();
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
                 .matcherName(matcher.getPriorityMatcherName())
@@ -59,7 +59,7 @@ public class AtLeastPriorityTest {
     }
 
     @Test
-    public void shouldNotMatchWhenPriorityDoesNotMatch() throws MessagingException {
+    void shouldNotMatchWhenPriorityDoesNotMatch() throws MessagingException {
         FakeMail fakeMail = createFakeMail(3);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
@@ -68,7 +68,7 @@ public class AtLeastPriorityTest {
     }
 
     @Test
-    public void shouldMatchWhenPriorityMatch() throws MessagingException {
+    void shouldMatchWhenPriorityMatch() throws MessagingException {
         FakeMail fakeMail = createFakeMail(5);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
@@ -77,7 +77,7 @@ public class AtLeastPriorityTest {
     }
 
     @Test
-    public void shouldMatchWhenMailHasHigherPriority() throws MessagingException {
+    void shouldMatchWhenMailHasHigherPriority() throws MessagingException {
         FakeMail fakeMail = createFakeMail(7);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtMostPriorityTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtMostPriorityTest.java
index ef508e0..447d970 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtMostPriorityTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/AtMostPriorityTest.java
@@ -30,10 +30,10 @@ import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeValue;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class AtMostPriorityTest {
+class AtMostPriorityTest {
     protected AtMostPriority matcher;
     protected MailAddress testRecipient;
     private final String condition = "5";
@@ -46,8 +46,8 @@ public class AtMostPriorityTest {
         return fakeMail;
     }
 
-    @Before
-    public void setup() throws MessagingException {
+    @BeforeEach
+    void setup() throws MessagingException {
         this.matcher = new AtMostPriority();
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
                 .matcherName(matcher.getPriorityMatcherName())
@@ -59,7 +59,7 @@ public class AtMostPriorityTest {
     }
 
     @Test
-    public void shouldMatchWhenMailHasLowerPriority() throws MessagingException {
+    void shouldMatchWhenMailHasLowerPriority() throws MessagingException {
         FakeMail fakeMail = this.createFakeMail(3);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
@@ -68,7 +68,7 @@ public class AtMostPriorityTest {
     }
 
     @Test
-    public void shouldMatchWhenPriorityMatch() throws MessagingException {
+    void shouldMatchWhenPriorityMatch() throws MessagingException {
         FakeMail fakeMail = this.createFakeMail(5);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
@@ -77,7 +77,7 @@ public class AtMostPriorityTest {
     }
 
     @Test
-    public void shouldNotMatchWhenPriorityDoesNotMatch() throws MessagingException {
+    void shouldNotMatchWhenPriorityDoesNotMatch() throws MessagingException {
         FakeMail fakeMail = this.createFakeMail(7);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/HasPriorityTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/HasPriorityTest.java
index 92ec67a..ec9bcf1 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/HasPriorityTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/HasPriorityTest.java
@@ -30,8 +30,8 @@ import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeValue;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class HasPriorityTest {
     protected HasPriority matcher;
@@ -46,8 +46,8 @@ public class HasPriorityTest {
         return fakeMail;
     }
 
-    @Before
-    public void setup() throws MessagingException {
+    @BeforeEach
+    void setup() throws MessagingException {
         this.matcher = new HasPriority();
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
                 .matcherName(matcher.getPriorityMatcherName())
@@ -59,7 +59,7 @@ public class HasPriorityTest {
     }
 
     @Test
-    public void shouldMatchWhenPriorityMatch() throws MessagingException {
+    void shouldMatchWhenPriorityMatch() throws MessagingException {
         FakeMail fakeMail = this.createFakeMail(5);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
@@ -68,7 +68,7 @@ public class HasPriorityTest {
     }
 
     @Test
-    public void shouldNotMatchWhenPriorityDoesNotMatch() throws MessagingException {
+    void shouldNotMatchWhenPriorityDoesNotMatch() throws MessagingException {
         FakeMail fakeMail = this.createFakeMail(7);
 
         Collection<MailAddress> actual = matcher.match(fakeMail);
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
index 1382669..5f4948b 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
@@ -32,14 +32,14 @@ import org.apache.james.dnsservice.api.mock.MockDNSService;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class InSpammerBlacklistTest {
-
-    private InSpammerBlacklist matcher;
+class InSpammerBlacklistTest {
     private static final String BLACKLIST = "my.black.list.";
     private static final StringBuffer LISTED_HOST = new StringBuffer("111.222.111.222");
 
+    private InSpammerBlacklist matcher;
+
     private DNSService setUpDNSServer() {
         return new MockDNSService() {
 
@@ -75,7 +75,7 @@ public class InSpammerBlacklistTest {
     }
 
     @Test
-    public void testInBlackList() throws MessagingException {
+    void testInBlackList() throws MessagingException {
         Mail mail = createMail(LISTED_HOST.toString());
         setupMatcher(BLACKLIST);
 
@@ -86,7 +86,7 @@ public class InSpammerBlacklistTest {
     }
 
     @Test
-    public void testNotInBlackList() throws MessagingException {
+    void testNotInBlackList() throws MessagingException {
         Mail mail = createMail("212.12.14.1");
         setupMatcher(BLACKLIST);
 
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsMarkedAsSpamTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsMarkedAsSpamTest.java
index 4d3210d..7eaf2b4 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsMarkedAsSpamTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsMarkedAsSpamTest.java
@@ -26,20 +26,19 @@ import org.apache.james.core.MailAddress;
 import org.apache.mailet.Attribute;
 import org.apache.mailet.PerRecipientHeaders;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class IsMarkedAsSpamTest {
-
     private IsMarkedAsSpam matcher;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         matcher = new IsMarkedAsSpam();
     }
 
     @Test
-    public void isMarkedAsSpamShouldNotMatchWhenNoHeader() throws Exception {
+    void isMarkedAsSpamShouldNotMatchWhenNoHeader() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
@@ -51,7 +50,7 @@ public class IsMarkedAsSpamTest {
     }
 
     @Test
-    public void isMarkedAsSpamShouldNotMatchWhenHeaderButEmptyValue() throws Exception {
+    void isMarkedAsSpamShouldNotMatchWhenHeaderButEmptyValue() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
@@ -68,7 +67,7 @@ public class IsMarkedAsSpamTest {
     }
 
     @Test
-    public void isMarkedAsSpamShouldNotMatchWhenHeaderButOtherValue() throws Exception {
+    void isMarkedAsSpamShouldNotMatchWhenHeaderButOtherValue() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
@@ -85,7 +84,7 @@ public class IsMarkedAsSpamTest {
     }
 
     @Test
-    public void isMarkedAsSpamShouldNotMatchWhenHeaderButNoValue() throws Exception {
+    void isMarkedAsSpamShouldNotMatchWhenHeaderButNoValue() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
@@ -102,7 +101,7 @@ public class IsMarkedAsSpamTest {
     }
 
     @Test
-    public void isMarkedAsSpamShouldMatchWhenHeaderAndYesValue() throws Exception {
+    void isMarkedAsSpamShouldMatchWhenHeaderAndYesValue() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
@@ -120,7 +119,7 @@ public class IsMarkedAsSpamTest {
     }
 
     @Test
-    public void isMarkedAsSpamShouldMatchOnlyRecipientsWithHeaderAndYesValue() throws Exception {
+    void isMarkedAsSpamShouldMatchOnlyRecipientsWithHeaderAndYesValue() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
@@ -137,7 +136,7 @@ public class IsMarkedAsSpamTest {
     }
 
     @Test
-    public void isMarkedAsSpamShouldMatchWhenHeaderAndYesValueInOtherCase() throws Exception {
+    void isMarkedAsSpamShouldMatchWhenHeaderAndYesValueInOtherCase() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .sender("sender@james.org")
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
index 34b39b0..b9528fb 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
@@ -38,8 +38,8 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class IsOverQuotaTest {
     private IsOverQuota testee;
@@ -47,7 +47,7 @@ public class IsOverQuotaTest {
     private DefaultUserQuotaRootResolver quotaRootResolver;
     private UsersRepository usersRepository;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         InMemoryIntegrationResources resources = InMemoryIntegrationResources.defaultResources();
 
@@ -64,7 +64,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldAcceptMailWhenNoQuota() throws Exception {
+    void matchShouldAcceptMailWhenNoQuota() throws Exception {
         FakeMail mail = FakeMail.builder()
             .name("name")
             .recipient(MailAddressFixture.ANY_AT_JAMES)
@@ -76,7 +76,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldKeepAddressesWithTooBigSize() throws Exception {
+    void matchShouldKeepAddressesWithTooBigSize() throws Exception {
         maxQuotaManager.setGlobalMaxStorage(QuotaSizeLimit.size(100));
 
         FakeMail fakeMail = FakeMail.builder()
@@ -90,7 +90,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldReturnEmptyAtSizeQuotaLimit() throws Exception {
+    void matchShouldReturnEmptyAtSizeQuotaLimit() throws Exception {
         maxQuotaManager.setGlobalMaxStorage(QuotaSizeLimit.size(1000));
 
         FakeMail fakeMail = FakeMail.builder()
@@ -104,7 +104,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldKeepAddressesWithTooMuchMessages() throws Exception {
+    void matchShouldKeepAddressesWithTooMuchMessages() throws Exception {
         maxQuotaManager.setGlobalMaxMessage(QuotaCountLimit.count(0));
 
         FakeMail fakeMail = FakeMail.builder()
@@ -117,7 +117,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldReturnEmptyOnMessageLimit() throws Exception {
+    void matchShouldReturnEmptyOnMessageLimit() throws Exception {
         maxQuotaManager.setGlobalMaxMessage(QuotaCountLimit.count(1));
 
         FakeMail fakeMail = FakeMail.builder()
@@ -130,7 +130,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldNotIncludeRecipientNotOverQuota() throws Exception {
+    void matchShouldNotIncludeRecipientNotOverQuota() throws Exception {
         Username username = Username.of(MailAddressFixture.ANY_AT_JAMES.getLocalPart());
         QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(MailboxPath.inbox(username));
         maxQuotaManager.setMaxStorage(quotaRoot, QuotaSizeLimit.size(100));
@@ -147,7 +147,7 @@ public class IsOverQuotaTest {
     }
 
     @Test
-    public void matchShouldSupportVirtualHosting() throws Exception {
+    void matchShouldSupportVirtualHosting() throws Exception {
         when(usersRepository.getUsername(MailAddressFixture.ANY_AT_JAMES)).thenReturn(Username.of(MailAddressFixture.ANY_AT_JAMES.asString()));
         when(usersRepository.getUsername(MailAddressFixture.OTHER_AT_JAMES)).thenReturn(Username.of(MailAddressFixture.OTHER_AT_JAMES.asString()));
         Username username = Username.of(MailAddressFixture.ANY_AT_JAMES.asString());
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsSenderInRRTLoopTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsSenderInRRTLoopTest.java
index f0ca51d..775be5f 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsSenderInRRTLoopTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsSenderInRRTLoopTest.java
@@ -35,17 +35,17 @@ import org.apache.james.rrt.api.RecipientRewriteTableConfiguration;
 import org.apache.james.rrt.lib.MappingSource;
 import org.apache.james.rrt.memory.MemoryRecipientRewriteTable;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IsSenderInRRTLoopTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+class IsSenderInRRTLoopTest {
     public static final Domain DOMAIN = Domain.of("domain.tld");
+
     private RecipientRewriteTable recipientRewriteTable;
     private IsSenderInRRTLoop testee;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         recipientRewriteTable = new MemoryRecipientRewriteTable();
         SimpleDomainList domainList = new SimpleDomainList();
         domainList.addDomain(DOMAIN);
@@ -56,7 +56,7 @@ public class IsSenderInRRTLoopTest {
     }
 
     @Test
-    public void matchShouldReturnEmptyWhenSenderHasNoRRT() throws Exception {
+    void matchShouldReturnEmptyWhenSenderHasNoRRT() throws Exception {
         Collection<MailAddress> result = testee.match(FakeMail.builder()
             .name("name")
             .sender(SENDER)
@@ -67,7 +67,7 @@ public class IsSenderInRRTLoopTest {
     }
 
     @Test
-    public void matchShouldNotFailWhenNoSender() throws Exception {
+    void matchShouldNotFailWhenNoSender() throws Exception {
         Collection<MailAddress> result = testee.match(FakeMail.builder()
             .name("name")
             .recipient(RECIPIENT1)
@@ -77,7 +77,7 @@ public class IsSenderInRRTLoopTest {
     }
 
     @Test
-    public void matchShouldReturnEmptyWhenNoRRTLoop() throws Exception {
+    void matchShouldReturnEmptyWhenNoRRTLoop() throws Exception {
         recipientRewriteTable.addAddressMapping(MappingSource.fromUser(SENDER.getLocalPart(), SENDER.getDomain()), RECIPIENT1.asString());
 
         Collection<MailAddress> result = testee.match(FakeMail.builder()
@@ -90,7 +90,7 @@ public class IsSenderInRRTLoopTest {
     }
 
     @Test
-    public void matchShouldReturnRecipientsWhenLoop() throws Exception {
+    void matchShouldReturnRecipientsWhenLoop() throws Exception {
         recipientRewriteTable.addAddressMapping(MappingSource.fromUser(SENDER.getLocalPart(), SENDER.getDomain()),"recipient1@domain.tld");
         recipientRewriteTable.addAddressMapping(MappingSource.fromUser(RECIPIENT1.getLocalPart(), RECIPIENT1.getDomain()), SENDER.asString());
         // required overwise the loop is detected upon insertion
@@ -106,7 +106,7 @@ public class IsSenderInRRTLoopTest {
     }
 
     @Test
-    public void matchShouldReturnEmptyWhenLoopButNoRecipient() throws Exception {
+    void matchShouldReturnEmptyWhenLoopButNoRecipient() throws Exception {
         recipientRewriteTable.addAddressMapping(MappingSource.fromUser(SENDER.getLocalPart(), SENDER.getDomain()),"recipient1@domain.tld");
         recipientRewriteTable.addAddressMapping(MappingSource.fromUser(RECIPIENT1.getLocalPart(), RECIPIENT1.getDomain()), SENDER.asString());
         // required overwise the loop is detected upon insertion
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
index 68007e9..8503be4 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
@@ -29,15 +29,15 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.InMemoryDNSService;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class RemoteAddrInNetworkTest {
     private RemoteAddrInNetwork matcher;
     private FakeMail fakeMail;
     private MailAddress testRecipient;
 
-    @Before
+    @BeforeEach
     public void setup() throws Exception {
         DNSService dnsServer = new InMemoryDNSService()
             .registerMxRecord("192.168.0.1", "192.168.0.1")
@@ -56,7 +56,7 @@ public class RemoteAddrInNetworkTest {
     }
 
     @Test
-    public void shouldMatchWhenOnSameNetwork() throws MessagingException {
+    void shouldMatchWhenOnSameNetwork() throws MessagingException {
         fakeMail = FakeMail.builder()
                 .name("name")
                 .recipient(testRecipient)
@@ -69,7 +69,7 @@ public class RemoteAddrInNetworkTest {
     }
 
     @Test
-    public void shouldNotMatchWhenOnDifferentNetwork() throws MessagingException {
+    void shouldNotMatchWhenOnDifferentNetwork() throws MessagingException {
         fakeMail = FakeMail.builder()
                 .name("name")
                 .recipient(testRecipient)
@@ -82,7 +82,7 @@ public class RemoteAddrInNetworkTest {
     }
 
     @Test
-    public void shouldNotMatchWhenNoCondition() throws MessagingException {
+    void shouldNotMatchWhenNoCondition() throws MessagingException {
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
                 .matcherName("")
                 .build();
@@ -101,7 +101,7 @@ public class RemoteAddrInNetworkTest {
     }
 
     @Test
-    public void shouldNotMatchWhenInvalidAddress() throws MessagingException {
+    void shouldNotMatchWhenInvalidAddress() throws MessagingException {
         fakeMail = FakeMail.builder()
                 .name("name")
                 .recipient(testRecipient)
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
index 26db723..34ffd1c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
@@ -29,17 +29,17 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.InMemoryDNSService;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RemoteAddrNotInNetworkTest {
+class RemoteAddrNotInNetworkTest {
     private RemoteAddrNotInNetwork matcher;
     private FakeMail fakeMail;
     private MailAddress testRecipient;
     private FakeMatcherConfig matcherConfig;
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() throws Exception {
         DNSService dnsServer = new InMemoryDNSService()
             .registerMxRecord("192.168.0.1", "192.168.0.1")
             .registerMxRecord("192.168.200.1", "192.168.200.1")
@@ -57,7 +57,7 @@ public class RemoteAddrNotInNetworkTest {
     }
 
     @Test
-    public void shouldMatchWhenOnDifferentNetwork() throws MessagingException {
+    void shouldMatchWhenOnDifferentNetwork() throws MessagingException {
         fakeMail = FakeMail.builder()
                 .name("name")
                 .recipient(testRecipient)
@@ -70,7 +70,7 @@ public class RemoteAddrNotInNetworkTest {
     }
 
     @Test
-    public void shouldNotMatchWhenOnSameNetwork() throws MessagingException {
+    void shouldNotMatchWhenOnSameNetwork() throws MessagingException {
         fakeMail = FakeMail.builder()
                 .name("name")
                 .recipient(testRecipient)
@@ -83,7 +83,7 @@ public class RemoteAddrNotInNetworkTest {
     }
 
     @Test
-    public void shouldMatchWhenNoCondition() throws MessagingException {
+    void shouldMatchWhenNoCondition() throws MessagingException {
         matcherConfig = FakeMatcherConfig.builder()
                 .matcherName("")
                 .build();
@@ -102,7 +102,7 @@ public class RemoteAddrNotInNetworkTest {
     }
 
     @Test
-    public void shouldMatchWhenInvalidAddress() throws MessagingException {
+    void shouldMatchWhenInvalidAddress() throws MessagingException {
         fakeMail = FakeMail.builder()
                 .name("name")
                 .recipient(testRecipient)
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
index 82a5e5c..384547c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
@@ -29,24 +29,23 @@ import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class RecipientsUtilsTest {
-
+class RecipientsUtilsTest {
     private RedirectNotify mailet;
     private RecipientsUtils testee;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = mock(RedirectNotify.class);
         testee = RecipientsUtils.from(mailet);
     }
 
     @Test
-    public void getRecipientsShouldReturnEmptyWhenMailetRecipientsIsEmpty() throws Exception {
+    void getRecipientsShouldReturnEmptyWhenMailetRecipientsIsEmpty() throws Exception {
         when(mailet.getRecipients())
             .thenReturn(ImmutableList.<MailAddress>of());
 
@@ -58,7 +57,7 @@ public class RecipientsUtilsTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnEmptyWhenMailetRecipientsContainsOnlyUnaltered() throws Exception {
+    void getRecipientsShouldReturnEmptyWhenMailetRecipientsContainsOnlyUnaltered() throws Exception {
         when(mailet.getRecipients())
             .thenReturn(ImmutableList.of(SpecialAddress.UNALTERED));
 
@@ -70,7 +69,7 @@ public class RecipientsUtilsTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnEmptyWhenMailetRecipientsContainsOnlyRecipients() throws Exception {
+    void getRecipientsShouldReturnEmptyWhenMailetRecipientsContainsOnlyRecipients() throws Exception {
         when(mailet.getRecipients())
             .thenReturn(ImmutableList.of(SpecialAddress.RECIPIENTS));
 
@@ -82,7 +81,7 @@ public class RecipientsUtilsTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnRecipientsWhenMailetRecipientsAreCommon() throws Exception {
+    void getRecipientsShouldReturnRecipientsWhenMailetRecipientsAreCommon() throws Exception {
         ImmutableList<MailAddress> expectedRecipients = ImmutableList.of(new MailAddress("test", "james.org"), new MailAddress("test2", "james.org"));
         when(mailet.getRecipients())
             .thenReturn(expectedRecipients);
@@ -95,7 +94,7 @@ public class RecipientsUtilsTest {
     }
 
     @Test
-    public void getRecipientsShouldReturnAddressesFromOriginalMailWhenMailetRecipientsAreSpecialAddresses() throws Exception {
+    void getRecipientsShouldReturnAddressesFromOriginalMailWhenMailetRecipientsAreSpecialAddresses() throws Exception {
         when(mailet.getRecipients())
             .thenReturn(ImmutableList.of(SpecialAddress.FROM, SpecialAddress.TO));
 
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
index 7527521..e769849 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
@@ -25,12 +25,11 @@ import java.util.Optional;
 import org.apache.james.core.MailAddress;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
-
-public class ReplyToUtilsTest {
+import org.junit.jupiter.api.Test;
 
+class ReplyToUtilsTest {
     @Test
-    public void getReplyToShouldReturnAbsentWhenReplyToIsNull() throws Exception {
+    void getReplyToShouldReturnAbsentWhenReplyToIsNull() throws Exception {
         ReplyToUtils testee = ReplyToUtils.from((MailAddress) null);
 
         FakeMail fakeMail = FakeMail.defaultFakeMail();
@@ -41,7 +40,7 @@ public class ReplyToUtilsTest {
     }
 
     @Test
-    public void getReplyToShouldReturnNullWhenReplyToEqualsToUnaltered() throws Exception {
+    void getReplyToShouldReturnNullWhenReplyToEqualsToUnaltered() throws Exception {
         ReplyToUtils testee = ReplyToUtils.from(SpecialAddress.UNALTERED);
 
         FakeMail fakeMail = FakeMail.defaultFakeMail();
@@ -52,7 +51,7 @@ public class ReplyToUtilsTest {
     }
 
     @Test
-    public void getReplyToShouldReturnSenderWhenReplyToIsCommon() throws Exception {
+    void getReplyToShouldReturnSenderWhenReplyToIsCommon() throws Exception {
         MailAddress mailAddress = new MailAddress("test", "james.org");
         ReplyToUtils testee = ReplyToUtils.from(mailAddress);
 
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
index cde6b4e..c0f2dc5 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
@@ -25,12 +25,11 @@ import java.util.Optional;
 import org.apache.james.core.MailAddress;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
-
-public class SenderUtilsTest {
+import org.junit.jupiter.api.Test;
 
+class SenderUtilsTest {
     @Test
-    public void getSenderShouldReturnAbsentWhenSenderIsAbsent() throws Exception {
+    void getSenderShouldReturnAbsentWhenSenderIsAbsent() throws Exception {
         SenderUtils testee = SenderUtils.from(Optional.empty());
 
         FakeMail fakeMail = FakeMail.defaultFakeMail();
@@ -41,7 +40,7 @@ public class SenderUtilsTest {
     }
 
     @Test
-    public void getSenderShouldReturnAbsentWhenSenderEqualsToUnaltered() throws Exception {
+    void getSenderShouldReturnAbsentWhenSenderEqualsToUnaltered() throws Exception {
         SenderUtils testee = SenderUtils.from(Optional.of(SpecialAddress.UNALTERED));
 
         FakeMail fakeMail = FakeMail.defaultFakeMail();
@@ -52,7 +51,7 @@ public class SenderUtilsTest {
     }
 
     @Test
-    public void getSenderShouldReturnAbsentWhenSenderEqualsToSender() throws Exception {
+    void getSenderShouldReturnAbsentWhenSenderEqualsToSender() throws Exception {
         SenderUtils testee = SenderUtils.from(Optional.of(SpecialAddress.SENDER));
 
         FakeMail fakeMail = FakeMail.defaultFakeMail();
@@ -63,7 +62,7 @@ public class SenderUtilsTest {
     }
 
     @Test
-    public void getSenderShouldReturnSenderWhenSenderIsCommon() throws Exception {
+    void getSenderShouldReturnSenderWhenSenderIsCommon() throws Exception {
         MailAddress expectedMailAddress = new MailAddress("sender", "james.org");
         SenderUtils testee = SenderUtils.from(Optional.of(expectedMailAddress));
 
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SizeUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SizeUtilsTest.java
index 3ca8700..b6a3644 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SizeUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SizeUtilsTest.java
@@ -22,52 +22,51 @@ package org.apache.james.transport.util;
 import static org.apache.james.transport.util.SizeUtils.humanReadableSize;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Test;
-
-public class SizeUtilsTest {
+import org.junit.jupiter.api.Test;
 
+class SizeUtilsTest {
     @Test
-    public void humanSizeShouldAddByteUnitForSmallSize() {
+    void humanSizeShouldAddByteUnitForSmallSize() {
         assertThat(humanReadableSize(1000)).isEqualTo("1000 B");
     }
 
     @Test
-    public void humanSizeShouldScaleToKilobyteWhenSizeIsBetweenKilobyteAndMegabyte() {
+    void humanSizeShouldScaleToKilobyteWhenSizeIsBetweenKilobyteAndMegabyte() {
         assertThat(humanReadableSize(1024)).isEqualTo("1 KiB");
     }
 
     @Test
-    public void humanSizeShouldWorkWithZero() {
+    void humanSizeShouldWorkWithZero() {
         assertThat(humanReadableSize(0)).isEqualTo("0 B");
     }
 
     @Test
-    public void humanSizeShouldWorkWithNegative() {
+    void humanSizeShouldWorkWithNegative() {
         assertThat(humanReadableSize(-1)).isEqualTo("-1 B");
     }
 
     @Test
-    public void humanSizeShouldScaleToMegabyteWhenSizeIsBetweenMegabyteAndGigabyte() {
+    void humanSizeShouldScaleToMegabyteWhenSizeIsBetweenMegabyteAndGigabyte() {
         assertThat(humanReadableSize(1024 * 1024)).isEqualTo("1 MiB");
     }
 
     @Test
-    public void humanSizeShouldScaleToGigabyteWhenSizeIsBiggerThanGigabyte() {
+    void humanSizeShouldScaleToGigabyteWhenSizeIsBiggerThanGigabyte() {
         assertThat(humanReadableSize(1024 * 1024 * 1024)).isEqualTo("1 GiB");
     }
 
     @Test
-    public void humanSizeShouldCorrectlyCountKilobyte() {
+    void humanSizeShouldCorrectlyCountKilobyte() {
         assertThat(humanReadableSize(42 * 1024)).isEqualTo("42 KiB");
     }
 
     @Test
-    public void humanSizeShouldNotUseMoreThanOneDigitAfterComma() {
+    void humanSizeShouldNotUseMoreThanOneDigitAfterComma() {
         assertThat(humanReadableSize(1.42 * 1024)).isEqualTo("1.4 KiB");
     }
 
     @Test
-    public void humanSizeShouldNotUseMoreThanOneDigitAfterCommaAndRoundUpCorrectly() {
+    void humanSizeShouldNotUseMoreThanOneDigitAfterCommaAndRoundUpCorrectly() {
         assertThat(humanReadableSize(1.48 * 1024)).isEqualTo("1.5 KiB");
     }
 }
\ No newline at end of file
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
index 66039c4..c1d3454 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
@@ -31,24 +31,23 @@ import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class TosUtilsTest {
-
+class TosUtilsTest {
     private RedirectNotify mailet;
     private TosUtils testee;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = mock(RedirectNotify.class);
         testee = TosUtils.from(mailet);
     }
 
     @Test
-    public void getToShouldReturnEmptyWhenMailetToIsEmpty() throws Exception {
+    void getToShouldReturnEmptyWhenMailetToIsEmpty() throws Exception {
         when(mailet.getTo())
             .thenReturn(ImmutableList.<InternetAddress>of());
 
@@ -60,7 +59,7 @@ public class TosUtilsTest {
     }
 
     @Test
-    public void getToShouldReturnEmptyWhenMailetToContainsOnlyUnaltered() throws Exception {
+    void getToShouldReturnEmptyWhenMailetToContainsOnlyUnaltered() throws Exception {
         when(mailet.getTo())
             .thenReturn(ImmutableList.of(SpecialAddress.UNALTERED.toInternetAddress()));
 
@@ -72,7 +71,7 @@ public class TosUtilsTest {
     }
 
     @Test
-    public void getToShouldReturnEmptyWhenMailetToContainsOnlyRecipients() throws Exception {
+    void getToShouldReturnEmptyWhenMailetToContainsOnlyRecipients() throws Exception {
         when(mailet.getTo())
             .thenReturn(ImmutableList.of(SpecialAddress.RECIPIENTS.toInternetAddress()));
 
@@ -84,7 +83,7 @@ public class TosUtilsTest {
     }
 
     @Test
-    public void getToShouldReturnToWhenMailetToAreCommon() throws Exception {
+    void getToShouldReturnToWhenMailetToAreCommon() throws Exception {
         MailAddress mailAddress = new MailAddress("test", "james.org");
         MailAddress mailAddress2 = new MailAddress("test2", "james.org");
         when(mailet.getTo())
@@ -99,7 +98,7 @@ public class TosUtilsTest {
     }
 
     @Test
-    public void getToShouldReturnAddressesFromOriginalMailWhenMailetToAreSpecialAddresses() throws Exception {
+    void getToShouldReturnAddressesFromOriginalMailWhenMailetToAreSpecialAddresses() throws Exception {
         when(mailet.getTo())
             .thenReturn(ImmutableList.of(SpecialAddress.FROM.toInternetAddress(), SpecialAddress.TO.toInternetAddress()));
 


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


[james-project] 25/33: JAMES-3491 WebSocket PUSH should support delegation

Posted by bt...@apache.org.
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 9691e2efe358a8e85c95781136982cc392f63cc7
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Fri Feb 5 11:38:54 2021 +0700

    JAMES-3491 WebSocket PUSH should support delegation
---
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 69 +++++++++++++++++++++-
 1 file changed, 67 insertions(+), 2 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index e1fcb87..750c12f 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -19,14 +19,18 @@
 package org.apache.james.jmap.rfc8621.contract
 
 import java.net.{ProtocolException, URI}
+import java.nio.charset.StandardCharsets
 
 import net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson
 import org.apache.james.GuiceJamesServer
 import org.apache.james.jmap.api.model.AccountId
 import org.apache.james.jmap.draft.JmapGuiceProbe
 import org.apache.james.jmap.rfc8621.contract.Fixture._
-import org.apache.james.mailbox.model.MailboxPath
-import org.apache.james.modules.MailboxProbeImpl
+import org.apache.james.mailbox.MessageManager.AppendCommand
+import org.apache.james.mailbox.model.MailboxACL.Right
+import org.apache.james.mailbox.model.{MailboxACL, MailboxPath}
+import org.apache.james.mime4j.dom.Message
+import org.apache.james.modules.{ACLProbeImpl, MailboxProbeImpl}
 import org.apache.james.utils.DataProbeImpl
 import org.assertj.core.api.Assertions.{assertThat, assertThatThrownBy}
 import org.junit.jupiter.api.{BeforeEach, Test}
@@ -51,6 +55,7 @@ trait WebSocketContract {
     server.getProbe(classOf[DataProbeImpl])
       .fluent()
       .addDomain(DOMAIN.asString())
+      .addUser(ANDRE.asString(), ANDRE_PASSWORD)
       .addUser(BOB.asString(), BOB_PASSWORD)
   }
 
@@ -636,6 +641,66 @@ trait WebSocketContract {
       .doesNotContain(emailStateChange)
   }
 
+  @Test
+  def pushShouldSupportDelegation(server: GuiceJamesServer): Unit = {
+    val mailboxProbe: MailboxProbeImpl = server.getProbe(classOf[MailboxProbeImpl])
+    val andrePath = MailboxPath.inbox(ANDRE)
+    mailboxProbe.createMailbox(andrePath)
+
+    server.getProbe(classOf[ACLProbeImpl])
+      .replaceRights(andrePath, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read))
+
+    Thread.sleep(100)
+
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["Mailbox", "Email"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            val message: Message = Message.Builder
+              .of
+              .setSubject("test")
+              .setBody("testmail", StandardCharsets.UTF_8)
+              .build
+            mailboxProbe.appendMessage(ANDRE.asString(), andrePath, AppendCommand.from(message))
+
+            Thread.sleep(100)
+
+            List(
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                },
+              ws.receive()
+                .map { case t: Text =>
+                  t.payload
+                })
+        })
+        .send(backend)
+        .body
+
+    Thread.sleep(100)
+
+    val jmapGuiceProbe: JmapGuiceProbe = server.getProbe(classOf[JmapGuiceProbe])
+    val accountId: AccountId = AccountId.fromUsername(BOB)
+    val emailState: String = jmapGuiceProbe.getLatestEmailStateWithDelegation(accountId).getValue.toString
+    val mailboxState: String = jmapGuiceProbe.getLatestMailboxStateWithDelegation(accountId).getValue.toString
+
+    val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(2) // email notification + mailbox notification
+      .contains(mailboxStateChange, emailStateChange)
+  }
+
   private def authenticatedRequest(server: GuiceJamesServer): RequestT[Identity, Either[String, String], Any] = {
     val port = server.getProbe(classOf[JmapGuiceProbe])
       .getJmapPort


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


[james-project] 05/33: [REFACTORING] Get rid of some JUNIT 4 usages in onami tests

Posted by bt...@apache.org.
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 492641111691ceba89839516a92ac3c031331d9d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 10:03:01 2021 +0700

    [REFACTORING] Get rid of some JUNIT 4 usages in onami tests
---
 .../apache/james/onami/lifecycle/DefaultStagerTestCase.java    |  9 ++++-----
 .../apache/james/onami/lifecycle/MultiLifeCycleTestCase.java   | 10 +++++-----
 .../org/apache/james/onami/lifecycle/StagingOrderTestCase.java |  8 ++++----
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
index ff1b81e..1017dd1 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
@@ -23,12 +23,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.junit.Test;
-
-public class DefaultStagerTestCase {
+import org.junit.jupiter.api.Test;
 
+class DefaultStagerTestCase {
     @Test
-    public void stagerShouldStageObjectsRegisteredWhileStaging() {
+    void stagerShouldStageObjectsRegisteredWhileStaging() {
         final Stager<TestAnnotationA> stager = new DefaultStager<>(TestAnnotationA.class);
         final AtomicBoolean staged = new AtomicBoolean();
         stager.register(stageHandler1 -> stager
@@ -47,7 +46,7 @@ public class DefaultStagerTestCase {
      * 3. the thread blocks on the lock in DefaultStager.register()
      */
     @Test
-    public void stagerShouldNotDeadlockWhileStagingObjectChains() {
+    void stagerShouldNotDeadlockWhileStagingObjectChains() {
         final AtomicBoolean staged = new AtomicBoolean();
         final Stager<TestAnnotationA> stager = new DefaultStager<>(TestAnnotationA.class);
         stager.register(stageHandler1 -> {
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
index 5d60a53..93e10fc 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
@@ -28,16 +28,16 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Module;
 
-public class MultiLifeCycleTestCase {
+class MultiLifeCycleTestCase {
     @Test
-    public void testOrdering() {
+    void testOrdering() {
         Module lifeCycleModule = new TestLifeCycleModule(asList(TestAnnotationA.class, TestAnnotationB.class, TestAnnotationC.class));
         MultiLifeCycleObject obj = Guice.createInjector(lifeCycleModule).getInstance(MultiLifeCycleObject.class);
         assertThat(obj.toString()).isEqualTo("aaabbbc");
@@ -51,7 +51,7 @@ public class MultiLifeCycleTestCase {
     }
 
     @Test
-    public void testStaging() {
+    void testStaging() {
         Module moduleA = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationA.class));
         Module moduleB = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationB.class));
         Module moduleC = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationC.class));
@@ -72,7 +72,7 @@ public class MultiLifeCycleTestCase {
     }
 
     @Test
-    public void testStagingOrdering() {
+    void testStagingOrdering() {
         Module moduleA = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationA.class, DefaultStager.Order.FIRST_IN_FIRST_OUT));
         Module moduleB = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationB.class, DefaultStager.Order.FIRST_IN_LAST_OUT));
 
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
index dbb6723..b1c66c2 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
@@ -25,11 +25,11 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class StagingOrderTestCase {
+class StagingOrderTestCase {
     @Test
-    public void testFifo() {
+    void testFifo() {
         List<Integer> order = new ArrayList<>();
         DefaultStager<TestAnnotationA> stager = makeStager(order, DefaultStager.Order.FIRST_IN_FIRST_OUT);
         stager.stage();
@@ -38,7 +38,7 @@ public class StagingOrderTestCase {
     }
 
     @Test
-    public void testFilo() {
+    void testFilo() {
         List<Integer> order = new ArrayList<>();
         DefaultStager<TestAnnotationA> stager = makeStager(order, DefaultStager.Order.FIRST_IN_LAST_OUT);
         stager.stage();


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


[james-project] 27/33: JAMES-3491 Add timeouts in WebSocketContract

Posted by bt...@apache.org.
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 6b3189a6af46731397129c1d038fc76ae7a6f83d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 14:23:43 2021 +0700

    JAMES-3491 Add timeouts in WebSocketContract
    
    If failing, this avoids waiting forever for server response
    this significantly improves the DEV experience...
---
 .../jmap/rfc8621/contract/WebSocketContract.scala      | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index 5fd55a0..e477607 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -33,7 +33,8 @@ import org.apache.james.mime4j.dom.Message
 import org.apache.james.modules.{ACLProbeImpl, MailboxProbeImpl}
 import org.apache.james.utils.DataProbeImpl
 import org.assertj.core.api.Assertions.{assertThat, assertThatThrownBy}
-import org.junit.jupiter.api.{BeforeEach, Test}
+import org.junit.jupiter.api.{BeforeEach, Test, Timeout}
+import play.api.libs.json.{JsString, Json}
 import sttp.capabilities.WebSockets
 import sttp.client3.monad.IdMonad
 import sttp.client3.okhttp.OkHttpSyncBackend
@@ -60,6 +61,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def apiRequestsShouldBeProcessed(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -105,6 +107,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def executingSeveralAPICallsShouldBePossible(server: GuiceJamesServer): Unit = {
     val response: Either[String, List[String]] =
       authenticatedRequest(server)
@@ -165,6 +168,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def apiRequestsShouldBeProcessedWhenNoRequestId(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -202,6 +206,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def nonJsonPayloadShouldTriggerError(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -226,6 +231,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def handshakeShouldBeAuthenticated(server: GuiceJamesServer): Unit = {
     assertThatThrownBy(() =>
       unauthenticatedRequest(server)
@@ -242,6 +248,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def noTypeFieldShouldTriggerError(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -280,6 +287,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def badTypeFieldShouldTriggerError(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -319,6 +327,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def unknownTypeFieldShouldTriggerError(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -358,6 +367,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def clientSendingARespondTypeFieldShouldTriggerError(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -397,6 +407,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def requestLevelErrorShouldReturnAPIError(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -433,6 +444,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def pushEnableRequestsShouldBeProcessed(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
     val accountId: AccountId = AccountId.fromUsername(BOB)
@@ -502,6 +514,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   // For client compatibility purposes
   def specifiedUnHandledDataTypesShouldNotBeRejected(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
@@ -572,6 +585,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def dataTypesShouldDefaultToAll(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
     val accountId: AccountId = AccountId.fromUsername(BOB)
@@ -641,6 +655,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def pushEnableShouldUpdatePreviousSubscriptions(server: GuiceJamesServer): Unit = {
     val bobPath = MailboxPath.inbox(BOB)
     val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
@@ -712,6 +727,7 @@ trait WebSocketContract {
   }
 
   @Test
+  @Timeout(180)
   def pushShouldSupportDelegation(server: GuiceJamesServer): Unit = {
     val mailboxProbe: MailboxProbeImpl = server.getProbe(classOf[MailboxProbeImpl])
     val andrePath = MailboxPath.inbox(ANDRE)


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


[james-project] 17/33: JAMES-3491 Have an EventBus for JMAP

Posted by bt...@apache.org.
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 b349944f46bb691208982838ec71fad79ef20a58
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Feb 3 16:06:24 2021 +0700

    JAMES-3491 Have an EventBus for JMAP
---
 .../org/apache/james/CassandraJamesServerMain.java |  2 +
 .../james/CassandraRabbitMQJamesServerMain.java    |  2 +
 .../james/modules/event/JMAPEventBusModule.java    | 92 ++++++++++++++++++++++
 .../org/apache/james/MemoryJamesServerMain.java    |  2 +
 .../modules/protocols/JmapEventBusModule.java      | 14 ++++
 .../james/jmap/change/JmapEventSerializer.scala    | 17 ++--
 .../james/jmap/change/MailboxChangeListener.scala  | 28 +++++--
 .../jmap/change/MailboxChangeListenerTest.scala    | 16 +++-
 .../java/org/apache/james/jmap/InjectionKeys.java  | 24 ++++++
 9 files changed, 179 insertions(+), 18 deletions(-)

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 40bfa50..908f486 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
@@ -46,6 +46,7 @@ import org.apache.james.modules.mailrepository.CassandraMailRepositoryModule;
 import org.apache.james.modules.metrics.CassandraMetricsModule;
 import org.apache.james.modules.protocols.IMAPServerModule;
 import org.apache.james.modules.protocols.JMAPServerModule;
+import org.apache.james.modules.protocols.JmapEventBusModule;
 import org.apache.james.modules.protocols.LMTPServerModule;
 import org.apache.james.modules.protocols.ManageSieveServerModule;
 import org.apache.james.modules.protocols.POP3ServerModule;
@@ -111,6 +112,7 @@ public class CassandraJamesServerMain implements JamesServerMain {
         new ProtocolHandlerModule(),
         new SMTPServerModule(),
         new JMAPServerModule(),
+        new JmapEventBusModule(),
         WEBADMIN);
 
     public static final Module PLUGINS = Modules.combine(
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
index c0c23d9..69c1ee5 100644
--- a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
@@ -26,6 +26,7 @@ import org.apache.james.modules.DistributedTaskSerializationModule;
 import org.apache.james.modules.blobstore.BlobStoreCacheModulesChooser;
 import org.apache.james.modules.blobstore.BlobStoreConfiguration;
 import org.apache.james.modules.blobstore.BlobStoreModulesChooser;
+import org.apache.james.modules.event.JMAPEventBusModule;
 import org.apache.james.modules.event.RabbitMQEventBusModule;
 import org.apache.james.modules.queue.rabbitmq.RabbitMQModule;
 import org.apache.james.modules.server.JMXServerModule;
@@ -40,6 +41,7 @@ public class CassandraRabbitMQJamesServerMain implements JamesServerMain {
             .override(Modules.combine(REQUIRE_TASK_MANAGER_MODULE, new DistributedTaskManagerModule()))
             .with(new RabbitMQModule(),
                 new RabbitMailQueueRoutesModule(),
+                new JMAPEventBusModule(),
                 new RabbitMQEventBusModule(),
                 new DistributedTaskSerializationModule());
 
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/event/JMAPEventBusModule.java b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/event/JMAPEventBusModule.java
new file mode 100644
index 0000000..aef6f3b
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/event/JMAPEventBusModule.java
@@ -0,0 +1,92 @@
+/****************************************************************
+ * 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.event;
+
+import javax.inject.Named;
+
+import org.apache.james.backends.rabbitmq.ReactorRabbitMQChannelPool;
+import org.apache.james.backends.rabbitmq.ReceiverProvider;
+import org.apache.james.backends.rabbitmq.SimpleConnectionPool;
+import org.apache.james.events.EventBus;
+import org.apache.james.events.EventBusId;
+import org.apache.james.events.EventDeadLetters;
+import org.apache.james.events.KeyReconnectionHandler;
+import org.apache.james.events.NamingStrategy;
+import org.apache.james.events.RabbitMQEventBus;
+import org.apache.james.events.RetryBackoffConfiguration;
+import org.apache.james.events.RoutingKeyConverter;
+import org.apache.james.jmap.InjectionKeys;
+import org.apache.james.jmap.change.Factory;
+import org.apache.james.jmap.change.JmapEventSerializer;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.utils.InitializationOperation;
+import org.apache.james.utils.InitilizationOperationBuilder;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.ProvidesIntoSet;
+import com.google.inject.name.Names;
+
+import reactor.rabbitmq.Sender;
+
+public class JMAPEventBusModule extends AbstractModule {
+    public static final NamingStrategy JMAP_NAMING_STRATEGY = new NamingStrategy("jmapEvent");
+
+    @Override
+    protected void configure() {
+        bind(EventBusId.class).annotatedWith(Names.named(InjectionKeys.JMAP)).toInstance(EventBusId.random());
+    }
+
+    @ProvidesIntoSet
+    InitializationOperation workQueue(@Named(InjectionKeys.JMAP) RabbitMQEventBus instance) {
+        return InitilizationOperationBuilder
+            .forClass(RabbitMQEventBus.class)
+            .init(instance::start);
+    }
+
+    @ProvidesIntoSet
+    SimpleConnectionPool.ReconnectionHandler provideReconnectionHandler(@Named(InjectionKeys.JMAP) EventBusId eventBusId) {
+        return new KeyReconnectionHandler(JMAP_NAMING_STRATEGY, eventBusId);
+    }
+
+    @Provides
+    @Singleton
+    @Named(InjectionKeys.JMAP)
+    RabbitMQEventBus provideJmapEventBus(Sender sender, ReceiverProvider receiverProvider,
+                                 JmapEventSerializer eventSerializer,
+                                 RetryBackoffConfiguration retryBackoffConfiguration,
+                                 EventDeadLetters eventDeadLetters,
+                                 MetricFactory metricFactory, ReactorRabbitMQChannelPool channelPool,
+                                 @Named(InjectionKeys.JMAP) EventBusId eventBusId) {
+        return new RabbitMQEventBus(
+            JMAP_NAMING_STRATEGY,
+            sender, receiverProvider, eventSerializer, retryBackoffConfiguration, new RoutingKeyConverter(ImmutableSet.of(new Factory())),
+            eventDeadLetters, metricFactory, channelPool, eventBusId);
+    }
+
+    @Provides
+    @Singleton
+    @Named(InjectionKeys.JMAP)
+    EventBus provideJmapEventBus(@Named(InjectionKeys.JMAP) RabbitMQEventBus rabbitMQEventBus) {
+        return rabbitMQEventBus;
+    }
+}
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index 152693e..33d63c8 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -32,6 +32,7 @@ import org.apache.james.modules.eventstore.MemoryEventStoreModule;
 import org.apache.james.modules.mailbox.MemoryMailboxModule;
 import org.apache.james.modules.protocols.IMAPServerModule;
 import org.apache.james.modules.protocols.JMAPServerModule;
+import org.apache.james.modules.protocols.JmapEventBusModule;
 import org.apache.james.modules.protocols.LMTPServerModule;
 import org.apache.james.modules.protocols.ManageSieveServerModule;
 import org.apache.james.modules.protocols.POP3ServerModule;
@@ -99,6 +100,7 @@ public class MemoryJamesServerMain implements JamesServerMain {
         new SpamAssassinListenerModule());
 
     public static final Module JMAP = Modules.combine(
+        new JmapEventBusModule(),
         new JmapTasksModule(),
         new MemoryDataJmapModule(),
         new JMAPServerModule());
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java
new file mode 100644
index 0000000..9faba9d
--- /dev/null
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java
@@ -0,0 +1,14 @@
+package org.apache.james.modules.protocols;
+
+import org.apache.james.events.EventBus;
+import org.apache.james.jmap.InjectionKeys;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
+
+public class JmapEventBusModule extends AbstractModule {
+    @Override
+    protected void configure() {
+        bind(EventBus.class).annotatedWith(Names.named(InjectionKeys.JMAP)).to(EventBus.class);
+    }
+}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
index 2c4e28c..ea5461e 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/JmapEventSerializer.scala
@@ -22,14 +22,12 @@ package org.apache.james.jmap.change
 import java.util.Optional
 
 import com.fasterxml.jackson.annotation.JsonProperty
-import javax.inject.Inject
 import org.apache.james.core.Username
 import org.apache.james.events.Event.EventId
 import org.apache.james.events.{Event, EventSerializer}
 import org.apache.james.jmap.core.State
 import org.apache.james.json.JsonGenericSerializer
 
-import scala.jdk.CollectionConverters._
 import scala.jdk.OptionConverters._
 
 object StateChangeEventDTO {
@@ -60,17 +58,14 @@ case class StateChangeEventDTO(@JsonProperty("type") getType: String,
     emailState = getEmailState.toScala.map(State.fromStringUnchecked))
 }
 
-case class JmapEventSerializer(dtoModules: Set[EventDTOModule[Event, EventDTO]]) extends EventSerializer {
-  @Inject
-  def this(javaModules: java.util.Set[EventDTOModule[Event, EventDTO]]) {
-    this(javaModules.asScala.toSet)
-  }
-
-  private val genericSerializer: JsonGenericSerializer[Event, EventDTO] = JsonGenericSerializer
-    .forModules(dtoModules.asJava)
+case class JmapEventSerializer() extends EventSerializer {
+  private val genericSerializer: JsonGenericSerializer[StateChangeEvent, StateChangeEventDTO] = JsonGenericSerializer
+    .forModules(StateChangeEventDTO.dtoModule)
     .withoutNestedType()
 
-  override def toJson(event: Event): String = genericSerializer.serialize(event)
+  override def toJson(event: Event): String = event match {
+    case stateChangeEvent: StateChangeEvent => genericSerializer.serialize(stateChangeEvent)
+  }
 
   override def asEvent(serialized: String): Event = genericSerializer.deserialize(serialized)
 }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
index 1f6986c..627941f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
@@ -21,13 +21,16 @@ package org.apache.james.jmap.change
 
 import java.time.{Clock, ZonedDateTime}
 
-import javax.inject.Inject
+import javax.inject.{Inject, Named}
 import org.apache.james.core.Username
+import org.apache.james.events.Event.EventId
 import org.apache.james.events.EventListener.ReactiveGroupEventListener
-import org.apache.james.events.{Event, Group}
+import org.apache.james.events.{Event, EventBus, Group, RegistrationKey}
+import org.apache.james.jmap.InjectionKeys
 import org.apache.james.jmap.api.change.{EmailChange, EmailChangeRepository, JmapChange, MailboxChange, MailboxChangeRepository}
 import org.apache.james.jmap.api.model.AccountId
 import org.apache.james.jmap.change.MailboxChangeListener.LOGGER
+import org.apache.james.jmap.core.State
 import org.apache.james.mailbox.events.MailboxEvents.{Added, Expunged, FlagsUpdated, MailboxACLUpdated, MailboxAdded, MailboxDeletion, MailboxEvent, MailboxRenamed}
 import org.apache.james.mailbox.exception.MailboxException
 import org.apache.james.mailbox.model.{MailboxACL, MailboxId}
@@ -45,7 +48,8 @@ object MailboxChangeListener {
   val LOGGER: Logger = LoggerFactory.getLogger(classOf[MailboxChangeListener])
 }
 
-case class MailboxChangeListener @Inject() (mailboxChangeRepository: MailboxChangeRepository,
+case class MailboxChangeListener @Inject() (@Named(InjectionKeys.JMAP) eventBus: EventBus,
+                                            mailboxChangeRepository: MailboxChangeRepository,
                                             mailboxChangeFactory: MailboxChange.Factory,
                                             emailChangeRepository: EmailChangeRepository,
                                             emailChangeFactory: EmailChange.Factory,
@@ -94,10 +98,11 @@ case class MailboxChangeListener @Inject() (mailboxChangeRepository: MailboxChan
   }
 
   private def saveChangeEvent(jmapChange: JmapChange): Publisher[Void] =
-    jmapChange match {
+    SMono(jmapChange match {
       case mailboxChange: MailboxChange => mailboxChangeRepository.save(mailboxChange)
       case emailChange: EmailChange => emailChangeRepository.save(emailChange)
-    }
+    }).`then`(SMono(eventBus.dispatch(toStateChangeEvent(jmapChange), Set[RegistrationKey]().asJava)))
+
 
   private def getSharees(mailboxId: MailboxId, username: Username): List[AccountId] = {
     val mailboxSession: MailboxSession = mailboxManager.createSystemSession(username)
@@ -116,4 +121,17 @@ case class MailboxChangeListener @Inject() (mailboxChangeRepository: MailboxChan
         List.empty
     }
   }
+
+  private def toStateChangeEvent(jmapChange: JmapChange): StateChangeEvent = jmapChange match {
+    case emailChange: EmailChange => StateChangeEvent(
+      eventId = EventId.random(),
+      username = Username.of(emailChange.getAccountId.getIdentifier),
+      emailState = Some(State.fromJava(emailChange.getState)),
+      mailboxState = None)
+    case mailboxChange: MailboxChange => StateChangeEvent(
+      eventId = EventId.random(),
+      username = Username.of(mailboxChange.getAccountId.getIdentifier),
+      emailState = Some(State.fromJava(mailboxChange.getState)),
+      mailboxState = None)
+  }
 }
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/MailboxChangeListenerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/MailboxChangeListenerTest.scala
index c93d891..17a91a5 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/MailboxChangeListenerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/MailboxChangeListenerTest.scala
@@ -20,10 +20,11 @@
 package org.apache.james.jmap.change
 
 import java.time.{Clock, ZonedDateTime}
+import java.util
 
 import javax.mail.Flags
 import org.apache.james.events.delivery.InVmEventDelivery
-import org.apache.james.events.{InVMEventBus, MemoryEventDeadLetters, RetryBackoffConfiguration}
+import org.apache.james.events.{Event, EventBus, EventListener, Group, InVMEventBus, MemoryEventDeadLetters, Registration, RegistrationKey, RetryBackoffConfiguration}
 import org.apache.james.jmap.api.change.{EmailChange, EmailChangeRepository, MailboxChange, MailboxChangeRepository, State}
 import org.apache.james.jmap.api.model.AccountId
 import org.apache.james.jmap.change.MailboxChangeListenerTest.ACCOUNT_ID
@@ -36,6 +37,8 @@ import org.apache.james.mailbox.{MailboxManager, MailboxSessionUtil, MessageMana
 import org.apache.james.metrics.tests.RecordingMetricFactory
 import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.{BeforeEach, Nested, Test}
+import org.reactivestreams.Publisher
+import reactor.core.publisher.Mono
 
 import scala.jdk.CollectionConverters._
 import scala.jdk.OptionConverters._
@@ -71,7 +74,16 @@ class MailboxChangeListenerTest {
     mailboxChangeRepository = new MemoryMailboxChangeRepository()
     emailChangeFactory = new EmailChange.Factory(stateFactory)
     emailChangeRepository = new MemoryEmailChangeRepository()
-    listener = MailboxChangeListener(mailboxChangeRepository, mailboxChangeFactory, emailChangeRepository, emailChangeFactory, mailboxManager, clock)
+    val eventBus = new EventBus {
+      override def register(listener: EventListener.ReactiveEventListener, key: RegistrationKey): Publisher[Registration] = Mono.empty()
+
+      override def register(listener: EventListener.ReactiveEventListener, group: Group): Registration = () => {}
+
+      override def dispatch(event: Event, key: util.Set[RegistrationKey]): Mono[Void] = Mono.empty()
+
+      override def reDeliver(group: Group, event: Event): Mono[Void] = Mono.empty()
+    }
+    listener = MailboxChangeListener(eventBus, mailboxChangeRepository, mailboxChangeFactory, emailChangeRepository, emailChangeFactory, mailboxManager, clock)
     resources.getEventBus.register(listener)
   }
 
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/InjectionKeys.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/InjectionKeys.java
new file mode 100644
index 0000000..7d2c080
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/InjectionKeys.java
@@ -0,0 +1,24 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap;
+
+public interface InjectionKeys {
+    String JMAP = "JMAP";
+}


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


[james-project] 18/33: JAMES-3491 Register state changes upon WebSocketPushEnable reception

Posted by bt...@apache.org.
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 737e2c04c28771b10c5094d8c6b15adf1d884aa3
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 10:10:56 2021 +0700

    JAMES-3491 Register state changes upon WebSocketPushEnable reception
---
 .../modules/protocols/JmapEventBusModule.java      | 19 ++++++++
 .../apache/james/jmap/api/change/JmapChange.java   |  4 +-
 .../jmap/change/AccountIdRegistrationKey.scala     |  5 ++
 .../james/jmap/change/MailboxChangeListener.scala  |  8 ++--
 .../org/apache/james/jmap/change/StateChange.scala |  4 +-
 .../james/jmap/core/WebSocketTransport.scala       |  4 +-
 .../james/jmap/json/ResponseSerializer.scala       |  6 +--
 .../apache/james/jmap/routes/WebSocketRoutes.scala | 53 ++++++++++++++++------
 8 files changed, 79 insertions(+), 24 deletions(-)

diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java
index 9faba9d..0fafb26 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JmapEventBusModule.java
@@ -1,3 +1,22 @@
+/****************************************************************
+ * 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.protocols;
 
 import org.apache.james.events.EventBus;
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/JmapChange.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/JmapChange.java
index b7a1a2e..3767de1 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/JmapChange.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/JmapChange.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.jmap.api.change;
 
-public interface JmapChange {
+import org.apache.james.jmap.api.model.AccountId;
 
+public interface JmapChange {
+    AccountId getAccountId();
 }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala
index b2b969b..5bf3eba 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/AccountIdRegistrationKey.scala
@@ -19,6 +19,7 @@
 
 package org.apache.james.jmap.change
 
+import org.apache.james.core.Username
 import org.apache.james.events.RegistrationKey
 import org.apache.james.jmap.api.model.AccountId
 
@@ -28,6 +29,10 @@ case class Factory() extends RegistrationKey.Factory {
   override def fromString(asString: String): RegistrationKey = AccountIdRegistrationKey(AccountId.fromString(asString))
 }
 
+object AccountIdRegistrationKey {
+  def of(username: Username): AccountIdRegistrationKey = AccountIdRegistrationKey(AccountId.fromUsername(username))
+}
+
 case class AccountIdRegistrationKey(accountId: AccountId) extends RegistrationKey {
   override def asString(): String = accountId.getIdentifier
 }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
index 627941f..6e57c4f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/MailboxChangeListener.scala
@@ -25,7 +25,7 @@ import javax.inject.{Inject, Named}
 import org.apache.james.core.Username
 import org.apache.james.events.Event.EventId
 import org.apache.james.events.EventListener.ReactiveGroupEventListener
-import org.apache.james.events.{Event, EventBus, Group, RegistrationKey}
+import org.apache.james.events.{Event, EventBus, Group}
 import org.apache.james.jmap.InjectionKeys
 import org.apache.james.jmap.api.change.{EmailChange, EmailChangeRepository, JmapChange, MailboxChange, MailboxChangeRepository}
 import org.apache.james.jmap.api.model.AccountId
@@ -101,7 +101,7 @@ case class MailboxChangeListener @Inject() (@Named(InjectionKeys.JMAP) eventBus:
     SMono(jmapChange match {
       case mailboxChange: MailboxChange => mailboxChangeRepository.save(mailboxChange)
       case emailChange: EmailChange => emailChangeRepository.save(emailChange)
-    }).`then`(SMono(eventBus.dispatch(toStateChangeEvent(jmapChange), Set[RegistrationKey]().asJava)))
+    }).`then`(SMono(eventBus.dispatch(toStateChangeEvent(jmapChange), AccountIdRegistrationKey(jmapChange.getAccountId))))
 
 
   private def getSharees(mailboxId: MailboxId, username: Username): List[AccountId] = {
@@ -131,7 +131,7 @@ case class MailboxChangeListener @Inject() (@Named(InjectionKeys.JMAP) eventBus:
     case mailboxChange: MailboxChange => StateChangeEvent(
       eventId = EventId.random(),
       username = Username.of(mailboxChange.getAccountId.getIdentifier),
-      emailState = Some(State.fromJava(mailboxChange.getState)),
-      mailboxState = None)
+      emailState = None,
+      mailboxState = Some(State.fromJava(mailboxChange.getState)))
   }
 }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index 1b400be..312aa72 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -32,10 +32,10 @@ sealed trait TypeName {
   def asString(): String
 }
 case object MailboxTypeName extends TypeName {
-  override def asString(): String = "Mailbox"
+  override val asString: String = "Mailbox"
 }
 case object EmailTypeName extends TypeName {
-  override def asString(): String = "Email"
+  override val asString: String = "Email"
 }
 
 case class TypeState(changes: Map[TypeName, State]) {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
index 3d1fd01..dd40f12 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
@@ -41,4 +41,6 @@ case class StateChange(changes: Map[AccountId, TypeState]) extends WebSocketOutb
     })
     .filter(_.nonEmpty)
     .map(StateChange)
-}
\ No newline at end of file
+}
+
+case class WebSocketPushEnable(dataTypes: Set[TypeName]) extends WebSocketInboundMessage
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
index fff3c11..b1454c6 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
@@ -25,7 +25,7 @@ import java.net.URL
 import eu.timepit.refined.refineV
 import io.netty.handler.codec.http.HttpResponseStatus
 import org.apache.james.core.Username
-import org.apache.james.jmap.change.{TypeName, TypeState}
+import org.apache.james.jmap.change.{EmailTypeName, MailboxTypeName, TypeName, TypeState}
 import org.apache.james.jmap.core
 import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
 import org.apache.james.jmap.core.Id.IdConstraint
@@ -187,8 +187,8 @@ object ResponseSerializer {
     case _ => JsError("Expecting a JsObject to represent a webSocket inbound request")
   }
   private implicit val typeNameReads: Reads[TypeName] = {
-    case JsString(value) if value.equals(MailboxTypeName.asString()) => JsSuccess(MailboxTypeName)
-    case JsString(value) if value.equals(EmailTypeName.asString()) => JsSuccess(EmailTypeName)
+    case JsString(MailboxTypeName.asString) => JsSuccess(MailboxTypeName)
+    case JsString(EmailTypeName.asString) => JsSuccess(EmailTypeName)
     case _ => JsError("Expecting a JsString as typeName")
   }
   private implicit val webSocketPushEnableReads: Reads[WebSocketPushEnable] = Json.reads[WebSocketPushEnable]
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
index 4664eba..c97f4bf 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
@@ -26,13 +26,15 @@ import io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE
 import io.netty.handler.codec.http.HttpMethod
 import io.netty.handler.codec.http.websocketx.WebSocketFrame
 import javax.inject.{Inject, Named}
+import org.apache.james.events.{EventBus, Registration}
 import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
 import org.apache.james.jmap.JMAPUrls.JMAP_WS
-import org.apache.james.jmap.core.{ProblemDetails, RequestId, WebSocketError, WebSocketOutboundMessage, WebSocketRequest, WebSocketResponse}
+import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener}
+import org.apache.james.jmap.core.{ProblemDetails, RequestId, WebSocketError, WebSocketOutboundMessage, WebSocketPushEnable, WebSocketRequest, WebSocketResponse}
 import org.apache.james.jmap.http.rfc8621.InjectionKeys
 import org.apache.james.jmap.http.{Authenticator, UserProvisioning}
 import org.apache.james.jmap.json.ResponseSerializer
-import org.apache.james.jmap.{Endpoint, JMAPRoute, JMAPRoutes}
+import org.apache.james.jmap.{Endpoint, JMAPRoute, JMAPRoutes, InjectionKeys => JMAPInjectionKeys}
 import org.apache.james.mailbox.MailboxSession
 import org.slf4j.{Logger, LoggerFactory}
 import reactor.core.publisher.Mono
@@ -45,8 +47,21 @@ object WebSocketRoutes {
   val LOGGER: Logger = LoggerFactory.getLogger(classOf[WebSocketRoutes])
 }
 
+case class ClientContext(outbound: WebsocketOutbound, pushRegistration: Option[Registration], session: MailboxSession) {
+  def latest(clientContext: ClientContext): ClientContext = {
+    clean
+    clientContext
+  }
+
+  def clean: ClientContext = {
+    pushRegistration.foreach(_.unregister())
+    ClientContext(outbound, None, session)
+  }
+}
+
 class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticator: Authenticator,
                                  userProvisioner: UserProvisioning,
+                                 @Named(JMAPInjectionKeys.JMAP) eventBus: EventBus,
                                  jmapApi: JMAPApi) extends JMAPRoutes {
 
   override def routes(): stream.Stream[JMAPRoute] = stream.Stream.of(
@@ -70,7 +85,8 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
       .`then`()
   }
 
-  private def handleWebSocketConnection(session: MailboxSession)(in: WebsocketInbound, out: WebsocketOutbound): Mono[Void] =
+  private def handleWebSocketConnection(session: MailboxSession)(in: WebsocketInbound, out: WebsocketOutbound): Mono[Void] = {
+    val context = ClientContext(out, None, session)
     SFlux[WebSocketFrame](in.aggregateFrames()
       .receiveFrames())
       .map(frame => {
@@ -78,27 +94,38 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
         frame.content().readBytes(bytes)
         new String(bytes, StandardCharsets.UTF_8)
       })
-      .flatMap(handleClientMessages(session))
-      .onErrorResume(e => SMono.just[WebSocketOutboundMessage](asError(None)(e)))
-      .map(ResponseSerializer.serialize)
-      .map(_.toString)
-      .flatMap(response => out.sendString(SMono.just(response), StandardCharsets.UTF_8))
+      .flatMap(message => handleClientMessages(context)(message))
+      .reduce((c1: ClientContext, c2: ClientContext) => c1.latest(c2))
+      .map[ClientContext](context => context.clean)
       .`then`()
       .asJava()
       .`then`()
+  }
 
-  private def handleClientMessages(session: MailboxSession)(message: String): SMono[WebSocketOutboundMessage] =
+  private def handleClientMessages(clientContext: ClientContext)(message: String): SMono[ClientContext] =
     ResponseSerializer.deserializeWebSocketInboundMessage(message)
       .fold(invalid => {
-        val error = asError(None)(new IllegalArgumentException(invalid.toString()))
-        SMono.just[WebSocketOutboundMessage](error)
+        val error = ResponseSerializer.serialize(asError(None)(new IllegalArgumentException(invalid.toString())))
+        SMono(clientContext.outbound.sendString(SMono.just(error.toString()), StandardCharsets.UTF_8)
+          .`then`())
+          .`then`(SMono.just(clientContext))
       }, {
           case request: WebSocketRequest =>
-            jmapApi.process(request.requestObject, session)
+            jmapApi.process(request.requestObject, clientContext.session)
               .map[WebSocketOutboundMessage](WebSocketResponse(request.requestId, _))
               .onErrorResume(e => SMono.just(asError(request.requestId)(e)))
               .subscribeOn(Schedulers.elastic)
-        })
+              .onErrorResume(e => SMono.just[WebSocketOutboundMessage](asError(None)(e)))
+              .map(ResponseSerializer.serialize)
+              .map(_.toString)
+              .flatMap(response => SMono(clientContext.outbound.sendString(SMono.just(response), StandardCharsets.UTF_8).`then`()))
+              .`then`(SMono.just(clientContext))
+          case pushEnable: WebSocketPushEnable =>
+            SMono(eventBus.register(
+                StateChangeListener(pushEnable.dataTypes, clientContext.outbound),
+                AccountIdRegistrationKey.of(clientContext.session.getUser)))
+              .map((registration: Registration) => ClientContext(clientContext.outbound, Some(registration), clientContext.session))
+      })
 
   private def handleHttpHandshakeError(throwable: Throwable, response: HttpServerResponse): SMono[Void] =
     respondDetails(response, ProblemDetails.forThrowable(throwable))


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


[james-project] 20/33: JAMES-3491 Transport independant StateChangeListener

Posted by bt...@apache.org.
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 a661388fbf00f1649e694e00d617d74239a98259
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Feb 4 16:48:08 2021 +0700

    JAMES-3491 Transport independant StateChangeListener
    
     - Allow writing tests without mocks
     - Enable reuse for other push mechanisms:
       - SSE (event-source)
       - Web hooks
---
 .../james/jmap/change/StateChangeListener.scala    | 20 ++---
 .../apache/james/jmap/routes/WebSocketRoutes.scala | 13 ++-
 .../jmap/change/StateChangeListenerTest.scala      | 96 +++++++++-------------
 3 files changed, 55 insertions(+), 74 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
index 57fd4f2..a085a15 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
@@ -19,25 +19,21 @@
 
 package org.apache.james.jmap.change
 
-import java.nio.charset.StandardCharsets
-
 import org.apache.james.events.Event
 import org.apache.james.events.EventListener.ReactiveEventListener
-import org.apache.james.jmap.json.ResponseSerializer
+import org.apache.james.jmap.core.StateChange
 import org.reactivestreams.Publisher
-import play.api.libs.json.Json
+import reactor.core.publisher.Sinks
+import reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST
 import reactor.core.scala.publisher.SMono
-import reactor.core.scheduler.Schedulers
-import reactor.netty.http.websocket.WebsocketOutbound
 
-case class StateChangeListener(types: Set[TypeName], outbound: WebsocketOutbound) extends ReactiveEventListener {
+case class StateChangeListener(types: Set[TypeName], sink: Sinks.Many[StateChange]) extends ReactiveEventListener {
   override def reactiveEvent(event: Event): Publisher[Void] = event match {
     case stateChangeEvent: StateChangeEvent =>
-      val stateChange = stateChangeEvent.asStateChange.filter(types)
-      val jsonString = stateChange.map(ResponseSerializer.serialize).map(Json.stringify)
-      jsonString.map(json => SMono(outbound.sendString(SMono.just[String](json), StandardCharsets.UTF_8))
-        .subscribeOn(Schedulers.elastic))
-        .getOrElse(SMono.empty)
+      SMono.fromCallable(() => {
+        val stateChange = stateChangeEvent.asStateChange.filter(types)
+        stateChange.foreach(next => sink.emitNext(next, FAIL_FAST))
+      }).asJava().`then`()
     case _ => SMono.empty
   }
 
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
index c97f4bf..f2b3ba8 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
@@ -30,14 +30,14 @@ import org.apache.james.events.{EventBus, Registration}
 import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
 import org.apache.james.jmap.JMAPUrls.JMAP_WS
 import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener}
-import org.apache.james.jmap.core.{ProblemDetails, RequestId, WebSocketError, WebSocketOutboundMessage, WebSocketPushEnable, WebSocketRequest, WebSocketResponse}
+import org.apache.james.jmap.core.{ProblemDetails, RequestId, StateChange, WebSocketError, WebSocketOutboundMessage, WebSocketPushEnable, WebSocketRequest, WebSocketResponse}
 import org.apache.james.jmap.http.rfc8621.InjectionKeys
 import org.apache.james.jmap.http.{Authenticator, UserProvisioning}
 import org.apache.james.jmap.json.ResponseSerializer
 import org.apache.james.jmap.{Endpoint, JMAPRoute, JMAPRoutes, InjectionKeys => JMAPInjectionKeys}
 import org.apache.james.mailbox.MailboxSession
 import org.slf4j.{Logger, LoggerFactory}
-import reactor.core.publisher.Mono
+import reactor.core.publisher.{Mono, Sinks}
 import reactor.core.scala.publisher.{SFlux, SMono}
 import reactor.core.scheduler.Schedulers
 import reactor.netty.http.server.{HttpServerRequest, HttpServerResponse}
@@ -121,10 +121,17 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
               .flatMap(response => SMono(clientContext.outbound.sendString(SMono.just(response), StandardCharsets.UTF_8).`then`()))
               .`then`(SMono.just(clientContext))
           case pushEnable: WebSocketPushEnable =>
+            val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureError()
             SMono(eventBus.register(
-                StateChangeListener(pushEnable.dataTypes, clientContext.outbound),
+                StateChangeListener(pushEnable.dataTypes, sink),
                 AccountIdRegistrationKey.of(clientContext.session.getUser)))
               .map((registration: Registration) => ClientContext(clientContext.outbound, Some(registration), clientContext.session))
+              .doOnNext(context => sink.asFlux()
+                .map(ResponseSerializer.serialize)
+                .map(_.toString)
+                .flatMap(response => SMono(context.outbound.sendString(SMono.just(response), StandardCharsets.UTF_8).`then`()))
+                .subscribeOn(Schedulers.elastic())
+                .subscribe())
       })
 
   private def handleHttpHandshakeError(throwable: Throwable, response: HttpServerResponse): SMono[Void] =
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
index d208ca2..0addd3e 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
@@ -19,91 +19,69 @@
 
 package org.apache.james.jmap.change
 
-import java.nio.charset.Charset
-
-import net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson
 import org.apache.james.core.Username
 import org.apache.james.events.Event.EventId
-import org.apache.james.jmap.core.State
+import org.apache.james.jmap.core.{AccountId, State, StateChange}
+import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Test
-import org.mockito.ArgumentCaptor
-import org.mockito.ArgumentMatchers.any
-import org.mockito.Mockito.{mock, verify, verifyZeroInteractions, when}
-import org.reactivestreams.Publisher
+import reactor.core.publisher.Sinks
+import reactor.core.publisher.Sinks.EmitFailureHandler
 import reactor.core.scala.publisher.SMono
-import reactor.netty.NettyOutbound
-import reactor.netty.http.websocket.WebsocketOutbound
+import reactor.core.scheduler.Schedulers
 
 class StateChangeListenerTest {
-  private val outbound: WebsocketOutbound = mock(classOf[WebsocketOutbound])
+  private val mailboxState = State.fromStringUnchecked("2f9f1b12-b35a-43e6-9af2-0106fb53a943")
+  private val emailState = State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")
+  private val eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4")
 
   @Test
   def reactiveEventShouldSendAnOutboundMessage(): Unit = {
-    val event = StateChangeEvent(eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4"),
+    val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureBuffer()
+    val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
-      mailboxState = Some(State.fromStringUnchecked("2f9f1b12-b35a-43e6-9af2-0106fb53a943")),
-      emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
-    val listener = StateChangeListener(Set(MailboxTypeName, EmailTypeName), outbound)
-    val nettyOutbound = mock(classOf[NettyOutbound])
-    when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
+      mailboxState = Some(mailboxState),
+      emailState = Some(emailState))
+    val listener = StateChangeListener(Set(MailboxTypeName, EmailTypeName), sink)
 
-    listener.reactiveEvent(event)
+    SMono(listener.reactiveEvent(event)).subscribeOn(Schedulers.elastic()).block()
+    sink.emitComplete(EmitFailureHandler.FAIL_FAST)
 
-    val captor: ArgumentCaptor[Publisher[String]] = ArgumentCaptor.forClass(classOf[Publisher[String]])
-    verify(outbound).sendString(captor.capture(), any(classOf[Charset]))
-    assertThatJson(SMono(captor.getValue).block()).isEqualTo(
-      """
-        |{
-        |  "@type":"StateChange",
-        |  "changed":{
-        |    "81b637d8fcd2c6da6359e6963113a1170de795e4b725b84d1e0b4cfd9ec58ce9":{
-        |      "Mailbox":"2f9f1b12-b35a-43e6-9af2-0106fb53a943",
-        |      "Email":"2d9f1b12-b35a-43e6-9af2-0106fb53a943"
-        |    }
-        |  }
-        |}
-        |""".stripMargin)
+    assertThat(sink.asFlux().collectList().block())
+      .containsExactly(StateChange(Map(AccountId.from(Username.of("bob")).toOption.get  -> TypeState(Map(
+        MailboxTypeName -> mailboxState,
+        EmailTypeName -> emailState)))))
   }
 
   @Test
   def reactiveEventShouldOmitUnwantedTypes(): Unit = {
-    val event = StateChangeEvent(eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4"),
+    val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureBuffer()
+    val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
-      mailboxState = Some(State.fromStringUnchecked("2f9f1b12-b35a-43e6-9af2-0106fb53a943")),
-      emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
-    val listener = StateChangeListener(Set(MailboxTypeName), outbound)
-    val nettyOutbound = mock(classOf[NettyOutbound])
-    when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
+      mailboxState = Some(mailboxState),
+      emailState = Some(emailState))
+    val listener = StateChangeListener(Set(MailboxTypeName), sink)
 
-    listener.reactiveEvent(event)
+    SMono(listener.reactiveEvent(event)).subscribeOn(Schedulers.elastic()).block()
+    sink.emitComplete(EmitFailureHandler.FAIL_FAST)
 
-    val captor: ArgumentCaptor[Publisher[String]] = ArgumentCaptor.forClass(classOf[Publisher[String]])
-    verify(outbound).sendString(captor.capture(), any(classOf[Charset]))
-    assertThatJson(SMono(captor.getValue).block()).isEqualTo(
-      """
-        |{
-        |  "@type":"StateChange",
-        |  "changed":{
-        |    "81b637d8fcd2c6da6359e6963113a1170de795e4b725b84d1e0b4cfd9ec58ce9":{
-        |      "Mailbox":"2f9f1b12-b35a-43e6-9af2-0106fb53a943"
-        |    }
-        |  }
-        |}
-        |""".stripMargin)
+    assertThat(sink.asFlux().collectList().block())
+      .containsExactly(StateChange(Map(AccountId.from(Username.of("bob")).toOption.get -> TypeState(Map(
+        MailboxTypeName -> mailboxState)))))
   }
 
   @Test
   def reactiveEventShouldFilterOutUnwantedEvents(): Unit = {
-    val event = StateChangeEvent(eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4"),
+    val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureBuffer()
+    val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = None,
-      emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
-    val listener = StateChangeListener(Set(MailboxTypeName), outbound)
-    val nettyOutbound = mock(classOf[NettyOutbound])
-    when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
+      emailState = Some(emailState))
+    val listener = StateChangeListener(Set(MailboxTypeName), sink)
 
-    listener.reactiveEvent(event)
+    SMono(listener.reactiveEvent(event)).subscribeOn(Schedulers.elastic()).block()
+    sink.emitComplete(EmitFailureHandler.FAIL_FAST)
 
-    verifyZeroInteractions(outbound)
+    assertThat(sink.asFlux().collectList().block())
+      .isEmpty()
   }
 }


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


[james-project] 14/33: JAMES-3491 Provide a basic StateChangeListener

Posted by bt...@apache.org.
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 db48545bce46c66cdc8d8303e4e040269d64e99a
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Wed Feb 3 09:52:26 2021 +0700

    JAMES-3491 Provide a basic StateChangeListener
---
 .../org/apache/james/jmap/change/StateChange.scala | 16 ++++--
 ...StateChange.scala => StateChangeListener.scala} | 58 ++++++++-----------
 .../james/jmap/core/WebSocketTransport.scala       |  6 +-
 .../james/jmap/json/ResponseSerializer.scala       | 11 ++++
 .../scala/org/apache/james/jmap/json/package.scala |  2 +-
 .../jmap/change/StateChangeListenerTest.scala      | 67 ++++++++++++++++++++++
 6 files changed, 118 insertions(+), 42 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
index d6c555c..7aa9bf1 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
@@ -22,17 +22,21 @@ package org.apache.james.jmap.change
 import org.apache.james.core.Username
 import org.apache.james.events.Event
 import org.apache.james.events.Event.EventId
-import org.apache.james.jmap.core.{AccountId, State}
+import org.apache.james.jmap.core.{AccountId, State, StateChange}
 
 sealed trait TypeName {
   def asMap(maybeState: Option[State]): Map[TypeName, State] =
     maybeState.map(state => Map[TypeName, State](this -> state))
       .getOrElse(Map())
-}
-case object MailboxTypeName extends TypeName
-case object EmailTypeName extends TypeName
 
-case class StateChange(changes: Map[AccountId, TypeState])
+  def asString(): String
+}
+case object MailboxTypeName extends TypeName {
+  override def asString(): String = "Mailbox"
+}
+case object EmailTypeName extends TypeName {
+  override def asString(): String = "Email"
+}
 
 case class TypeState(changes: Map[TypeName, State])
 
@@ -51,7 +55,7 @@ case class StateChangeEvent(eventId: EventId,
 
   override def getUsername: Username = username
 
-  override def isNoop: Boolean = false
+  override def isNoop: Boolean = mailboxState.isEmpty && emailState.isEmpty
 
   override def getEventId: EventId = eventId
 }
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
similarity index 52%
copy from server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
copy to server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
index d6c555c..c653a8a 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
@@ -19,39 +19,29 @@
 
 package org.apache.james.jmap.change
 
-import org.apache.james.core.Username
-import org.apache.james.events.Event
-import org.apache.james.events.Event.EventId
-import org.apache.james.jmap.core.{AccountId, State}
+import java.nio.charset.StandardCharsets
 
-sealed trait TypeName {
-  def asMap(maybeState: Option[State]): Map[TypeName, State] =
-    maybeState.map(state => Map[TypeName, State](this -> state))
-      .getOrElse(Map())
+import org.apache.james.events.Event
+import org.apache.james.events.EventListener.ReactiveEventListener
+import org.apache.james.jmap.json.ResponseSerializer
+import org.reactivestreams.Publisher
+import play.api.libs.json.Json
+import reactor.core.scala.publisher.SMono
+import reactor.core.scheduler.Schedulers
+import reactor.netty.http.websocket.WebsocketOutbound
+
+case class StateChangeListener(outbound: WebsocketOutbound) extends ReactiveEventListener {
+  override def reactiveEvent(event: Event): Publisher[Void] = event match {
+    case stateChangeEvent: StateChangeEvent =>
+      val stateChange = stateChangeEvent.asStateChange
+      val jsonString = Json.stringify(ResponseSerializer.serialize(stateChange))
+      SMono(outbound.sendString(SMono.just[String](jsonString), StandardCharsets.UTF_8))
+        .subscribeOn(Schedulers.elastic)
+    case _ => SMono.empty
+  }
+
+  override def isHandling(event: Event): Boolean = event match {
+    case _: StateChangeEvent => true
+    case _ => false
+  }
 }
-case object MailboxTypeName extends TypeName
-case object EmailTypeName extends TypeName
-
-case class StateChange(changes: Map[AccountId, TypeState])
-
-case class TypeState(changes: Map[TypeName, State])
-
-case class StateChangeEvent(eventId: EventId,
-                            username: Username,
-                            mailboxState: Option[State],
-                            emailState: Option[State]) extends Event {
-
-  def asStateChange: StateChange =
-    StateChange(Map(AccountId.from(username).fold(
-      failure => throw new IllegalArgumentException(failure),
-      success => success) ->
-      TypeState(
-        MailboxTypeName.asMap(mailboxState) ++
-          EmailTypeName.asMap(emailState))))
-
-  override def getUsername: Username = username
-
-  override def isNoop: Boolean = false
-
-  override def getEventId: EventId = eventId
-}
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
index f7df48b..b86cd07 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/WebSocketTransport.scala
@@ -19,6 +19,8 @@
 
 package org.apache.james.jmap.core
 
+import org.apache.james.jmap.change.TypeState
+
 sealed trait WebSocketInboundMessage
 
 sealed trait WebSocketOutboundMessage
@@ -29,4 +31,6 @@ case class WebSocketRequest(requestId: Option[RequestId], requestObject: Request
 
 case class WebSocketResponse(requestId: Option[RequestId], responseObject: ResponseObject) extends WebSocketOutboundMessage
 
-case class WebSocketError(requestId: Option[RequestId], problemDetails: ProblemDetails) extends WebSocketOutboundMessage
\ No newline at end of file
+case class WebSocketError(requestId: Option[RequestId], problemDetails: ProblemDetails) extends WebSocketOutboundMessage
+
+case class StateChange(changes: Map[AccountId, TypeState]) extends WebSocketOutboundMessage
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
index 2304565..fff3c11 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
@@ -25,6 +25,7 @@ import java.net.URL
 import eu.timepit.refined.refineV
 import io.netty.handler.codec.http.HttpResponseStatus
 import org.apache.james.core.Username
+import org.apache.james.jmap.change.{TypeName, TypeState}
 import org.apache.james.jmap.core
 import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
 import org.apache.james.jmap.core.Id.IdConstraint
@@ -202,6 +203,15 @@ object ResponseSerializer {
       }
     case _ => JsError("Expecting a JsObject to represent a webSocket inbound message")
   }
+
+  private implicit val typeStateMapWrites: Writes[Map[TypeName, State]] = mapWrites[TypeName, State](_.asString(), stateWrites)
+  private implicit val typeStateWrites: Writes[TypeState] = Json.valueWrites[TypeState]
+  private implicit val changeWrites: OWrites[Map[AccountId, TypeState]] = mapWrites[AccountId, TypeState](_.id.value, typeStateWrites)
+  private implicit val stateChangeWrites: Writes[StateChange] = stateChange =>
+    JsObject(Map(
+      "@type" -> JsString("StateChange"),
+      "changed" -> changeWrites.writes(stateChange.changes)))
+
   private implicit val webSocketResponseWrites: Writes[WebSocketResponse] = response => {
     val apiResponseJson: JsObject = responseObjectFormat.writes(response.responseObject)
     JsObject(Map(
@@ -217,6 +227,7 @@ object ResponseSerializer {
       ++ errorJson.value)
   }
   private implicit val webSocketOutboundWrites: Writes[WebSocketOutboundMessage] = {
+    case stateChange: StateChange => stateChangeWrites.writes(stateChange)
     case response: WebSocketResponse => webSocketResponseWrites.writes(response)
     case error: WebSocketError => webSocketErrorWrites.writes(error)
   }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
index e3160cf..fb77977 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
@@ -43,7 +43,7 @@ package object json {
     case _ => JsError("Expecting mailboxId value to be a boolean")
   }
 
-  def mapWrites[K, V](keyWriter: K => String, valueWriter: Writes[V]): Writes[Map[K, V]] =
+  def mapWrites[K, V](keyWriter: K => String, valueWriter: Writes[V]): OWrites[Map[K, V]] =
     (ids: Map[K, V]) => {
       ids.foldLeft(JsObject.empty)((jsObject, kv) => {
         val (key: K, value: V) = kv
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
new file mode 100644
index 0000000..ecd83a0
--- /dev/null
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
@@ -0,0 +1,67 @@
+/***************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap.change
+
+import java.nio.charset.Charset
+
+import net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson
+import org.apache.james.core.Username
+import org.apache.james.events.Event.EventId
+import org.apache.james.jmap.core.State
+import org.junit.jupiter.api.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.ArgumentMatchers.any
+import org.mockito.Mockito.{mock, verify, when}
+import org.reactivestreams.Publisher
+import reactor.core.scala.publisher.SMono
+import reactor.netty.NettyOutbound
+import reactor.netty.http.websocket.WebsocketOutbound
+
+class StateChangeListenerTest {
+  private val outbound: WebsocketOutbound = mock(classOf[WebsocketOutbound])
+
+  @Test
+  def reactiveEventShouldSendAnOutboundMessage(): Unit = {
+    val event = StateChangeEvent(eventId = EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4"),
+      username = Username.of("bob"),
+      mailboxState = Some(State.fromStringUnchecked("2f9f1b12-b35a-43e6-9af2-0106fb53a943")),
+      emailState = Some(State.fromStringUnchecked("2d9f1b12-b35a-43e6-9af2-0106fb53a943")))
+    val listener = StateChangeListener(outbound)
+    val nettyOutbound = mock(classOf[NettyOutbound])
+    when(outbound.sendString(any(), any())).thenReturn(nettyOutbound)
+
+    listener.reactiveEvent(event)
+
+    val captor: ArgumentCaptor[Publisher[String]] = ArgumentCaptor.forClass(classOf[Publisher[String]])
+    verify(outbound).sendString(captor.capture(), any(classOf[Charset]))
+    assertThatJson(SMono(captor.getValue).block()).isEqualTo(
+      """
+        |{
+        |  "@type":"StateChange",
+        |  "changed":{
+        |    "81b637d8fcd2c6da6359e6963113a1170de795e4b725b84d1e0b4cfd9ec58ce9":{
+        |      "Mailbox":"2f9f1b12-b35a-43e6-9af2-0106fb53a943",
+        |      "Email":"2d9f1b12-b35a-43e6-9af2-0106fb53a943"
+        |    }
+        |  }
+        |}
+        |""".stripMargin)
+  }
+}


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


[james-project] 19/33: JAMES-3491 WebSocketPushEnable integration test

Posted by bt...@apache.org.
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 f0d38eedf38f013177a13de1a510db672fe824ef
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Feb 5 10:11:12 2021 +0700

    JAMES-3491 WebSocketPushEnable integration test
---
 .../jmap/rfc8621/contract/WebSocketContract.scala  | 207 ++++++++++++++++++++-
 1 file changed, 206 insertions(+), 1 deletion(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
index 9bd810c..f47f734 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/WebSocketContract.scala
@@ -22,10 +22,13 @@ import java.net.{ProtocolException, URI}
 
 import net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson
 import org.apache.james.GuiceJamesServer
+import org.apache.james.jmap.api.model.AccountId
 import org.apache.james.jmap.draft.JmapGuiceProbe
 import org.apache.james.jmap.rfc8621.contract.Fixture._
+import org.apache.james.mailbox.model.MailboxPath
+import org.apache.james.modules.MailboxProbeImpl
 import org.apache.james.utils.DataProbeImpl
-import org.assertj.core.api.Assertions.assertThatThrownBy
+import org.assertj.core.api.Assertions.{assertThat, assertThatThrownBy}
 import org.junit.jupiter.api.{BeforeEach, Test}
 import sttp.capabilities.WebSockets
 import sttp.client3.monad.IdMonad
@@ -37,6 +40,8 @@ import sttp.monad.syntax.MonadErrorOps
 import sttp.ws.WebSocketFrame
 import sttp.ws.WebSocketFrame.Text
 
+import scala.jdk.CollectionConverters._
+
 trait WebSocketContract {
   private lazy val backend: SttpBackend[Identity, WebSockets] = OkHttpSyncBackend()
   private lazy implicit val monadError: MonadError[Identity] = IdMonad
@@ -95,6 +100,66 @@ trait WebSocketContract {
   }
 
   @Test
+  def executingSeveralAPICallsShouldBePossible(server: GuiceJamesServer): Unit = {
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            List({
+              ws.send(WebSocketFrame.text(
+                """{
+                  |  "@type": "Request",
+                  |  "requestId": "req-36",
+                  |  "using": [ "urn:ietf:params:jmap:core"],
+                  |  "methodCalls": [
+                  |    [
+                  |      "Core/echo",
+                  |      {
+                  |        "arg1": "1",
+                  |        "arg2": "arg2data"
+                  |      },
+                  |      "c1"
+                  |    ]
+                  |  ]
+                  |}""".stripMargin))
+              ws.receive()
+                .map {
+                  case t: Text => t.payload
+                }
+            }, {
+              Thread.sleep(200)
+
+              ws.send(WebSocketFrame.text(
+                """{
+                  |  "@type": "Request",
+                  |  "requestId": "req-36",
+                  |  "using": [ "urn:ietf:params:jmap:core"],
+                  |  "methodCalls": [
+                  |    [
+                  |      "Core/echo",
+                  |      {
+                  |        "arg1": "2",
+                  |        "arg2": "arg2data"
+                  |      },
+                  |      "c1"
+                  |    ]
+                  |  ]
+                  |}""".stripMargin))
+
+              ws.receive()
+                .map {
+                  case t: Text => t.payload
+                }
+            })
+        })
+        .send(backend)
+        .body
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(2)
+  }
+
+  @Test
   def apiRequestsShouldBeProcessedWhenNoRequestId(server: GuiceJamesServer): Unit = {
     val response: Either[String, String] =
       authenticatedRequest(server)
@@ -362,6 +427,146 @@ trait WebSocketContract {
                    |}""".stripMargin)
   }
 
+  @Test
+  def pushEnableRequestsShouldBeProcessed(server: GuiceJamesServer): Unit = {
+    val bobPath = MailboxPath.inbox(BOB)
+    val accountId: AccountId = AccountId.fromUsername(BOB)
+    val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+
+    Thread.sleep(100)
+
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["Mailbox", "Email"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "@type": "Request",
+                 |  "requestId": "req-36",
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "create": {
+                 |        "aaaaaa":{
+                 |          "mailboxIds": {
+                 |             "${mailboxId.serialize}": true
+                 |          }
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            List(
+            ws.receive()
+              .map { case t: Text =>
+                t.payload
+              },
+            ws.receive()
+              .map { case t: Text =>
+                t.payload
+              },
+            ws.receive()
+              .map { case t: Text =>
+                t.payload
+              })
+        })
+        .send(backend)
+        .body
+
+    Thread.sleep(100)
+
+    val jmapGuiceProbe: JmapGuiceProbe = server.getProbe(classOf[JmapGuiceProbe])
+    val emailState: String = jmapGuiceProbe.getLatestEmailState(accountId).getValue.toString
+    val mailboxState: String = jmapGuiceProbe.getLatestMailboxState(accountId).getValue.toString
+
+    val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(3) // email notification + mailbox notification + API response
+      .contains(mailboxStateChange, emailStateChange)
+  }
+
+  @Test
+  def pushEnableShouldUpdatePreviousSubscriptions(server: GuiceJamesServer): Unit = {
+    val bobPath = MailboxPath.inbox(BOB)
+    val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+    val accountId: AccountId = AccountId.fromUsername(BOB)
+    Thread.sleep(100)
+
+    val response: Either[String, List[String]] =
+      authenticatedRequest(server)
+        .response(asWebSocket[Identity, List[String]] {
+          ws =>
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["Mailbox", "Email"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              """{
+                |  "@type": "WebSocketPushEnable",
+                |  "dataTypes": ["Mailbox"]
+                |}""".stripMargin))
+
+            Thread.sleep(100)
+
+            ws.send(WebSocketFrame.text(
+              s"""{
+                 |  "@type": "Request",
+                 |  "requestId": "req-36",
+                 |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+                 |  "methodCalls": [
+                 |    ["Email/set", {
+                 |      "accountId": "$ACCOUNT_ID",
+                 |      "create": {
+                 |        "aaaaaa":{
+                 |          "mailboxIds": {
+                 |             "${mailboxId.serialize}": true
+                 |          }
+                 |        }
+                 |      }
+                 |    }, "c1"]]
+                 |}""".stripMargin))
+
+            List(ws.receive()
+              .map { case t: Text =>
+                t.payload
+            },
+            ws.receive()
+              .map { case t: Text =>
+                t.payload
+              })
+        })
+        .send(backend)
+        .body
+
+    Thread.sleep(100)
+    val jmapGuiceProbe: JmapGuiceProbe = server.getProbe(classOf[JmapGuiceProbe])
+    val emailState: String = jmapGuiceProbe.getLatestEmailState(accountId).getValue.toString
+    val mailboxState: String = jmapGuiceProbe.getLatestMailboxState(accountId).getValue.toString
+
+    val mailboxStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Mailbox":"$mailboxState"}}}"""
+    val emailStateChange: String = s"""{"@type":"StateChange","changed":{"$ACCOUNT_ID":{"Email":"$emailState"}}}"""
+
+    assertThat(response.toOption.get.asJava)
+      .hasSize(2) // No Email notification
+      .contains(mailboxStateChange)
+      .doesNotContain(emailStateChange)
+  }
+
   private def authenticatedRequest(server: GuiceJamesServer): RequestT[Identity, Either[String, String], Any] = {
     val port = server.getProbe(classOf[JmapGuiceProbe])
       .getJmapPort


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


[james-project] 33/33: [REFACTORING] Convert server/app tests to JUNIT 5

Posted by bt...@apache.org.
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 b8e6943778aa1d7887cc326fdf4d74474a6f17cc
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Feb 8 11:49:54 2021 +0700

    [REFACTORING] Convert server/app tests to JUNIT 5
---
 .../james/app/spring/JamesAppSpringMainTest.java       |  8 +++-----
 .../james/app/spring/JamesSpringContextTest.java       | 18 +++++++++---------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/server/app/src/test/java/org/apache/james/app/spring/JamesAppSpringMainTest.java b/server/app/src/test/java/org/apache/james/app/spring/JamesAppSpringMainTest.java
index 411e66e..3acc3a5 100644
--- a/server/app/src/test/java/org/apache/james/app/spring/JamesAppSpringMainTest.java
+++ b/server/app/src/test/java/org/apache/james/app/spring/JamesAppSpringMainTest.java
@@ -18,13 +18,11 @@
  ****************************************************************/
 package org.apache.james.app.spring;
 
-import org.junit.Test;
-
-public class JamesAppSpringMainTest {
+import org.junit.jupiter.api.Test;
 
+class JamesAppSpringMainTest {
     @Test
-    public void testServer() throws Exception {
+    void testServer() throws Exception {
         JamesAppSpringMain.main(null);
     }
-
 }
diff --git a/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java b/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
index 56fd185..8d2560a 100644
--- a/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
+++ b/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
@@ -26,28 +26,28 @@ import org.apache.james.events.InVMEventBus;
 import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
 import org.apache.james.mailbox.store.event.MailboxAnnotationListener;
 import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class JamesSpringContextTest {
+class JamesSpringContextTest {
     private JamesServerApplicationContext context;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         context = new JamesServerApplicationContext(new String[] { "META-INF/org/apache/james/spring-server.xml" });
         context.registerShutdownHook();
         context.start();
     }
 
-    @After
-    public void tearDown() {
+    @AfterEach
+    void tearDown() {
         context.stop();
         context.destroy();
     }
 
     @Test
-    public void springShouldLoadAndAddOnlyOneQuotaUpdaterListener() {
+    void springShouldLoadAndAddOnlyOneQuotaUpdaterListener() {
         InVMEventBus eventBus = context.getBean(InVMEventBus.class);
 
         assertThat(eventBus.registeredGroups())


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


[james-project] 21/33: JAMES-3491 Rework WebSocketRoutes

Posted by bt...@apache.org.
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 b6c02de8125acede33713d4178c16aceb66f5c22
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Feb 4 23:46:29 2021 +0700

    JAMES-3491 Rework WebSocketRoutes
    
     - Use a Sink to gather all messages sent to the client
    
    This enables a centralized handling, for errors, API messages, and push notification
    
     - Revert buggy "functional friendly" un-registration
    
     - Use Json.stringify
    
     - Improve unregistration - get ride of closed registrations
---
 .../james/jmap/change/StateChangeListener.scala    | 21 ++++----
 .../apache/james/jmap/routes/WebSocketRoutes.scala | 63 +++++++++++-----------
 .../jmap/change/StateChangeListenerTest.scala      |  8 +--
 3 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
index a085a15..c83f642 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChangeListener.scala
@@ -21,21 +21,22 @@ package org.apache.james.jmap.change
 
 import org.apache.james.events.Event
 import org.apache.james.events.EventListener.ReactiveEventListener
-import org.apache.james.jmap.core.StateChange
+import org.apache.james.jmap.core.WebSocketOutboundMessage
 import org.reactivestreams.Publisher
 import reactor.core.publisher.Sinks
 import reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST
 import reactor.core.scala.publisher.SMono
 
-case class StateChangeListener(types: Set[TypeName], sink: Sinks.Many[StateChange]) extends ReactiveEventListener {
-  override def reactiveEvent(event: Event): Publisher[Void] = event match {
-    case stateChangeEvent: StateChangeEvent =>
-      SMono.fromCallable(() => {
-        val stateChange = stateChangeEvent.asStateChange.filter(types)
-        stateChange.foreach(next => sink.emitNext(next, FAIL_FAST))
-      }).asJava().`then`()
-    case _ => SMono.empty
-  }
+case class StateChangeListener(types: Set[TypeName], sink: Sinks.Many[WebSocketOutboundMessage]) extends ReactiveEventListener {
+  override def reactiveEvent(event: Event): Publisher[Void] =
+    event match {
+      case stateChangeEvent: StateChangeEvent =>
+        SMono.fromCallable(() =>
+          stateChangeEvent.asStateChange.filter(types)
+            .foreach(next => sink.emitNext(next, FAIL_FAST)))
+          .asJava().`then`()
+      case _ => SMono.empty
+    }
 
   override def isHandling(event: Event): Boolean = event match {
     case _: StateChangeEvent => true
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
index f2b3ba8..bd038a5 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
@@ -20,6 +20,7 @@
 package org.apache.james.jmap.routes
 
 import java.nio.charset.StandardCharsets
+import java.util.concurrent.atomic.AtomicReference
 import java.util.stream
 
 import io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE
@@ -30,13 +31,15 @@ import org.apache.james.events.{EventBus, Registration}
 import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
 import org.apache.james.jmap.JMAPUrls.JMAP_WS
 import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener}
-import org.apache.james.jmap.core.{ProblemDetails, RequestId, StateChange, WebSocketError, WebSocketOutboundMessage, WebSocketPushEnable, WebSocketRequest, WebSocketResponse}
+import org.apache.james.jmap.core.{ProblemDetails, RequestId, WebSocketError, WebSocketOutboundMessage, WebSocketPushEnable, WebSocketRequest, WebSocketResponse}
 import org.apache.james.jmap.http.rfc8621.InjectionKeys
 import org.apache.james.jmap.http.{Authenticator, UserProvisioning}
 import org.apache.james.jmap.json.ResponseSerializer
 import org.apache.james.jmap.{Endpoint, JMAPRoute, JMAPRoutes, InjectionKeys => JMAPInjectionKeys}
 import org.apache.james.mailbox.MailboxSession
 import org.slf4j.{Logger, LoggerFactory}
+import play.api.libs.json.Json
+import reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST
 import reactor.core.publisher.{Mono, Sinks}
 import reactor.core.scala.publisher.{SFlux, SMono}
 import reactor.core.scheduler.Schedulers
@@ -47,16 +50,15 @@ object WebSocketRoutes {
   val LOGGER: Logger = LoggerFactory.getLogger(classOf[WebSocketRoutes])
 }
 
-case class ClientContext(outbound: WebsocketOutbound, pushRegistration: Option[Registration], session: MailboxSession) {
-  def latest(clientContext: ClientContext): ClientContext = {
-    clean
-    clientContext
-  }
+case class ClientContext(outbound: Sinks.Many[WebSocketOutboundMessage], pushRegistration: AtomicReference[Registration], session: MailboxSession) {
+  def withRegistration(registration: Registration): Unit = withRegistration(Some(registration))
 
-  def clean: ClientContext = {
-    pushRegistration.foreach(_.unregister())
-    ClientContext(outbound, None, session)
-  }
+  def clean(): Unit = withRegistration(None)
+
+  def withRegistration(registration: Option[Registration]): Unit = Option(pushRegistration.getAndSet(registration.orNull))
+    .foreach(oldRegistration => SMono.fromCallable(() => oldRegistration.unregister())
+      .subscribeOn(Schedulers.elastic())
+      .subscribe())
 }
 
 class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticator: Authenticator,
@@ -86,7 +88,17 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
   }
 
   private def handleWebSocketConnection(session: MailboxSession)(in: WebsocketInbound, out: WebsocketOutbound): Mono[Void] = {
-    val context = ClientContext(out, None, session)
+    val sink: Sinks.Many[WebSocketOutboundMessage] = Sinks.many().unicast().onBackpressureBuffer()
+
+    out.sendString(
+      sink.asFlux()
+        .map(ResponseSerializer.serialize)
+        .map(Json.stringify),
+      StandardCharsets.UTF_8).`then`
+      .subscribeOn(Schedulers.elastic())
+      .subscribe()
+
+    val context = ClientContext(sink, new AtomicReference[Registration](), session)
     SFlux[WebSocketFrame](in.aggregateFrames()
       .receiveFrames())
       .map(frame => {
@@ -95,20 +107,17 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
         new String(bytes, StandardCharsets.UTF_8)
       })
       .flatMap(message => handleClientMessages(context)(message))
-      .reduce((c1: ClientContext, c2: ClientContext) => c1.latest(c2))
-      .map[ClientContext](context => context.clean)
+      .doOnTerminate(context.clean)
       .`then`()
       .asJava()
       .`then`()
   }
 
-  private def handleClientMessages(clientContext: ClientContext)(message: String): SMono[ClientContext] =
+  private def handleClientMessages(clientContext: ClientContext)(message: String): SMono[Unit] =
     ResponseSerializer.deserializeWebSocketInboundMessage(message)
       .fold(invalid => {
-        val error = ResponseSerializer.serialize(asError(None)(new IllegalArgumentException(invalid.toString())))
-        SMono(clientContext.outbound.sendString(SMono.just(error.toString()), StandardCharsets.UTF_8)
-          .`then`())
-          .`then`(SMono.just(clientContext))
+        val error = asError(None)(new IllegalArgumentException(invalid.toString()))
+        SMono.fromCallable(() => clientContext.outbound.emitNext(error, FAIL_FAST))
       }, {
           case request: WebSocketRequest =>
             jmapApi.process(request.requestObject, clientContext.session)
@@ -116,22 +125,14 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
               .onErrorResume(e => SMono.just(asError(request.requestId)(e)))
               .subscribeOn(Schedulers.elastic)
               .onErrorResume(e => SMono.just[WebSocketOutboundMessage](asError(None)(e)))
-              .map(ResponseSerializer.serialize)
-              .map(_.toString)
-              .flatMap(response => SMono(clientContext.outbound.sendString(SMono.just(response), StandardCharsets.UTF_8).`then`()))
-              .`then`(SMono.just(clientContext))
+              .doOnNext(next => clientContext.outbound.emitNext(next, FAIL_FAST))
+              .`then`()
           case pushEnable: WebSocketPushEnable =>
-            val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureError()
             SMono(eventBus.register(
-                StateChangeListener(pushEnable.dataTypes, sink),
+                StateChangeListener(pushEnable.dataTypes, clientContext.outbound),
                 AccountIdRegistrationKey.of(clientContext.session.getUser)))
-              .map((registration: Registration) => ClientContext(clientContext.outbound, Some(registration), clientContext.session))
-              .doOnNext(context => sink.asFlux()
-                .map(ResponseSerializer.serialize)
-                .map(_.toString)
-                .flatMap(response => SMono(context.outbound.sendString(SMono.just(response), StandardCharsets.UTF_8).`then`()))
-                .subscribeOn(Schedulers.elastic())
-                .subscribe())
+              .doOnNext(newRegistration => clientContext.withRegistration(newRegistration))
+              .`then`()
       })
 
   private def handleHttpHandshakeError(throwable: Throwable, response: HttpServerResponse): SMono[Void] =
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
index 0addd3e..efa5775 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/change/StateChangeListenerTest.scala
@@ -21,7 +21,7 @@ package org.apache.james.jmap.change
 
 import org.apache.james.core.Username
 import org.apache.james.events.Event.EventId
-import org.apache.james.jmap.core.{AccountId, State, StateChange}
+import org.apache.james.jmap.core.{AccountId, State, StateChange, WebSocketOutboundMessage}
 import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Test
 import reactor.core.publisher.Sinks
@@ -36,7 +36,7 @@ class StateChangeListenerTest {
 
   @Test
   def reactiveEventShouldSendAnOutboundMessage(): Unit = {
-    val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureBuffer()
+    val sink: Sinks.Many[WebSocketOutboundMessage] = Sinks.many().unicast().onBackpressureBuffer()
     val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = Some(mailboxState),
@@ -54,7 +54,7 @@ class StateChangeListenerTest {
 
   @Test
   def reactiveEventShouldOmitUnwantedTypes(): Unit = {
-    val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureBuffer()
+    val sink: Sinks.Many[WebSocketOutboundMessage] = Sinks.many().unicast().onBackpressureBuffer()
     val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = Some(mailboxState),
@@ -71,7 +71,7 @@ class StateChangeListenerTest {
 
   @Test
   def reactiveEventShouldFilterOutUnwantedEvents(): Unit = {
-    val sink: Sinks.Many[StateChange] = Sinks.many().unicast().onBackpressureBuffer()
+    val sink: Sinks.Many[WebSocketOutboundMessage] = Sinks.many().unicast().onBackpressureBuffer()
     val event = StateChangeEvent(eventId = eventId,
       username = Username.of("bob"),
       mailboxState = None,


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