You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2018/07/12 15:37:39 UTC
[01/11] james-project git commit: JAMES-2464 ConcurrentTestRunner
should use a builder
Repository: james-project
Updated Branches:
refs/heads/master 751e4fc5e -> 7442ad385
JAMES-2464 ConcurrentTestRunner should use a builder
This allows:
- Removing the confusion between threadCount & operationCount
- Allow a default value for operationCount (1)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1b76753a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1b76753a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1b76753a
Branch: refs/heads/master
Commit: 1b76753a7690984cdef57cc8238e4353e3e39bb0
Parents: 2db5e2f
Author: benwa <bt...@linagora.com>
Authored: Wed Jul 11 10:10:21 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Jul 11 12:53:16 2018 +0700
----------------------------------------------------------------------
.../CassandraMailboxMapperConcurrencyTest.java | 12 +-
.../QuotaThresholdMailingIntegrationTest.java | 5 +-
.../store/mail/model/MessageIdMapperTest.java | 16 ++-
.../store/mail/model/MessageMapperTest.java | 16 ++-
.../mailbox/tika/CachingTextExtractorTest.java | 7 +-
.../processor/base/UidMsnConverterTest.java | 25 ++--
.../protocols/smtp/AbstractSMTPServerTest.java | 15 +-
.../utils/InMemoryMailRepositoryStoreTest.java | 6 +-
.../util/concurrency/ConcurrentTestRunner.java | 46 +++++-
.../concurrency/ConcurrentTestRunnerTest.java | 142 +++++++++----------
.../api/MailRepositoryUrlStoreContract.java | 13 +-
.../mailrepository/MailRepositoryContract.java | 8 +-
.../org/apache/james/jmap/ProvisioningTest.java | 5 +-
.../DefaultMailboxesProvisioningFilterTest.java | 7 +-
14 files changed, 190 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
index cceb4f3..8f99a59 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
@@ -67,8 +67,10 @@ public class CassandraMailboxMapperConcurrencyTest {
@Test
public void saveShouldBeThreadSafe() throws Exception {
- boolean termination = new ConcurrentTestRunner(THREAD_COUNT, OPERATION_COUNT,
- (a, b) -> testee.save(new SimpleMailbox(MAILBOX_PATH, UID_VALIDITY)))
+ boolean termination = ConcurrentTestRunner.builder()
+ .threadCount(THREAD_COUNT)
+ .operationCount(OPERATION_COUNT)
+ .build((a, b) -> testee.save(new SimpleMailbox(MAILBOX_PATH, UID_VALIDITY)))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
@@ -83,8 +85,10 @@ public class CassandraMailboxMapperConcurrencyTest {
mailbox.setName("newName");
- boolean termination = new ConcurrentTestRunner(THREAD_COUNT, OPERATION_COUNT,
- (a, b) -> testee.save(mailbox))
+ boolean termination = ConcurrentTestRunner.builder()
+ .threadCount(THREAD_COUNT)
+ .operationCount(OPERATION_COUNT)
+ .build((a, b) -> testee.save(mailbox))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
index 2dbc69b..964570c 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
@@ -211,8 +211,9 @@ public interface QuotaThresholdMailingIntegrationTest {
.gracePeriod(GRACE_PERIOD)
.build());
- new ConcurrentTestRunner(10, 1, (threadNb, step) ->
- testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)))
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((threadNb, step) -> testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
index afafc1d..db3cd6e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
@@ -677,8 +677,10 @@ public abstract class MessageIdMapperTest {
int threadCount = 2;
int updateCount = 10;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> sut.setFlags(message1.getMessageId(),
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> sut.setFlags(message1.getMessageId(),
ImmutableList.of(message1.getMailboxId()),
new Flags("custom-" + threadNumber + "-" + step),
FlagsUpdateMode.ADD)).run()
@@ -697,10 +699,12 @@ public abstract class MessageIdMapperTest {
message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));
sut.save(message1);
- final int threadCount = 4;
- final int updateCount = 20;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> {
+ int threadCount = 4;
+ int updateCount = 20;
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> {
if (step < updateCount / 2) {
sut.setFlags(message1.getMessageId(),
ImmutableList.of(message1.getMailboxId()),
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
index 5dc3105..a993d81 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
@@ -796,8 +796,10 @@ public abstract class MessageMapperTest {
int threadCount = 2;
int updateCount = 10;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> messageMapper.updateFlags(benwaInboxMailbox,
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> messageMapper.updateFlags(benwaInboxMailbox,
new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
MessageRange.one(message1.getUid()))).run()
.awaitTermination(1, TimeUnit.MINUTES))
@@ -814,10 +816,12 @@ public abstract class MessageMapperTest {
Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.THREAD_SAFE_FLAGS_UPDATE));
saveMessages();
- final int threadCount = 4;
- final int updateCount = 20;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> {
+ int threadCount = 4;
+ int updateCount = 20;
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> {
if (step < updateCount / 2) {
messageMapper.updateFlags(benwaInboxMailbox,
new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
index e5b4d02..1cc2a40 100644
--- a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
+++ b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
@@ -185,10 +185,9 @@ public class CachingTextExtractorTest {
@RepeatedTest(10)
void concurrentValueComputationShouldNotLeadToDuplicatedBackendAccess() throws Exception {
- int concurrentThreadCount = 10;
- int operationCount = 1;
- new ConcurrentTestRunner(concurrentThreadCount, operationCount,
- (a, b) -> textExtractor.extractContent(INPUT_STREAM.get(), CONTENT_TYPE))
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((a, b) -> textExtractor.extractContent(INPUT_STREAM.get(), CONTENT_TYPE))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
index e793adc..9da76ae 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
@@ -365,14 +365,15 @@ public class UidMsnConverterTest {
@Test
public void addAndRemoveShouldLeadToMonoticMSNToUIDConversionWhenMixed() throws Exception {
- final int initialCount = 1000;
+ int initialCount = 1000;
for (int i = 1; i <= initialCount; i++) {
testee.addUid(MessageUid.of(i));
}
- int threadCount = 2;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, initialCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(initialCount)
+ .build((threadNumber, step) -> {
if (threadNumber == 0) {
testee.remove(MessageUid.of(step + 1));
} else {
@@ -392,11 +393,13 @@ public class UidMsnConverterTest {
@Test
public void addShouldLeadToMonoticMSNToUIDConversionWhenConcurrent() throws Exception {
- final int operationCount = 1000;
+ int operationCount = 1000;
int threadCount = 2;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> testee.addUid(MessageUid.of((threadNumber * operationCount) + (step + 1))));
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(operationCount)
+ .build((threadNumber, step) -> testee.addUid(MessageUid.of((threadNumber * operationCount) + (step + 1))));
concurrentTestRunner.run();
concurrentTestRunner.awaitTermination(10, TimeUnit.SECONDS);
@@ -410,14 +413,16 @@ public class UidMsnConverterTest {
@Test
public void removeShouldLeadToMonoticMSNToUIDConversionWhenConcurrent() throws Exception {
- final int operationCount = 1000;
+ int operationCount = 1000;
int threadCount = 2;
for (int i = 1; i <= operationCount * (threadCount + 1); i++) {
testee.addUid(MessageUid.of(i));
}
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> testee.remove(MessageUid.of((threadNumber * operationCount) + (step + 1))));
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(operationCount)
+ .build((threadNumber, step) -> testee.remove(MessageUid.of((threadNumber * operationCount) + (step + 1))));
concurrentTestRunner.run();
concurrentTestRunner.awaitTermination(10, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
index 966347e..e6891eb 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
@@ -99,13 +99,14 @@ public abstract class AbstractSMTPServerTest {
server = createServer(createProtocol(hook));
server.bind();
- final ProtocolServer finalServer = server;
- final InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress();
- final String mailContent = CharStreams.toString(new InputStreamReader(ClassLoader.getSystemResourceAsStream("a50.eml"), StandardCharsets.US_ASCII));
- int threadCount = 4;
- int updateCount = 1;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> send(finalServer, bindedAddress, mailContent)).run()
+ ProtocolServer finalServer = server;
+ InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress();
+ String mailContent = CharStreams.toString(new InputStreamReader(ClassLoader.getSystemResourceAsStream("a50.eml"), StandardCharsets.US_ASCII));
+
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(4)
+ .build((threadNumber, step) -> send(finalServer, bindedAddress, mailContent))
+ .run()
.awaitTermination(1, TimeUnit.MINUTES))
.isTrue();
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
index 5ad89e4..cb6cb00 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
@@ -240,10 +240,10 @@ public class InMemoryMailRepositoryStoreTest {
public void selectShouldNotReturnDifferentResultsWhenUsedInAConcurrentEnvironment() throws Exception {
MailRepositoryUrl url = MailRepositoryUrl.from("memory://repo");
int threadCount = 10;
- int operationCount = 1;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNb, operationNb) -> repositoryStore.select(url)
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((threadNb, operationNb) -> repositoryStore.select(url)
.store(FakeMail.builder()
.name("name" + threadNb)
.mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java b/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
index 23fd57c..0efb525 100644
--- a/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
+++ b/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
@@ -21,6 +21,7 @@ package org.apache.james.util.concurrency;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -35,7 +36,39 @@ import com.google.common.base.Preconditions;
public class ConcurrentTestRunner {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConcurrentTestRunner.class);
+ public static final int DEFAULT_OPERATION_COUNT = 1;
+
+ public static class Builder {
+ private Optional<Integer> threadCount;
+ private Optional<Integer> operationCount;
+
+ public Builder() {
+ threadCount = Optional.empty();
+ operationCount = Optional.empty();
+ }
+
+ public Builder threadCount(int threadCount) {
+ Preconditions.checkArgument(threadCount > 0, "Thread count should be strictly positive");
+ this.threadCount = Optional.of(threadCount);
+ return this;
+ }
+
+ public Builder operationCount(int operationCount) {
+ Preconditions.checkArgument(operationCount > 0, "Operation count should be strictly positive");
+ this.operationCount = Optional.of(operationCount);
+ return this;
+ }
+
+ public ConcurrentTestRunner build(BiConsumer operation) {
+ Preconditions.checkState(threadCount.isPresent(), "'threadCount' is compulsory");
+ Preconditions.checkNotNull(operation);
+
+ return new ConcurrentTestRunner(
+ threadCount.get(),
+ operationCount.orElse(DEFAULT_OPERATION_COUNT),
+ operation);
+ }
+ }
public interface BiConsumer {
void consume(int threadNumber, int step) throws Exception;
@@ -69,6 +102,12 @@ public class ConcurrentTestRunner {
}
}
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConcurrentTestRunner.class);
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
private final int threadCount;
private final int operationCount;
private final CountDownLatch countDownLatch;
@@ -76,10 +115,7 @@ public class ConcurrentTestRunner {
private final ExecutorService executorService;
private final List<Future<?>> futures;
- public ConcurrentTestRunner(int threadCount, int operationCount, BiConsumer biConsumer) {
- Preconditions.checkArgument(threadCount > 0, "Thread count should be strictly positive");
- Preconditions.checkArgument(operationCount > 0, "Operation count should be strictly positive");
- Preconditions.checkNotNull(biConsumer);
+ private ConcurrentTestRunner(int threadCount, int operationCount, BiConsumer biConsumer) {
this.threadCount = threadCount;
this.operationCount = operationCount;
this.countDownLatch = new CountDownLatch(threadCount);
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java b/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
index 4a03fe1..5eac926 100644
--- a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
@@ -20,74 +20,64 @@
package org.apache.james.util.concurrency;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
public class ConcurrentTestRunnerTest {
-
public static final ConcurrentTestRunner.BiConsumer EMPTY_BI_CONSUMER = (threadNumber, step) -> { };
public static final int DEFAULT_AWAIT_TIME = 100;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void constructorShouldThrowOnNegativeThreadCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = 1;
- int threadCount = -1;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .threadCount(-1))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnNegativeOperationCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = -1;
- int threadCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .operationCount(-1))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnZeroThreadCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = 1;
- int threadCount = 0;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .threadCount(0))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnZeroOperationCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = 0;
- int threadCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .operationCount(0))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnNullBiConsumer() {
- expectedException.expect(NullPointerException.class);
-
- int operationCount = 1;
- int threadCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount, null);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .threadCount(1)
+ .build(null))
+ .isInstanceOf(NullPointerException.class);
}
@Test
public void awaitTerminationShouldReturnTrueWhenFinished() throws Exception {
- int operationCount = 1;
- int threadCount = 1;
-
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER)
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(1)
+ .build(EMPTY_BI_CONSUMER)
.run();
assertThat(concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS)).isTrue();
@@ -95,12 +85,11 @@ public class ConcurrentTestRunnerTest {
@Test
public void awaitTerminationShouldReturnFalseWhenNotFinished() throws Exception {
- int operationCount = 1;
- int threadCount = 1;
- final int sleepDelay = 50;
+ int sleepDelay = 50;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> Thread.sleep(sleepDelay))
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(1)
+ .build((threadNumber, step) -> Thread.sleep(sleepDelay))
.run();
assertThat(concurrentTestRunner.awaitTermination(sleepDelay / 2, TimeUnit.MILLISECONDS)).isFalse();
@@ -108,12 +97,12 @@ public class ConcurrentTestRunnerTest {
@Test
public void runShouldPerformAllOperations() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
- final ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> queue.add(threadNumber + ":" + step))
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> queue.add(threadNumber + ":" + step))
.run();
assertThat(concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS)).isTrue();
@@ -121,12 +110,24 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void runShouldNotThrowOnExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
+ public void operationCountShouldDefaultToOne() throws Exception {
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .build((threadNumber, step) -> queue.add(threadNumber + ":" + step))
+ .run();
+
+ assertThat(concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS)).isTrue();
+ assertThat(queue).containsOnly("0:0", "1:0");
+ }
+
+ @Test
+ public void runShouldNotThrowOnExceptions() throws Exception {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
throw new RuntimeException();
})
.run();
@@ -136,10 +137,10 @@ public class ConcurrentTestRunnerTest {
@Test
public void noExceptionsShouldNotThrowWhenNoExceptionGenerated() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
-
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER)
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build(EMPTY_BI_CONSUMER)
.run();
concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS);
@@ -149,28 +150,27 @@ public class ConcurrentTestRunnerTest {
@Test
public void assertNoExceptionShouldThrowOnExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
-
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
throw new RuntimeException();
})
.run();
concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS);
- expectedException.expect(ExecutionException.class);
- concurrentTestRunner.assertNoException();
+ assertThatThrownBy(concurrentTestRunner::assertNoException)
+ .isInstanceOf(ExecutionException.class);
}
@Test
public void runShouldPerformAllOperationsEvenOnExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
- final ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
queue.add(threadNumber + ":" + step);
throw new RuntimeException();
})
@@ -182,12 +182,12 @@ public class ConcurrentTestRunnerTest {
@Test
public void runShouldPerformAllOperationsEvenOnOccasionalExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
- final ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
queue.add(threadNumber + ":" + step);
if ((threadNumber + step) % 2 == 0) {
throw new RuntimeException();
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java b/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
index 8260deb..9bbe365 100644
--- a/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
+++ b/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
@@ -74,8 +74,10 @@ public interface MailRepositoryUrlStoreContract {
default void addShouldWorkInConcurrentEnvironment(MailRepositoryUrlStore store) throws Exception {
int operationCount = 10;
int threadCount = 10;
- ConcurrentTestRunner testRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (a, b) -> store.add(MailRepositoryUrl.from("proto://" + a + "/" + b)))
+ ConcurrentTestRunner testRunner = ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(operationCount)
+ .build((a, b) -> store.add(MailRepositoryUrl.from("proto://" + a + "/" + b)))
.run();
testRunner.awaitTermination(1, TimeUnit.MINUTES);
testRunner.assertNoException();
@@ -86,9 +88,10 @@ public interface MailRepositoryUrlStoreContract {
@Test
default void addShouldNotAddDuplicatesInConcurrentEnvironment(MailRepositoryUrlStore store) throws Exception {
int operationCount = 10;
- int threadCount = 10;
- ConcurrentTestRunner testRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (a, b) -> store.add(MailRepositoryUrl.from("proto://" + b)))
+ ConcurrentTestRunner testRunner = ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .operationCount(operationCount)
+ .build((a, b) -> store.add(MailRepositoryUrl.from("proto://" + b)))
.run();
testRunner.awaitTermination(1, TimeUnit.MINUTES);
testRunner.assertNoException();
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
index d56dee9..3ed562b 100644
--- a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
+++ b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
@@ -381,8 +381,6 @@ public interface MailRepositoryContract {
default void storingAndRemovingMessagesConcurrentlyShouldLeadToConsistentResult() throws Exception {
MailRepository testee = retrieveRepository();
int nbKeys = 20;
- int nbIterations = 10;
- int threadCount = 10;
ConcurrentHashMap.KeySetView<MailKey, Boolean> expectedResult = ConcurrentHashMap.newKeySet();
List<Object> locks = IntStream.range(0, 10)
.boxed()
@@ -412,8 +410,10 @@ public interface MailRepositoryContract {
new DistributionEntry<>(add, 0.25),
new DistributionEntry<>(remove, 0.75)));
- new ConcurrentTestRunner(threadCount, nbIterations,
- (a, b) -> distribution.sample().run())
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .operationCount(10)
+ .build((a, b) -> distribution.sample().run())
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
index e5d49a5..7194ad4 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
@@ -78,8 +78,9 @@ public abstract class ProvisioningTest {
public void provisionMailboxesShouldNotDuplicateMailboxByName() throws Exception {
String token = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD).serialize();
- boolean termination = new ConcurrentTestRunner(10, 1,
- (a, b) -> with()
+ boolean termination = ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((a, b) -> with()
.header("Authorization", token)
.body("[[\"getMailboxes\", {}, \"#0\"]]")
.post("/jmap"))
http://git-wip-us.apache.org/repos/asf/james-project/blob/1b76753a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
index 08522f1..ea0dd1f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
@@ -89,10 +89,9 @@ public class DefaultMailboxesProvisioningFilterTest {
@Test
public void createMailboxesIfNeededShouldNotGenerateExceptionsInConcurrentEnvironment() throws Exception {
- int threadCount = 10;
- int operationCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> testee.createMailboxesIfNeeded(session))
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((threadNumber, step) -> testee.createMailboxesIfNeeded(session))
.run()
.assertNoException()
.awaitTermination(10, TimeUnit.SECONDS);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[08/11] james-project git commit: Merge remote-tracking branch
'benoit/JAMES-2464'
Posted by ro...@apache.org.
Merge remote-tracking branch 'benoit/JAMES-2464'
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d677f23c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d677f23c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d677f23c
Branch: refs/heads/master
Commit: d677f23c0d34332e132b1fdf91bf904143e40077
Parents: 751e4fc 1b76753
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Jul 12 17:34:45 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Jul 12 17:34:45 2018 +0200
----------------------------------------------------------------------
.../CassandraMailboxMapperConcurrencyTest.java | 12 +-
.../QuotaThresholdMailingIntegrationTest.java | 5 +-
.../store/mail/model/MessageIdMapperTest.java | 16 ++-
.../store/mail/model/MessageMapperTest.java | 16 ++-
.../mailbox/tika/CachingTextExtractorTest.java | 7 +-
.../processor/base/UidMsnConverterTest.java | 25 ++--
.../protocols/smtp/AbstractSMTPServerTest.java | 15 +-
.../utils/InMemoryMailRepositoryStoreTest.java | 6 +-
.../util/concurrency/ConcurrentTestRunner.java | 46 +++++-
.../concurrency/ConcurrentTestRunnerTest.java | 142 +++++++++----------
.../api/MailRepositoryUrlStoreContract.java | 13 +-
.../mailrepository/MailRepositoryContract.java | 8 +-
.../org/apache/james/jmap/ProvisioningTest.java | 5 +-
.../DefaultMailboxesProvisioningFilterTest.java | 7 +-
14 files changed, 190 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[02/11] james-project git commit: Fix warnings
Posted by ro...@apache.org.
Fix warnings
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/bbb70413
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/bbb70413
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/bbb70413
Branch: refs/heads/master
Commit: bbb70413371bbc0917603f3b7593370ce433e13e
Parents: 751e4fc
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Wed Jul 11 17:04:14 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Wed Jul 11 17:04:14 2018 +0200
----------------------------------------------------------------------
.../test/java/org/apache/james/queue/file/FileMailQueueTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/bbb70413/server/queue/queue-file/src/test/java/org/apache/james/queue/file/FileMailQueueTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-file/src/test/java/org/apache/james/queue/file/FileMailQueueTest.java b/server/queue/queue-file/src/test/java/org/apache/james/queue/file/FileMailQueueTest.java
index d0700af..d829200 100644
--- a/server/queue/queue-file/src/test/java/org/apache/james/queue/file/FileMailQueueTest.java
+++ b/server/queue/queue-file/src/test/java/org/apache/james/queue/file/FileMailQueueTest.java
@@ -23,10 +23,10 @@ import org.apache.james.queue.api.DelayedManageableMailQueueContract;
import org.apache.james.queue.api.MailQueue;
import org.apache.james.queue.api.ManageableMailQueue;
import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
-import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.junit.rules.TemporaryFolder;
public class FileMailQueueTest implements DelayedManageableMailQueueContract {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[09/11] james-project git commit: Merge remote-tracking branch
'benoit/JAMES-2465'
Posted by ro...@apache.org.
Merge remote-tracking branch 'benoit/JAMES-2465'
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8c7b5206
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8c7b5206
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8c7b5206
Branch: refs/heads/master
Commit: 8c7b52068f7cb0af20b84c25fc43b4ea040e9af7
Parents: d677f23 2cc467f
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Jul 12 17:35:28 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Jul 12 17:35:28 2018 +0200
----------------------------------------------------------------------
.../mailets/delivery/MailboxAppender.java | 10 ++++-
.../mailets/delivery/MailboxAppenderTest.java | 45 +++++++++++---------
2 files changed, 35 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[06/11] james-project git commit: JAMES-2466 Turn logback logging
level to WARN in tests
Posted by ro...@apache.org.
JAMES-2466 Turn logback logging level to WARN in tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5dab030a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5dab030a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5dab030a
Branch: refs/heads/master
Commit: 5dab030a20f7c1bc47d72f59e4e33af4e7a6d69d
Parents: 751e4fc
Author: benwa <bt...@linagora.com>
Authored: Thu Jul 12 11:30:14 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Thu Jul 12 11:30:54 2018 +0700
----------------------------------------------------------------------
.../src/test/resources/logback-test.xml | 4 ++--
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 8 +------
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../tika/src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../core/src/main/resources/logback.xml | 2 +-
.../imap/src/test/resources/logback-test.xml | 2 +-
server/container/cli-integration/pom.xml | 16 +++++++++----
.../src/test/resources/logback-test.xml | 2 --
.../src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 22 ++++++++++++++++++
.../src/test/resources/logback.xml | 24 --------------------
.../src/test/resources/logback-test.xml | 2 +-
.../mailets/src/test/resources/logback-test.xml | 4 ++--
.../src/test/resources/logback-test.xml | 15 ++++++++++++
.../src/test/resources/logback-test.xml | 15 ++++++++++++
.../src/test/resources/logback-test.xml | 4 ++--
23 files changed, 155 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/backends-common/cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/resources/logback-test.xml b/backends-common/cassandra/src/test/resources/logback-test.xml
index ed489a2..b02f0d8 100644
--- a/backends-common/cassandra/src/test/resources/logback-test.xml
+++ b/backends-common/cassandra/src/test/resources/logback-test.xml
@@ -12,12 +12,12 @@
</encoder>
</appender>
- <root level="INFO">
+ <root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
- <logger name="org.apache.james" level="DEBUG" >
+ <logger name="org.apache.james" level="WARN" >
<appender-ref ref="CONSOLE" />
</logger>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/event-sourcing/event-store-cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/resources/logback-test.xml b/event-sourcing/event-store-cassandra/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..705a933
--- /dev/null
+++ b/event-sourcing/event-store-cassandra/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/mailbox/cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/resources/logback-test.xml b/mailbox/cassandra/src/test/resources/logback-test.xml
index 8785627..b5e1a77 100644
--- a/mailbox/cassandra/src/test/resources/logback-test.xml
+++ b/mailbox/cassandra/src/test/resources/logback-test.xml
@@ -12,7 +12,7 @@
</encoder>
</appender>
- <root level="INFO">
+ <root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/mailbox/elasticsearch/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/resources/logback-test.xml b/mailbox/elasticsearch/src/test/resources/logback-test.xml
index 0c52f6b..b0c305c 100644
--- a/mailbox/elasticsearch/src/test/resources/logback-test.xml
+++ b/mailbox/elasticsearch/src/test/resources/logback-test.xml
@@ -17,13 +17,7 @@
</root>
- <logger name="org.apache.james" level="DEBUG" >
- <appender-ref ref="CONSOLE" />
- </logger>
-
- <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
-
- <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" level="WARN" >
+ <logger name="org.apache.james" level="WARN" >
<appender-ref ref="CONSOLE" />
</logger>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/mailbox/plugin/quota-mailing-cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/test/resources/logback-test.xml b/mailbox/plugin/quota-mailing-cassandra/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..705a933
--- /dev/null
+++ b/mailbox/plugin/quota-mailing-cassandra/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/mailbox/tika/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/tika/src/test/resources/logback-test.xml b/mailbox/tika/src/test/resources/logback-test.xml
index f2c08d8..8b79495 100644
--- a/mailbox/tika/src/test/resources/logback-test.xml
+++ b/mailbox/tika/src/test/resources/logback-test.xml
@@ -12,7 +12,7 @@
</encoder>
</appender>
- <root level="INFO">
+ <root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/mailet/icalendar/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailet/icalendar/src/test/resources/logback-test.xml b/mailet/icalendar/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..705a933
--- /dev/null
+++ b/mailet/icalendar/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/mpt/impl/imap-mailbox/core/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/logback.xml b/mpt/impl/imap-mailbox/core/src/main/resources/logback.xml
index 72816f6..6fc0ac3 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/logback.xml
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/logback.xml
@@ -16,7 +16,7 @@
<appender-ref ref="CONSOLE" />
</root>
- <logger name="org.apache.james" level="DEBUG">
+ <logger name="org.apache.james" level="WARN">
<appender-ref ref="CONSOLE" />
</logger>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/protocols/imap/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/resources/logback-test.xml b/protocols/imap/src/test/resources/logback-test.xml
index 5e4c459..dc902a7 100644
--- a/protocols/imap/src/test/resources/logback-test.xml
+++ b/protocols/imap/src/test/resources/logback-test.xml
@@ -17,7 +17,7 @@
</root>
- <logger name="org.apache.james" level="DEBUG" >
+ <logger name="org.apache.james" level="WARN" >
<appender-ref ref="CONSOLE" />
</logger>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/cli-integration/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/cli-integration/pom.xml b/server/container/cli-integration/pom.xml
index 617239c..dca39f7 100644
--- a/server/container/cli-integration/pom.xml
+++ b/server/container/cli-integration/pom.xml
@@ -35,6 +35,12 @@
<groupId>${project.groupId}</groupId>
<artifactId>james-server-cli</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -61,6 +67,11 @@
</dependency>
<dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.github.fge</groupId>
<artifactId>throwing-lambdas</artifactId>
</dependency>
@@ -78,11 +89,6 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/cli-integration/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/cli-integration/src/test/resources/logback-test.xml b/server/container/cli-integration/src/test/resources/logback-test.xml
index 6f13ac9..705a933 100644
--- a/server/container/cli-integration/src/test/resources/logback-test.xml
+++ b/server/container/cli-integration/src/test/resources/logback-test.xml
@@ -10,6 +10,4 @@
<appender-ref ref="STDOUT" />
</root>
- <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
-
</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml b/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
index 3cc9158..7521c49 100644
--- a/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
+++ b/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
@@ -16,7 +16,7 @@
<appender-ref ref="CONSOLE" />
</root>
- <logger name="org.apache.james" level="INFO"/>
+ <logger name="org.apache.james" level="WARN"/>
<logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/guice/jpa-guice/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/test/resources/logback-test.xml b/server/container/guice/jpa-guice/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..705a933
--- /dev/null
+++ b/server/container/guice/jpa-guice/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/guice/jpa-smtp-mariadb/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/logback-test.xml b/server/container/guice/jpa-smtp-mariadb/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..705a933
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/guice/jpa-smtp/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/test/resources/logback-test.xml b/server/container/guice/jpa-smtp/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..705a933
--- /dev/null
+++ b/server/container/guice/jpa-smtp/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/container/guice/memory-guice/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/logback-test.xml b/server/container/guice/memory-guice/src/test/resources/logback-test.xml
index 3487f0b..4380d45 100644
--- a/server/container/guice/memory-guice/src/test/resources/logback-test.xml
+++ b/server/container/guice/memory-guice/src/test/resources/logback-test.xml
@@ -30,7 +30,7 @@
</encoder>
</appender>
- <root level="INFO">
+ <root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/data/data-ldap-integration-testing/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/src/test/resources/logback-test.xml b/server/data/data-ldap-integration-testing/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..ddbf62c
--- /dev/null
+++ b/server/data/data-ldap-integration-testing/src/test/resources/logback-test.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+ <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
+ <resetJUL>true</resetJUL>
+ </contextListener>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
+ <immediateFlush>false</immediateFlush>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="CONSOLE" />
+ </root>
+
+ <logger name="org.testcontainers" level="WARN"/>
+ <logger name="org.apache.james" level="WARN"/>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/data/data-ldap-integration-testing/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/src/test/resources/logback.xml b/server/data/data-ldap-integration-testing/src/test/resources/logback.xml
deleted file mode 100644
index 4801b91..0000000
--- a/server/data/data-ldap-integration-testing/src/test/resources/logback.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-
- <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
- <resetJUL>true</resetJUL>
- </contextListener>
-
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
- <immediateFlush>false</immediateFlush>
- </encoder>
- </appender>
-
- <root level="DEBUG">
- <appender-ref ref="CONSOLE" />
- </root>
-
- <logger name="org.testcontainers" level="INFO"/>
- <logger name="org.apache.james" level="DEBUG"/>
-
- <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/mailet/integration-testing/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/logback-test.xml b/server/mailet/integration-testing/src/test/resources/logback-test.xml
index 0524945..071b4f8 100644
--- a/server/mailet/integration-testing/src/test/resources/logback-test.xml
+++ b/server/mailet/integration-testing/src/test/resources/logback-test.xml
@@ -12,6 +12,6 @@
<appender-ref ref="CONSOLE" />
</root>
- <logger name="org.apache.james" level="DEBUG"/>
+ <logger name="org.apache.james" level="WARN"/>
</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/mailet/mailets/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/resources/logback-test.xml b/server/mailet/mailets/src/test/resources/logback-test.xml
index 43f4151..ac8c95b 100644
--- a/server/mailet/mailets/src/test/resources/logback-test.xml
+++ b/server/mailet/mailets/src/test/resources/logback-test.xml
@@ -12,11 +12,11 @@
</encoder>
</appender>
- <root level="DEBUG">
+ <root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
- <logger name="org.apache.james" level="DEBUG"/>
+ <logger name="org.apache.james" level="WARN"/>
<logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/logback-test.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..6f13ac9
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/logback-test.xml
@@ -0,0 +1,15 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/protocols/webadmin-integration-test/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/logback-test.xml b/server/protocols/webadmin-integration-test/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..6f13ac9
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/src/test/resources/logback-test.xml
@@ -0,0 +1,15 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/5dab030a/server/queue/queue-rabbitmq/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/resources/logback-test.xml b/server/queue/queue-rabbitmq/src/test/resources/logback-test.xml
index fa5a922..5486d86 100644
--- a/server/queue/queue-rabbitmq/src/test/resources/logback-test.xml
+++ b/server/queue/queue-rabbitmq/src/test/resources/logback-test.xml
@@ -17,7 +17,7 @@
</root>
<logger name="org.testcontainers" level="ERROR"/>
- <logger name="org.apache.james" level="DEBUG"/>
- <logger name="org.apache.james.queue.rabbitmq.DockerRabbitMQ" level="DEBUG"/>
+ <logger name="org.apache.james" level="WARN"/>
+ <logger name="org.apache.james.queue.rabbitmq.DockerRabbitMQ" level="WARN"/>
</configuration>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[11/11] james-project git commit: Merge branch 'JAMES-2467'
Posted by ro...@apache.org.
Merge branch 'JAMES-2467'
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7442ad38
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7442ad38
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7442ad38
Branch: refs/heads/master
Commit: 7442ad385a68639e4d108a7cca7c159a7f04d2dc
Parents: 279cce2 771db64
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Jul 12 17:36:16 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Jul 12 17:36:16 2018 +0200
----------------------------------------------------------------------
README.adoc | 2 +-
.../apache/james/backends/cassandra/DockerCassandraRule.java | 4 ++--
dockerfiles/run/docker-compose.yml | 2 +-
.../java/org/apache/james/queue/file/FileMailQueueTest.java | 2 +-
src/site/markdown/server/install/guice-cassandra.md | 6 +++---
src/site/xdoc/server/quick-start-cassandra.xml | 2 +-
6 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[10/11] james-project git commit: Merge remote-tracking branch
'benoit/JAMES-2466'
Posted by ro...@apache.org.
Merge remote-tracking branch 'benoit/JAMES-2466'
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/279cce21
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/279cce21
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/279cce21
Branch: refs/heads/master
Commit: 279cce21cbc87a0d908c414bf40426afa695ed2b
Parents: 8c7b520 5dab030
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Jul 12 17:35:57 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Jul 12 17:35:57 2018 +0200
----------------------------------------------------------------------
.../src/test/resources/logback-test.xml | 4 ++--
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 8 +------
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../tika/src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../core/src/main/resources/logback.xml | 2 +-
.../imap/src/test/resources/logback-test.xml | 2 +-
server/container/cli-integration/pom.xml | 16 +++++++++----
.../src/test/resources/logback-test.xml | 2 --
.../src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 13 +++++++++++
.../src/test/resources/logback-test.xml | 2 +-
.../src/test/resources/logback-test.xml | 22 ++++++++++++++++++
.../src/test/resources/logback.xml | 24 --------------------
.../src/test/resources/logback-test.xml | 2 +-
.../mailets/src/test/resources/logback-test.xml | 4 ++--
.../src/test/resources/logback-test.xml | 15 ++++++++++++
.../src/test/resources/logback-test.xml | 15 ++++++++++++
.../src/test/resources/logback-test.xml | 4 ++--
23 files changed, 155 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[04/11] james-project git commit: JAMES-2465 Migrate
MailboxAppenderTest to Junit5
Posted by ro...@apache.org.
JAMES-2465 Migrate MailboxAppenderTest to Junit5
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f23a1848
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f23a1848
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f23a1848
Branch: refs/heads/master
Commit: f23a18489bcac26f044ee40f4300f2b90febec47
Parents: 68e03ed
Author: benwa <bt...@linagora.com>
Authored: Thu Jul 12 10:57:41 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Thu Jul 12 10:57:41 2018 +0700
----------------------------------------------------------------------
.../mailets/delivery/MailboxAppenderTest.java | 34 +++++++++-----------
1 file changed, 15 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f23a1848/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
index 866a70e..22e2e9f 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
@@ -20,6 +20,7 @@
package org.apache.james.transport.mailets.delivery;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
@@ -34,11 +35,9 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
import org.apache.james.mailbox.model.MessageResult;
import org.apache.james.mailbox.model.MessageResultIterator;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class MailboxAppenderTest {
@@ -46,16 +45,14 @@ public class MailboxAppenderTest {
public static final String FOLDER = "folder";
public static final String EMPTY_FOLDER = "";
- @Rule public ExpectedException expectedException = ExpectedException.none();
-
private MailboxAppender testee;
private MailboxManager mailboxManager;
private MimeMessage mimeMessage;
private InMemoryIntegrationResources integrationResources;
private MailboxSession session;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
mimeMessage = MimeMessageBuilder.mimeMessageBuilder()
.setMultipartWithBodyParts(
MimeMessageBuilder.bodyPartBuilder()
@@ -70,13 +67,13 @@ public class MailboxAppenderTest {
session = mailboxManager.createSystemSession("TEST");
}
- @After
- public void cleanUp() throws Exception {
+ @AfterEach
+ void cleanUp() {
integrationResources.clean();
}
@Test
- public void appendShouldAddMessageToDesiredMailbox() throws Exception {
+ void appendShouldAddMessageToDesiredMailbox() throws Exception {
testee.append(mimeMessage, USER, FOLDER);
MessageResultIterator messages = mailboxManager.getMailbox(MailboxPath.forUser(USER, FOLDER), session)
@@ -86,7 +83,7 @@ public class MailboxAppenderTest {
}
@Test
- public void appendShouldAddMessageToDesiredMailboxWhenMailboxExists() throws Exception {
+ void appendShouldAddMessageToDesiredMailboxWhenMailboxExists() throws Exception {
MailboxPath mailboxPath = MailboxPath.forUser(USER, FOLDER);
mailboxManager.createMailbox(mailboxPath, session);
@@ -99,14 +96,13 @@ public class MailboxAppenderTest {
}
@Test
- public void appendShouldNotAppendToEmptyFolder() throws Exception {
- expectedException.expect(MessagingException.class);
-
- testee.append(mimeMessage, USER, EMPTY_FOLDER);
+ void appendShouldNotAppendToEmptyFolder() {
+ assertThatThrownBy(() -> testee.append(mimeMessage, USER, EMPTY_FOLDER))
+ .isInstanceOf(MessagingException.class);
}
@Test
- public void appendShouldRemovePathSeparatorAsFirstChar() throws Exception {
+ void appendShouldRemovePathSeparatorAsFirstChar() throws Exception {
testee.append(mimeMessage, USER, "." + FOLDER);
MessageResultIterator messages = mailboxManager.getMailbox(MailboxPath.forUser(USER, FOLDER), session)
@@ -116,7 +112,7 @@ public class MailboxAppenderTest {
}
@Test
- public void appendShouldReplaceSlashBySeparator() throws Exception {
+ void appendShouldReplaceSlashBySeparator() throws Exception {
testee.append(mimeMessage, USER, FOLDER + "/any");
MessageResultIterator messages = mailboxManager.getMailbox(MailboxPath.forUser(USER, FOLDER + ".any"), session)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[03/11] james-project git commit: JAMES-2464 ConcurrentTestRunner
should use a builder
Posted by ro...@apache.org.
JAMES-2464 ConcurrentTestRunner should use a builder
This allows:
- Removing the confusion between threadCount & operationCount
- Allow a default value for operationCount (1)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/68e03ede
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/68e03ede
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/68e03ede
Branch: refs/heads/master
Commit: 68e03edea6c088cdb454f5277c694054e1ae4e9a
Parents: 751e4fc
Author: benwa <bt...@linagora.com>
Authored: Wed Jul 11 10:10:21 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Thu Jul 12 10:50:53 2018 +0700
----------------------------------------------------------------------
.../CassandraMailboxMapperConcurrencyTest.java | 12 +-
.../QuotaThresholdMailingIntegrationTest.java | 5 +-
.../store/mail/model/MessageIdMapperTest.java | 16 ++-
.../store/mail/model/MessageMapperTest.java | 16 ++-
.../mailbox/tika/CachingTextExtractorTest.java | 7 +-
.../processor/base/UidMsnConverterTest.java | 25 ++--
.../protocols/smtp/AbstractSMTPServerTest.java | 15 +-
.../utils/InMemoryMailRepositoryStoreTest.java | 6 +-
.../util/concurrency/ConcurrentTestRunner.java | 46 +++++-
.../concurrency/ConcurrentTestRunnerTest.java | 142 +++++++++----------
.../api/MailRepositoryUrlStoreContract.java | 13 +-
.../mailrepository/MailRepositoryContract.java | 8 +-
.../org/apache/james/jmap/ProvisioningTest.java | 5 +-
.../DefaultMailboxesProvisioningFilterTest.java | 7 +-
14 files changed, 190 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
index cceb4f3..8f99a59 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
@@ -67,8 +67,10 @@ public class CassandraMailboxMapperConcurrencyTest {
@Test
public void saveShouldBeThreadSafe() throws Exception {
- boolean termination = new ConcurrentTestRunner(THREAD_COUNT, OPERATION_COUNT,
- (a, b) -> testee.save(new SimpleMailbox(MAILBOX_PATH, UID_VALIDITY)))
+ boolean termination = ConcurrentTestRunner.builder()
+ .threadCount(THREAD_COUNT)
+ .operationCount(OPERATION_COUNT)
+ .build((a, b) -> testee.save(new SimpleMailbox(MAILBOX_PATH, UID_VALIDITY)))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
@@ -83,8 +85,10 @@ public class CassandraMailboxMapperConcurrencyTest {
mailbox.setName("newName");
- boolean termination = new ConcurrentTestRunner(THREAD_COUNT, OPERATION_COUNT,
- (a, b) -> testee.save(mailbox))
+ boolean termination = ConcurrentTestRunner.builder()
+ .threadCount(THREAD_COUNT)
+ .operationCount(OPERATION_COUNT)
+ .build((a, b) -> testee.save(mailbox))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
index 2dbc69b..964570c 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
@@ -211,8 +211,9 @@ public interface QuotaThresholdMailingIntegrationTest {
.gracePeriod(GRACE_PERIOD)
.build());
- new ConcurrentTestRunner(10, 1, (threadNb, step) ->
- testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)))
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((threadNb, step) -> testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
index afafc1d..db3cd6e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
@@ -677,8 +677,10 @@ public abstract class MessageIdMapperTest {
int threadCount = 2;
int updateCount = 10;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> sut.setFlags(message1.getMessageId(),
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> sut.setFlags(message1.getMessageId(),
ImmutableList.of(message1.getMailboxId()),
new Flags("custom-" + threadNumber + "-" + step),
FlagsUpdateMode.ADD)).run()
@@ -697,10 +699,12 @@ public abstract class MessageIdMapperTest {
message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));
sut.save(message1);
- final int threadCount = 4;
- final int updateCount = 20;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> {
+ int threadCount = 4;
+ int updateCount = 20;
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> {
if (step < updateCount / 2) {
sut.setFlags(message1.getMessageId(),
ImmutableList.of(message1.getMailboxId()),
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
index 5dc3105..a993d81 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
@@ -796,8 +796,10 @@ public abstract class MessageMapperTest {
int threadCount = 2;
int updateCount = 10;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> messageMapper.updateFlags(benwaInboxMailbox,
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> messageMapper.updateFlags(benwaInboxMailbox,
new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
MessageRange.one(message1.getUid()))).run()
.awaitTermination(1, TimeUnit.MINUTES))
@@ -814,10 +816,12 @@ public abstract class MessageMapperTest {
Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.THREAD_SAFE_FLAGS_UPDATE));
saveMessages();
- final int threadCount = 4;
- final int updateCount = 20;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> {
+ int threadCount = 4;
+ int updateCount = 20;
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(updateCount)
+ .build((threadNumber, step) -> {
if (step < updateCount / 2) {
messageMapper.updateFlags(benwaInboxMailbox,
new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
index e5b4d02..1cc2a40 100644
--- a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
+++ b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/CachingTextExtractorTest.java
@@ -185,10 +185,9 @@ public class CachingTextExtractorTest {
@RepeatedTest(10)
void concurrentValueComputationShouldNotLeadToDuplicatedBackendAccess() throws Exception {
- int concurrentThreadCount = 10;
- int operationCount = 1;
- new ConcurrentTestRunner(concurrentThreadCount, operationCount,
- (a, b) -> textExtractor.extractContent(INPUT_STREAM.get(), CONTENT_TYPE))
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((a, b) -> textExtractor.extractContent(INPUT_STREAM.get(), CONTENT_TYPE))
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
index e793adc..9da76ae 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/UidMsnConverterTest.java
@@ -365,14 +365,15 @@ public class UidMsnConverterTest {
@Test
public void addAndRemoveShouldLeadToMonoticMSNToUIDConversionWhenMixed() throws Exception {
- final int initialCount = 1000;
+ int initialCount = 1000;
for (int i = 1; i <= initialCount; i++) {
testee.addUid(MessageUid.of(i));
}
- int threadCount = 2;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, initialCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(initialCount)
+ .build((threadNumber, step) -> {
if (threadNumber == 0) {
testee.remove(MessageUid.of(step + 1));
} else {
@@ -392,11 +393,13 @@ public class UidMsnConverterTest {
@Test
public void addShouldLeadToMonoticMSNToUIDConversionWhenConcurrent() throws Exception {
- final int operationCount = 1000;
+ int operationCount = 1000;
int threadCount = 2;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> testee.addUid(MessageUid.of((threadNumber * operationCount) + (step + 1))));
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(operationCount)
+ .build((threadNumber, step) -> testee.addUid(MessageUid.of((threadNumber * operationCount) + (step + 1))));
concurrentTestRunner.run();
concurrentTestRunner.awaitTermination(10, TimeUnit.SECONDS);
@@ -410,14 +413,16 @@ public class UidMsnConverterTest {
@Test
public void removeShouldLeadToMonoticMSNToUIDConversionWhenConcurrent() throws Exception {
- final int operationCount = 1000;
+ int operationCount = 1000;
int threadCount = 2;
for (int i = 1; i <= operationCount * (threadCount + 1); i++) {
testee.addUid(MessageUid.of(i));
}
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> testee.remove(MessageUid.of((threadNumber * operationCount) + (step + 1))));
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(operationCount)
+ .build((threadNumber, step) -> testee.remove(MessageUid.of((threadNumber * operationCount) + (step + 1))));
concurrentTestRunner.run();
concurrentTestRunner.awaitTermination(10, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
index 966347e..e6891eb 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
@@ -99,13 +99,14 @@ public abstract class AbstractSMTPServerTest {
server = createServer(createProtocol(hook));
server.bind();
- final ProtocolServer finalServer = server;
- final InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress();
- final String mailContent = CharStreams.toString(new InputStreamReader(ClassLoader.getSystemResourceAsStream("a50.eml"), StandardCharsets.US_ASCII));
- int threadCount = 4;
- int updateCount = 1;
- assertThat(new ConcurrentTestRunner(threadCount, updateCount,
- (threadNumber, step) -> send(finalServer, bindedAddress, mailContent)).run()
+ ProtocolServer finalServer = server;
+ InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress();
+ String mailContent = CharStreams.toString(new InputStreamReader(ClassLoader.getSystemResourceAsStream("a50.eml"), StandardCharsets.US_ASCII));
+
+ assertThat(ConcurrentTestRunner.builder()
+ .threadCount(4)
+ .build((threadNumber, step) -> send(finalServer, bindedAddress, mailContent))
+ .run()
.awaitTermination(1, TimeUnit.MINUTES))
.isTrue();
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
index 5ad89e4..cb6cb00 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
@@ -240,10 +240,10 @@ public class InMemoryMailRepositoryStoreTest {
public void selectShouldNotReturnDifferentResultsWhenUsedInAConcurrentEnvironment() throws Exception {
MailRepositoryUrl url = MailRepositoryUrl.from("memory://repo");
int threadCount = 10;
- int operationCount = 1;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNb, operationNb) -> repositoryStore.select(url)
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((threadNb, operationNb) -> repositoryStore.select(url)
.store(FakeMail.builder()
.name("name" + threadNb)
.mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java b/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
index 23fd57c..0efb525 100644
--- a/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
+++ b/server/container/util/src/main/java/org/apache/james/util/concurrency/ConcurrentTestRunner.java
@@ -21,6 +21,7 @@ package org.apache.james.util.concurrency;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -35,7 +36,39 @@ import com.google.common.base.Preconditions;
public class ConcurrentTestRunner {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConcurrentTestRunner.class);
+ public static final int DEFAULT_OPERATION_COUNT = 1;
+
+ public static class Builder {
+ private Optional<Integer> threadCount;
+ private Optional<Integer> operationCount;
+
+ public Builder() {
+ threadCount = Optional.empty();
+ operationCount = Optional.empty();
+ }
+
+ public Builder threadCount(int threadCount) {
+ Preconditions.checkArgument(threadCount > 0, "Thread count should be strictly positive");
+ this.threadCount = Optional.of(threadCount);
+ return this;
+ }
+
+ public Builder operationCount(int operationCount) {
+ Preconditions.checkArgument(operationCount > 0, "Operation count should be strictly positive");
+ this.operationCount = Optional.of(operationCount);
+ return this;
+ }
+
+ public ConcurrentTestRunner build(BiConsumer operation) {
+ Preconditions.checkState(threadCount.isPresent(), "'threadCount' is compulsory");
+ Preconditions.checkNotNull(operation);
+
+ return new ConcurrentTestRunner(
+ threadCount.get(),
+ operationCount.orElse(DEFAULT_OPERATION_COUNT),
+ operation);
+ }
+ }
public interface BiConsumer {
void consume(int threadNumber, int step) throws Exception;
@@ -69,6 +102,12 @@ public class ConcurrentTestRunner {
}
}
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConcurrentTestRunner.class);
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
private final int threadCount;
private final int operationCount;
private final CountDownLatch countDownLatch;
@@ -76,10 +115,7 @@ public class ConcurrentTestRunner {
private final ExecutorService executorService;
private final List<Future<?>> futures;
- public ConcurrentTestRunner(int threadCount, int operationCount, BiConsumer biConsumer) {
- Preconditions.checkArgument(threadCount > 0, "Thread count should be strictly positive");
- Preconditions.checkArgument(operationCount > 0, "Operation count should be strictly positive");
- Preconditions.checkNotNull(biConsumer);
+ private ConcurrentTestRunner(int threadCount, int operationCount, BiConsumer biConsumer) {
this.threadCount = threadCount;
this.operationCount = operationCount;
this.countDownLatch = new CountDownLatch(threadCount);
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java b/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
index 4a03fe1..5eac926 100644
--- a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
@@ -20,74 +20,64 @@
package org.apache.james.util.concurrency;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
public class ConcurrentTestRunnerTest {
-
public static final ConcurrentTestRunner.BiConsumer EMPTY_BI_CONSUMER = (threadNumber, step) -> { };
public static final int DEFAULT_AWAIT_TIME = 100;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void constructorShouldThrowOnNegativeThreadCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = 1;
- int threadCount = -1;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .threadCount(-1))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnNegativeOperationCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = -1;
- int threadCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .operationCount(-1))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnZeroThreadCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = 1;
- int threadCount = 0;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .threadCount(0))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnZeroOperationCount() {
- expectedException.expect(IllegalArgumentException.class);
-
- int operationCount = 0;
- int threadCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .operationCount(0))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void constructorShouldThrowOnNullBiConsumer() {
- expectedException.expect(NullPointerException.class);
-
- int operationCount = 1;
- int threadCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount, null);
+ assertThatThrownBy(() ->
+ ConcurrentTestRunner.builder()
+ .threadCount(1)
+ .build(null))
+ .isInstanceOf(NullPointerException.class);
}
@Test
public void awaitTerminationShouldReturnTrueWhenFinished() throws Exception {
- int operationCount = 1;
- int threadCount = 1;
-
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER)
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(1)
+ .build(EMPTY_BI_CONSUMER)
.run();
assertThat(concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS)).isTrue();
@@ -95,12 +85,11 @@ public class ConcurrentTestRunnerTest {
@Test
public void awaitTerminationShouldReturnFalseWhenNotFinished() throws Exception {
- int operationCount = 1;
- int threadCount = 1;
- final int sleepDelay = 50;
+ int sleepDelay = 50;
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> Thread.sleep(sleepDelay))
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(1)
+ .build((threadNumber, step) -> Thread.sleep(sleepDelay))
.run();
assertThat(concurrentTestRunner.awaitTermination(sleepDelay / 2, TimeUnit.MILLISECONDS)).isFalse();
@@ -108,12 +97,12 @@ public class ConcurrentTestRunnerTest {
@Test
public void runShouldPerformAllOperations() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
- final ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> queue.add(threadNumber + ":" + step))
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> queue.add(threadNumber + ":" + step))
.run();
assertThat(concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS)).isTrue();
@@ -121,12 +110,24 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void runShouldNotThrowOnExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
+ public void operationCountShouldDefaultToOne() throws Exception {
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .build((threadNumber, step) -> queue.add(threadNumber + ":" + step))
+ .run();
+
+ assertThat(concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS)).isTrue();
+ assertThat(queue).containsOnly("0:0", "1:0");
+ }
+
+ @Test
+ public void runShouldNotThrowOnExceptions() throws Exception {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
throw new RuntimeException();
})
.run();
@@ -136,10 +137,10 @@ public class ConcurrentTestRunnerTest {
@Test
public void noExceptionsShouldNotThrowWhenNoExceptionGenerated() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
-
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount, EMPTY_BI_CONSUMER)
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build(EMPTY_BI_CONSUMER)
.run();
concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS);
@@ -149,28 +150,27 @@ public class ConcurrentTestRunnerTest {
@Test
public void assertNoExceptionShouldThrowOnExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
-
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
throw new RuntimeException();
})
.run();
concurrentTestRunner.awaitTermination(DEFAULT_AWAIT_TIME, TimeUnit.MILLISECONDS);
- expectedException.expect(ExecutionException.class);
- concurrentTestRunner.assertNoException();
+ assertThatThrownBy(concurrentTestRunner::assertNoException)
+ .isInstanceOf(ExecutionException.class);
}
@Test
public void runShouldPerformAllOperationsEvenOnExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
- final ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
queue.add(threadNumber + ":" + step);
throw new RuntimeException();
})
@@ -182,12 +182,12 @@ public class ConcurrentTestRunnerTest {
@Test
public void runShouldPerformAllOperationsEvenOnOccasionalExceptions() throws Exception {
- int operationCount = 2;
- int threadCount = 2;
- final ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
- ConcurrentTestRunner concurrentTestRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> {
+ ConcurrentTestRunner concurrentTestRunner = ConcurrentTestRunner.builder()
+ .threadCount(2)
+ .operationCount(2)
+ .build((threadNumber, step) -> {
queue.add(threadNumber + ":" + step);
if ((threadNumber + step) % 2 == 0) {
throw new RuntimeException();
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java b/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
index 8260deb..9bbe365 100644
--- a/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
+++ b/server/data/data-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryUrlStoreContract.java
@@ -74,8 +74,10 @@ public interface MailRepositoryUrlStoreContract {
default void addShouldWorkInConcurrentEnvironment(MailRepositoryUrlStore store) throws Exception {
int operationCount = 10;
int threadCount = 10;
- ConcurrentTestRunner testRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (a, b) -> store.add(MailRepositoryUrl.from("proto://" + a + "/" + b)))
+ ConcurrentTestRunner testRunner = ConcurrentTestRunner.builder()
+ .threadCount(threadCount)
+ .operationCount(operationCount)
+ .build((a, b) -> store.add(MailRepositoryUrl.from("proto://" + a + "/" + b)))
.run();
testRunner.awaitTermination(1, TimeUnit.MINUTES);
testRunner.assertNoException();
@@ -86,9 +88,10 @@ public interface MailRepositoryUrlStoreContract {
@Test
default void addShouldNotAddDuplicatesInConcurrentEnvironment(MailRepositoryUrlStore store) throws Exception {
int operationCount = 10;
- int threadCount = 10;
- ConcurrentTestRunner testRunner = new ConcurrentTestRunner(threadCount, operationCount,
- (a, b) -> store.add(MailRepositoryUrl.from("proto://" + b)))
+ ConcurrentTestRunner testRunner = ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .operationCount(operationCount)
+ .build((a, b) -> store.add(MailRepositoryUrl.from("proto://" + b)))
.run();
testRunner.awaitTermination(1, TimeUnit.MINUTES);
testRunner.assertNoException();
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
index d56dee9..3ed562b 100644
--- a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
+++ b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
@@ -381,8 +381,6 @@ public interface MailRepositoryContract {
default void storingAndRemovingMessagesConcurrentlyShouldLeadToConsistentResult() throws Exception {
MailRepository testee = retrieveRepository();
int nbKeys = 20;
- int nbIterations = 10;
- int threadCount = 10;
ConcurrentHashMap.KeySetView<MailKey, Boolean> expectedResult = ConcurrentHashMap.newKeySet();
List<Object> locks = IntStream.range(0, 10)
.boxed()
@@ -412,8 +410,10 @@ public interface MailRepositoryContract {
new DistributionEntry<>(add, 0.25),
new DistributionEntry<>(remove, 0.75)));
- new ConcurrentTestRunner(threadCount, nbIterations,
- (a, b) -> distribution.sample().run())
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .operationCount(10)
+ .build((a, b) -> distribution.sample().run())
.run()
.awaitTermination(1, TimeUnit.MINUTES);
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
index e5d49a5..7194ad4 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
@@ -78,8 +78,9 @@ public abstract class ProvisioningTest {
public void provisionMailboxesShouldNotDuplicateMailboxByName() throws Exception {
String token = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD).serialize();
- boolean termination = new ConcurrentTestRunner(10, 1,
- (a, b) -> with()
+ boolean termination = ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((a, b) -> with()
.header("Authorization", token)
.body("[[\"getMailboxes\", {}, \"#0\"]]")
.post("/jmap"))
http://git-wip-us.apache.org/repos/asf/james-project/blob/68e03ede/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
index 08522f1..ea0dd1f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterTest.java
@@ -89,10 +89,9 @@ public class DefaultMailboxesProvisioningFilterTest {
@Test
public void createMailboxesIfNeededShouldNotGenerateExceptionsInConcurrentEnvironment() throws Exception {
- int threadCount = 10;
- int operationCount = 1;
- new ConcurrentTestRunner(threadCount, operationCount,
- (threadNumber, step) -> testee.createMailboxesIfNeeded(session))
+ ConcurrentTestRunner.builder()
+ .threadCount(10)
+ .build((threadNumber, step) -> testee.createMailboxesIfNeeded(session))
.run()
.assertNoException()
.awaitTermination(10, TimeUnit.SECONDS);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[05/11] james-project git commit: JAMES-2465 Solve concurrency issue
when provisioning mailbox
Posted by ro...@apache.org.
JAMES-2465 Solve concurrency issue when provisioning mailbox
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2cc467f1
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2cc467f1
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2cc467f1
Branch: refs/heads/master
Commit: 2cc467f11ae9320dce79137fae0b934933360d28
Parents: f23a184
Author: benwa <bt...@linagora.com>
Authored: Thu Jul 12 10:58:29 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Thu Jul 12 11:00:00 2018 +0700
----------------------------------------------------------------------
.../transport/mailets/delivery/MailboxAppender.java | 10 +++++++++-
.../transport/mailets/delivery/MailboxAppenderTest.java | 11 +++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2cc467f1/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
index cd040e3..95e1246 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
@@ -27,13 +27,17 @@ import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.exception.BadCredentialsException;
import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxExistsException;
import org.apache.james.mailbox.model.ComposedMessageId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.server.core.MimeMessageInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
public class MailboxAppender {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MailboxAppender.class);
private final MailboxManager mailboxManager;
@@ -83,7 +87,11 @@ public class MailboxAppender {
private void createMailboxIfNotExist(MailboxSession session, MailboxPath path) throws MailboxException {
if (!mailboxManager.mailboxExists(path, session)) {
- mailboxManager.createMailbox(path, session);
+ try {
+ mailboxManager.createMailbox(path, session);
+ } catch (MailboxExistsException e) {
+ LOGGER.info("Mailbox {} have been created concurrently", path);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/2cc467f1/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
index 22e2e9f..914aba9 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
@@ -35,8 +35,10 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
import org.apache.james.mailbox.model.MessageResult;
import org.apache.james.mailbox.model.MessageResultIterator;
+import org.apache.james.util.concurrency.ConcurrentTestRunner;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
public class MailboxAppenderTest {
@@ -120,4 +122,13 @@ public class MailboxAppenderTest {
assertThat(messages).hasSize(1);
}
+
+ @RepeatedTest(20)
+ void appendShouldNotFailInConcurrentEnvironment() throws Exception {
+ ConcurrentTestRunner.builder()
+ .threadCount(100)
+ .build((a, b) -> testee.append(mimeMessage, USER, FOLDER + "/any"))
+ .run()
+ .assertNoException();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[07/11] james-project git commit: JAMES-2467 Recommend and use the
last Cassandra version
Posted by ro...@apache.org.
JAMES-2467 Recommend and use the last Cassandra version
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/771db643
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/771db643
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/771db643
Branch: refs/heads/master
Commit: 771db6432aeb0ef1a64dce85805a7a093901f308
Parents: bbb7041
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Wed Jul 11 17:06:37 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Jul 12 17:34:01 2018 +0200
----------------------------------------------------------------------
README.adoc | 2 +-
.../apache/james/backends/cassandra/DockerCassandraRule.java | 4 ++--
dockerfiles/run/docker-compose.yml | 2 +-
src/site/markdown/server/install/guice-cassandra.md | 6 +++---
src/site/xdoc/server/quick-start-cassandra.xml | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/771db643/README.adoc
----------------------------------------------------------------------
diff --git a/README.adoc b/README.adoc
index fd03b41..71d5b34 100644
--- a/README.adoc
+++ b/README.adoc
@@ -215,7 +215,7 @@ If you haven't already:
==== How to ?
You need a running *cassandra* in docker. To achieve this run:
- $ docker run -d --name=cassandra cassandra:2.2.3
+ $ docker run -d --name=cassandra cassandra:2.2.12
You need a running *ElasticSearch* in docker. To achieve this run:
http://git-wip-us.apache.org/repos/asf/james-project/blob/771db643/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
index 38ca0eb..b31024b 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
@@ -70,10 +70,10 @@ public class DockerCassandraRule implements TestRule {
deleteTmpsFsCmd = client.removeVolumeCmd(tmpFsName);
boolean deleteOnExit = false;
cassandraContainer = new GenericContainer<>(
- new ImageFromDockerfile("cassandra_2_2_10", deleteOnExit)
+ new ImageFromDockerfile("cassandra_2_2_12", deleteOnExit)
.withDockerfileFromBuilder(builder ->
builder
- .from("cassandra:2.2.10")
+ .from("cassandra:2.2.12")
.env("ENV CASSANDRA_CONFIG", "/etc/cassandra")
//avoiding token range computation helps starting faster
.run("echo \"JVM_OPTS=\\\"\\$JVM_OPTS -Dcassandra.initial_token=0\\\"\" >> " + CASSANDRA_ENV)
http://git-wip-us.apache.org/repos/asf/james-project/blob/771db643/dockerfiles/run/docker-compose.yml
----------------------------------------------------------------------
diff --git a/dockerfiles/run/docker-compose.yml b/dockerfiles/run/docker-compose.yml
index 154a14f..54170dd 100644
--- a/dockerfiles/run/docker-compose.yml
+++ b/dockerfiles/run/docker-compose.yml
@@ -24,7 +24,7 @@ services:
image: elasticsearch:2.2.1
cassandra:
- image: cassandra:2.2.3
+ image: cassandra:2.2.12
ports:
- "9042:9042"
http://git-wip-us.apache.org/repos/asf/james-project/blob/771db643/src/site/markdown/server/install/guice-cassandra.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/server/install/guice-cassandra.md b/src/site/markdown/server/install/guice-cassandra.md
index 3729d1f..b451559 100644
--- a/src/site/markdown/server/install/guice-cassandra.md
+++ b/src/site/markdown/server/install/guice-cassandra.md
@@ -5,7 +5,7 @@
### Requirements
- Java 8 SDK
- - Docker ∕ ElasticSearch 2.2.1 and Cassandra 2.2.3
+ - Docker ∕ ElasticSearch 2.2.1 and Cassandra 2.2.12
- Maven 3
### Building the artifacts
@@ -45,7 +45,7 @@ $ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
You need to have a Cassandra and an ElasticSearch instance running. You can either install the servers or launch them via docker:
```bash
-$ docker run -d --port 9042:9042 --name=cassandra cassandra:2.2.3
+$ docker run -d --port 9042:9042 --name=cassandra cassandra:2.2.12
$ docker run -d --port 9200:9200 --port 9300:9300 --name=elasticsearch elasticsearch:2.2.1
```
@@ -65,4 +65,4 @@ You can follow the same guide to build and run guice-cassandra-ldap artifact, ex
```bash
$ java -Dworking.directory=. -jar target/james-server-cassandra-ldap-guice.jar
-```
\ No newline at end of file
+```
http://git-wip-us.apache.org/repos/asf/james-project/blob/771db643/src/site/xdoc/server/quick-start-cassandra.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/quick-start-cassandra.xml b/src/site/xdoc/server/quick-start-cassandra.xml
index c0ad8c1..96390ed 100644
--- a/src/site/xdoc/server/quick-start-cassandra.xml
+++ b/src/site/xdoc/server/quick-start-cassandra.xml
@@ -64,7 +64,7 @@ Step 3: Deploy
3.1. Deploy Cassandra (optional)
You may skip this part if you already have a running Cassandra on your network.
-<i>$ docker run --detach=true --name=cassandra cassandra:2.2.3</i>
+<i>$ docker run --detach=true --name=cassandra cassandra:2.2.12</i>
3.2. Deploy ElasticSearch (optional)
You may skip this part if you already have a running ElasticSearch on your network.
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org