james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [18/19] james-project git commit: JAMES-2541 Improve testing speed
Date Mon, 10 Sep 2018 10:34:21 GMT
JAMES-2541 Improve testing speed

RabbitMQMailQueueTest 4 min 30 -> 1 min


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8ed6400c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8ed6400c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8ed6400c

Branch: refs/heads/master
Commit: 8ed6400c758b86b0e3896c9207c57fd8dfa9ed48
Parents: 197ea1e
Author: Benoit Tellier <btellier@linagora.com>
Authored: Fri Sep 7 16:10:17 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Sep 10 17:19:38 2018 +0700

----------------------------------------------------------------------
 .../queue/rabbitmq/RabbitMQMailQueueTest.java   |  3 +-
 .../rabbitmq/RabbitMqMailQueueFactoryTest.java  |  2 +-
 .../ReusableDockerRabbitMQExtension.java        | 59 ++++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8ed6400c/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index a75f761..b9f56ff 100644
--- a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -44,7 +44,7 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.extension.ExtendWith;
 
-@ExtendWith({DockerRabbitMQExtension.class, DockerCassandraExtension.class})
+@ExtendWith({ReusableDockerRabbitMQExtension.class, DockerCassandraExtension.class})
 public class RabbitMQMailQueueTest implements MailQueueContract {
     private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
 
@@ -67,6 +67,7 @@ public class RabbitMQMailQueueTest implements MailQueueContract {
             .setHost(rabbitMQ.getHostIp())
             .setPort(rabbitMQ.getAdminPort())
             .build();
+
         RabbitClient rabbitClient = new RabbitClient(rabbitMQ.connectionFactory().newConnection().createChannel());
         RabbitMQMailQueue.Factory factory = new RabbitMQMailQueue.Factory(rabbitClient, mimeMessageStore,
BLOB_ID_FACTORY);
         RabbitMQManagementApi mqManagementApi = new RabbitMQManagementApi(rabbitManagementUri,
new RabbitMQManagementCredentials("guest", "guest".toCharArray()));

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ed6400c/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMqMailQueueFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMqMailQueueFactoryTest.java
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMqMailQueueFactoryTest.java
index 60b3e10..1ff0510 100644
--- a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMqMailQueueFactoryTest.java
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMqMailQueueFactoryTest.java
@@ -44,7 +44,7 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.extension.ExtendWith;
 
-@ExtendWith({DockerRabbitMQExtension.class, DockerCassandraExtension.class})
+@ExtendWith({ReusableDockerRabbitMQExtension.class, DockerCassandraExtension.class})
 class RabbitMqMailQueueFactoryTest implements MailQueueFactoryContract<RabbitMQMailQueue>
{
     private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ed6400c/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/ReusableDockerRabbitMQExtension.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/ReusableDockerRabbitMQExtension.java
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/ReusableDockerRabbitMQExtension.java
new file mode 100644
index 0000000..3072b9c
--- /dev/null
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/ReusableDockerRabbitMQExtension.java
@@ -0,0 +1,59 @@
+/****************************************************************
+ * 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.queue.rabbitmq;
+
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class ReusableDockerRabbitMQExtension implements BeforeAllCallback, AfterAllCallback,
AfterEachCallback, ParameterResolver {
+
+    private DockerRabbitMQ rabbitMQ;
+
+    @Override
+    public void beforeAll(ExtensionContext context) {
+        rabbitMQ = DockerRabbitMQ.withoutCookie();
+        rabbitMQ.start();
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context) throws Exception {
+        rabbitMQ.reset();
+    }
+
+    @Override
+    public void afterAll(ExtensionContext extensionContext) {
+        rabbitMQ.stop();
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext
extensionContext) throws ParameterResolutionException {
+        return (parameterContext.getParameter().getType() == DockerRabbitMQ.class);
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
throws ParameterResolutionException {
+        return rabbitMQ;
+    }
+
+}


---------------------------------------------------------------------
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