james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [james-project] 05/06: JAMES-2774 Using another docker rabbit for the unstable test
Date Wed, 05 Jun 2019 03:01:31 GMT
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 085de7b1a34008606c795c7cb2c53939293f2824
Author: Tran Tien Duc <dtran@linagora.com>
AuthorDate: Wed May 22 17:30:05 2019 +0700

    JAMES-2774 Using another docker rabbit for the unstable test
---
 .../james/mailbox/events/RabbitMQEventBusTest.java | 55 +++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

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 45213fe..84616ac 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
@@ -52,6 +52,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.james.backend.rabbitmq.RabbitMQExtension;
 import org.apache.james.backend.rabbitmq.RabbitMQFixture;
 import org.apache.james.backend.rabbitmq.RabbitMQManagementAPI;
+import org.apache.james.backend.rabbitmq.SimpleConnectionPool;
 import org.apache.james.event.json.EventSerializer;
 import org.apache.james.mailbox.events.EventBusTestFixture.GroupA;
 import org.apache.james.mailbox.events.EventBusTestFixture.MailboxListenerCountingSuccessfulExecution;
@@ -65,6 +66,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.stubbing.Answer;
 
@@ -84,6 +86,21 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
     KeyContract.SingleEventBusKeyContract, KeyContract.MultipleEventBusKeyContract,
     ErrorHandlingContract {
 
+    static class TestScopedRabbitMQExtension extends RabbitMQExtension {
+
+        @Override
+        public void beforeEach(ExtensionContext extensionContext) throws Exception {
+            super.beforeAll(extensionContext);
+            super.beforeEach(extensionContext);
+        }
+
+        @Override
+        public void afterEach(ExtensionContext context) {
+            super.afterEach(context);
+            super.afterAll(context);
+        }
+    }
+
     @RegisterExtension
     static RabbitMQExtension rabbitMQExtension = new RabbitMQExtension();
 
@@ -128,7 +145,11 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
     }
 
     private RabbitMQEventBus newEventBus() {
-        return new RabbitMQEventBus(rabbitMQExtension.getRabbitConnectionPool(), eventSerializer,
RetryBackoffConfiguration.DEFAULT, routingKeyConverter, memoryEventDeadLetters, new NoopMetricFactory());
+        return newEventBus(rabbitMQExtension.getRabbitConnectionPool());
+    }
+
+    private RabbitMQEventBus newEventBus(SimpleConnectionPool connectionPool) {
+        return new RabbitMQEventBus(connectionPool, eventSerializer, RetryBackoffConfiguration.DEFAULT,
routingKeyConverter, memoryEventDeadLetters, new NoopMetricFactory());
     }
 
     @Override
@@ -294,6 +315,38 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
 
         @Nested
         class SingleEventBus {
+
+            @Nested
+            class DispatchingWhenNetWorkIssue {
+
+                @RegisterExtension
+                TestScopedRabbitMQExtension rabbitMQNetWorkIssueExtension = new TestScopedRabbitMQExtension();
+
+                private RabbitMQEventBus rabbitMQEventBusWithNetWorkIssue;
+
+                @BeforeEach
+                void beforeEach() {
+                    rabbitMQEventBusWithNetWorkIssue = newEventBus(rabbitMQNetWorkIssueExtension.getRabbitConnectionPool());
+                }
+
+                @Test
+                void dispatchShouldWorkAfterNetworkIssuesForOldRegistration() throws Exception
{
+                    rabbitMQEventBusWithNetWorkIssue.start();
+                    MailboxListener listener = newListener();
+                    rabbitMQEventBusWithNetWorkIssue.register(listener, GROUP_A);
+
+                    rabbitMQNetWorkIssueExtension.getRabbitMQ().pause();
+
+                    assertThatThrownBy(() -> rabbitMQEventBusWithNetWorkIssue.dispatch(EVENT,
NO_KEYS).block())
+                        .isInstanceOf(RabbitFluxException.class);
+
+                    rabbitMQNetWorkIssueExtension.getRabbitMQ().unpause();
+
+                    rabbitMQEventBusWithNetWorkIssue.dispatch(EVENT, NO_KEYS).block();
+                    assertThatListenerReceiveOneEvent(listener);
+                }
+            }
+
             @Test
             void startShouldCreateEventExchange() {
                 eventBus.start();


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


Mime
View raw message