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 2020/09/25 01:51:53 UTC
[james-project] 08/13: JAMES-3305 Extract
dispatchShouldWorkAfterNetworkIssuesForOldRegistration in its own class
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 c13a78a2cfde867622b186d1c14f38383b9f2ac3
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Sep 23 12:07:27 2020 +0700
JAMES-3305 Extract dispatchShouldWorkAfterNetworkIssuesForOldRegistration in its own class
Fails in the nested multi-eventBus environment of RabbitMQEventBusTest, succeeds in its own test class.
---
.../james/mailbox/events/NetworkErrorTest.java | 87 ++++++++++++++++++++++
.../james/mailbox/events/RabbitMQEventBusTest.java | 18 -----
2 files changed, 87 insertions(+), 18 deletions(-)
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/NetworkErrorTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/NetworkErrorTest.java
new file mode 100644
index 0000000..4d0ea38
--- /dev/null
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/NetworkErrorTest.java
@@ -0,0 +1,87 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox.events;
+
+import static org.apache.james.mailbox.events.EventBusTestFixture.EVENT;
+import static org.apache.james.mailbox.events.EventBusTestFixture.GROUP_A;
+import static org.apache.james.mailbox.events.EventBusTestFixture.NO_KEYS;
+import static org.apache.james.mailbox.events.EventBusTestFixture.RETRY_BACKOFF_CONFIGURATION;
+import static org.apache.james.mailbox.events.EventBusTestFixture.newListener;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.verify;
+
+import org.apache.james.backends.rabbitmq.RabbitMQExtension;
+import org.apache.james.backends.rabbitmq.RabbitMQFixture;
+import org.apache.james.event.json.EventSerializer;
+import org.apache.james.mailbox.model.TestId;
+import org.apache.james.mailbox.model.TestMessageId;
+import org.apache.james.mailbox.store.quota.DefaultUserQuotaRootResolver;
+import org.apache.james.metrics.tests.RecordingMetricFactory;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class NetworkErrorTest {
+ @RegisterExtension
+ static RabbitMQExtension rabbitMQExtension = RabbitMQExtension.singletonRabbitMQ()
+ .isolationPolicy(RabbitMQExtension.IsolationPolicy.WEAK);
+
+ private RabbitMQEventBus eventBus;
+
+ @BeforeEach
+ void setUp() {
+ MemoryEventDeadLetters memoryEventDeadLetters = new MemoryEventDeadLetters();
+
+ TestId.Factory mailboxIdFactory = new TestId.Factory();
+ EventSerializer eventSerializer = new EventSerializer(mailboxIdFactory, new TestMessageId.Factory(), new DefaultUserQuotaRootResolver.DefaultQuotaRootDeserializer());
+ RoutingKeyConverter routingKeyConverter = RoutingKeyConverter.forFactories(new MailboxIdRegistrationKey.Factory(mailboxIdFactory));
+
+ eventBus = new RabbitMQEventBus(rabbitMQExtension.getSender(), rabbitMQExtension.getReceiverProvider(),
+ eventSerializer, RETRY_BACKOFF_CONFIGURATION, routingKeyConverter,
+ memoryEventDeadLetters, new RecordingMetricFactory(), rabbitMQExtension.getRabbitChannelPool());
+
+ eventBus.start();
+ }
+
+ @AfterEach
+ void tearDown() {
+ eventBus.stop();
+ }
+
+ @Test
+ void dispatchShouldWorkAfterNetworkIssuesForOldRegistration() {
+ MailboxListener listener = newListener();
+ eventBus.register(listener, GROUP_A);
+
+ rabbitMQExtension.getRabbitMQ().pause();
+
+ assertThatThrownBy(() -> eventBus.dispatch(EVENT, NO_KEYS).block())
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("Retries exhausted");
+
+ rabbitMQExtension.getRabbitMQ().unpause();
+
+ eventBus.dispatch(EVENT, NO_KEYS).block();
+ RabbitMQFixture.awaitAtMostThirtySeconds
+ .untilAsserted(() -> verify(listener).event(EVENT));
+ }
+
+}
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
index 80650a9..7c8ee5f 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
@@ -460,24 +460,6 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
}
@Test
- void dispatchShouldWorkAfterNetworkIssuesForOldRegistration() {
- rabbitMQEventBusWithNetWorkIssue.start();
- MailboxListener listener = newListener();
- rabbitMQEventBusWithNetWorkIssue.register(listener, GROUP_A);
-
- rabbitMQNetWorkIssueExtension.getRabbitMQ().pause();
-
- assertThatThrownBy(() -> rabbitMQEventBusWithNetWorkIssue.dispatch(EVENT, NO_KEYS).block())
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Retries exhausted");
-
- rabbitMQNetWorkIssueExtension.getRabbitMQ().unpause();
-
- rabbitMQEventBusWithNetWorkIssue.dispatch(EVENT, NO_KEYS).block();
- assertThatListenerReceiveOneEvent(listener);
- }
-
- @Test
void dispatchShouldWorkAfterNetworkIssuesForOldRegistrationAndKey() {
rabbitMQEventBusWithNetWorkIssue.start();
MailboxListener listener = newListener();
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org