MAILBOX-306 Use assertThatThrownBy in CassandraConfigurationTest
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dacb968e Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dacb968e Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dacb968e Branch: refs/heads/master Commit: dacb968e1d20026bb52de0422dad25802dde7f08 Parents: 8c82a85 Author: Raphael Ouazana <raphael.ouaz...@linagora.com> Authored: Mon Sep 18 15:55:39 2017 +0200 Committer: benwa <btell...@linagora.com> Committed: Tue Sep 19 08:59:35 2017 +0700 ---------------------------------------------------------------------- .../init/CassandraConfigurationTest.java | 160 ++++++++----------- 1 file changed, 67 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/dacb968e/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java index 34b6a01..c59fc6c 100644 --- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java +++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java @@ -20,19 +20,15 @@ package org.apache.james.backends.cassandra.init; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.assertj.core.api.JUnitSoftAssertions; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import nl.jqno.equalsverifier.EqualsVerifier; public class CassandraConfigurationTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public final JUnitSoftAssertions softly = new JUnitSoftAssertions(); @@ -51,178 +47,156 @@ public class CassandraConfigurationTest { @Test public void aclMaxRetryShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .aclMaxRetry(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .aclMaxRetry(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void aclMaxRetryShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .aclMaxRetry(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .aclMaxRetry(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void expungeChunkSizeShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .expungeChunkSize(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .expungeChunkSize(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void expungeChunkSizeShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .expungeChunkSize(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .expungeChunkSize(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void messageReadChunkSizeShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .messageReadChunkSize(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .messageReadChunkSize(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void messageReadChunkSizeShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .messageReadChunkSize(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .messageReadChunkSize(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void flagsUpdateChunkSizeShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .flagsUpdateChunkSize(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .flagsUpdateChunkSize(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void flagsUpdateChunkSizeShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .flagsUpdateChunkSize(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .flagsUpdateChunkSize(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void flagsUpdateMessageIdMaxRetryShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .flagsUpdateMessageIdMaxRetry(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .flagsUpdateMessageIdMaxRetry(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void flagsUpdateMessageIdMaxRetryShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .flagsUpdateMessageIdMaxRetry(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .flagsUpdateMessageIdMaxRetry(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void flagsUpdateMessageMaxRetryShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .flagsUpdateMessageMaxRetry(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .flagsUpdateMessageMaxRetry(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void flagsUpdateMessageMaxRetryShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .flagsUpdateMessageMaxRetry(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .flagsUpdateMessageMaxRetry(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void fetchNextPageInAdvanceRowShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .fetchNextPageInAdvanceRow(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .fetchNextPageInAdvanceRow(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void fetchNextPageInAdvanceRowShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .fetchNextPageInAdvanceRow(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .fetchNextPageInAdvanceRow(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void modSeqMaxRetryShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .modSeqMaxRetry(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .modSeqMaxRetry(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void modSeqMaxRetryShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .modSeqMaxRetry(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .modSeqMaxRetry(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void uidMaxRetryShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .uidMaxRetry(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .uidMaxRetry(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void uidMaxRetryShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .uidMaxRetry(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .uidMaxRetry(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void attachmentV2MigrationReadTimeoutShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .attachmentV2MigrationReadTimeout(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .attachmentV2MigrationReadTimeout(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void attachmentV2MigrationReadTimeoutShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .attachmentV2MigrationReadTimeout(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .attachmentV2MigrationReadTimeout(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void messageAttachmentIdsReadTimeoutShouldThrowOnZero() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .messageAttachmentIdsReadTimeout(0); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .messageAttachmentIdsReadTimeout(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test public void messageAttachmentIdsReadTimeoutShouldThrowOnNegativeValue() { - expectedException.expect(IllegalArgumentException.class); - - CassandraConfiguration.builder() - .messageAttachmentIdsReadTimeout(-1); + assertThatThrownBy(() -> CassandraConfiguration.builder() + .messageAttachmentIdsReadTimeout(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org