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 bt...@apache.org on 2019/11/11 08:05:08 UTC
[james-project] 08/09: [Refactoring] Migrate tests in JUnit 4 to
JUnit 5 in backends-cassandra module
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit bc6e5a8c59f5897bca4c7bf480a24818b0b79735
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Nov 8 16:19:11 2019 +0700
[Refactoring] Migrate tests in JUnit 4 to JUnit 5 in backends-cassandra module
---
.../init/CassandraConfigurationReadingTest.java | 8 +--
.../cassandra/init/CassandraConfigurationTest.java | 58 +++++++++---------
.../init/QueryLoggerConfigurationTest.java | 10 ++--
.../migration/CassandraMigrationServiceTest.java | 69 ++++++++++------------
.../cassandra/utils/CassandraHealthCheckTest.java | 2 +-
.../utils/ZonedDateTimeRepresentationTest.java | 14 ++---
.../CassandraSchemaVersionManagerTest.java | 46 +++++++--------
7 files changed, 97 insertions(+), 110 deletions(-)
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationReadingTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationReadingTest.java
index 7ae57c4..da60e9b 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationReadingTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationReadingTest.java
@@ -27,19 +27,19 @@ import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class CassandraConfigurationReadingTest {
+class CassandraConfigurationReadingTest {
@Test
- public void provideCassandraConfigurationShouldReturnDefaultOnEmptyConfigurationFile() {
+ void provideCassandraConfigurationShouldReturnDefaultOnEmptyConfigurationFile() {
CassandraConfiguration configuration = CassandraConfiguration.from(new PropertiesConfiguration());
assertThat(configuration).isEqualTo(CassandraConfiguration.DEFAULT_CONFIGURATION);
}
@Test
- public void provideCassandraConfigurationShouldReturnRightConfigurationFile() throws ConfigurationException {
+ void provideCassandraConfigurationShouldReturnRightConfigurationFile() throws ConfigurationException {
FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(new Parameters()
.fileBased()
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 5edb3fb..a97e852 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
@@ -23,170 +23,170 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
+import org.assertj.core.api.JUnitJupiterSoftAssertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import nl.jqno.equalsverifier.EqualsVerifier;
-public class CassandraConfigurationTest {
- @Rule
- public final JUnitSoftAssertions softly = new JUnitSoftAssertions();
+class CassandraConfigurationTest {
+ @RegisterExtension
+ JUnitJupiterSoftAssertions softly = new JUnitJupiterSoftAssertions();
@Test
- public void cassandraConfigurationShouldRespectBeanContract() {
+ void cassandraConfigurationShouldRespectBeanContract() {
EqualsVerifier.forClass(CassandraConfiguration.class)
.verify();
}
@Test
- public void defaultBuilderShouldConstructDefaultConfiguration() {
+ void defaultBuilderShouldConstructDefaultConfiguration() {
assertThat(CassandraConfiguration.builder().build())
.isEqualTo(CassandraConfiguration.DEFAULT_CONFIGURATION);
}
@Test
- public void aclMaxRetryShouldThrowOnNegativeValue() {
+ void aclMaxRetryShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.aclMaxRetry(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void aclMaxRetryShouldThrowOnZero() {
+ void aclMaxRetryShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.aclMaxRetry(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void expungeChunkSizeShouldThrowOnNegativeValue() {
+ void expungeChunkSizeShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.expungeChunkSize(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void expungeChunkSizeShouldThrowOnZero() {
+ void expungeChunkSizeShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.expungeChunkSize(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void messageReadChunkSizeShouldThrowOnNegativeValue() {
+ void messageReadChunkSizeShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.messageReadChunkSize(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void messageReadChunkSizeShouldThrowOnZero() {
+ void messageReadChunkSizeShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.messageReadChunkSize(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void flagsUpdateMessageIdMaxRetryShouldThrowOnNegativeValue() {
+ void flagsUpdateMessageIdMaxRetryShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.flagsUpdateMessageIdMaxRetry(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void flagsUpdateMessageIdMaxRetryShouldThrowOnZero() {
+ void flagsUpdateMessageIdMaxRetryShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.flagsUpdateMessageIdMaxRetry(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void flagsUpdateMessageMaxRetryShouldThrowOnNegativeValue() {
+ void flagsUpdateMessageMaxRetryShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.flagsUpdateMessageMaxRetry(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void flagsUpdateMessageMaxRetryShouldThrowOnZero() {
+ void flagsUpdateMessageMaxRetryShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.flagsUpdateMessageMaxRetry(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void fetchNextPageInAdvanceRowShouldThrowOnNegativeValue() {
+ void fetchNextPageInAdvanceRowShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.fetchNextPageInAdvanceRow(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void fetchNextPageInAdvanceRowShouldThrowOnZero() {
+ void fetchNextPageInAdvanceRowShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.fetchNextPageInAdvanceRow(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void modSeqMaxRetryShouldThrowOnNegativeValue() {
+ void modSeqMaxRetryShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.modSeqMaxRetry(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void modSeqMaxRetryShouldThrowOnZero() {
+ void modSeqMaxRetryShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.modSeqMaxRetry(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void uidMaxRetryShouldThrowOnNegativeValue() {
+ void uidMaxRetryShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.uidMaxRetry(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void uidMaxRetryShouldThrowOnZero() {
+ void uidMaxRetryShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.uidMaxRetry(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void attachmentV2MigrationReadTimeoutShouldThrowOnZero() {
+ void attachmentV2MigrationReadTimeoutShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.attachmentV2MigrationReadTimeout(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void attachmentV2MigrationReadTimeoutShouldThrowOnNegativeValue() {
+ void attachmentV2MigrationReadTimeoutShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.attachmentV2MigrationReadTimeout(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void messageAttachmentIdsReadTimeoutShouldThrowOnZero() {
+ void messageAttachmentIdsReadTimeoutShouldThrowOnZero() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.messageAttachmentIdsReadTimeout(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void messageAttachmentIdsReadTimeoutShouldThrowOnNegativeValue() {
+ void messageAttachmentIdsReadTimeoutShouldThrowOnNegativeValue() {
assertThatThrownBy(() -> CassandraConfiguration.builder()
.messageAttachmentIdsReadTimeout(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void builderShouldCreateTheRightObject() {
+ void builderShouldCreateTheRightObject() {
int aclMaxRetry = 1;
int modSeqMaxRetry = 2;
int uidMaxRetry = 3;
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/QueryLoggerConfigurationTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/QueryLoggerConfigurationTest.java
index d3381fb..6f152f1 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/QueryLoggerConfigurationTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/QueryLoggerConfigurationTest.java
@@ -23,12 +23,12 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.james.backends.cassandra.init.configuration.QueryLoggerConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class QueryLoggerConfigurationTest {
+class QueryLoggerConfigurationTest {
@Test
- public void fromShouldNotThrowWithMinimalConfigAboutAConstantThresholdSlowQueryLogger() {
+ void fromShouldNotThrowWithMinimalConfigAboutAConstantThresholdSlowQueryLogger() {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.addProperty("cassandra.query.logger.constant.threshold", 100);
@@ -37,7 +37,7 @@ public class QueryLoggerConfigurationTest {
}
@Test
- public void fromShouldNotThrowWithPersonalizedConfigAboutPercentileSlowQuerryLogger() {
+ void fromShouldNotThrowWithPersonalizedConfigAboutPercentileSlowQuerryLogger() {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.addProperty("cassandra.query.slow.query.latency.threshold.percentile", 90);
@@ -50,7 +50,7 @@ public class QueryLoggerConfigurationTest {
}
@Test
- public void fromShouldThrowIfConfigAboutLoggerIsInvalid() {
+ void fromShouldThrowIfConfigAboutLoggerIsInvalid() {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.addProperty("cassandra.query.slow.query.latency.threshold.percentile", 90);
configuration.addProperty("cassandra.query.logger.constant.threshold", 100);
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/CassandraMigrationServiceTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/CassandraMigrationServiceTest.java
index 11d6b1a..4d59da7 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/CassandraMigrationServiceTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/CassandraMigrationServiceTest.java
@@ -20,6 +20,7 @@
package org.apache.james.backends.cassandra.migration;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -39,18 +40,16 @@ import org.apache.james.backends.cassandra.versions.SchemaTransition;
import org.apache.james.backends.cassandra.versions.SchemaVersion;
import org.apache.james.task.Task;
import org.apache.james.util.concurrent.NamedThreadFactory;
-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;
import com.datastax.driver.core.Session;
import com.google.common.collect.ImmutableMap;
import reactor.core.publisher.Mono;
-public class CassandraMigrationServiceTest {
+class CassandraMigrationServiceTest {
private static final SchemaVersion LATEST_VERSION = new SchemaVersion(3);
private static final SchemaVersion INTERMEDIARY_VERSION = new SchemaVersion(2);
private static final SchemaVersion CURRENT_VERSION = INTERMEDIARY_VERSION;
@@ -61,12 +60,10 @@ public class CassandraMigrationServiceTest {
private CassandraSchemaVersionDAO schemaVersionDAO;
private ExecutorService executorService;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
private Migration successfulMigration;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
schemaVersionDAO = mock(CassandraSchemaVersionDAO.class);
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.empty()));
when(schemaVersionDAO.updateVersion(any())).thenReturn(Mono.empty());
@@ -83,25 +80,25 @@ public class CassandraMigrationServiceTest {
NamedThreadFactory.withClassName(getClass()));
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
executorService.shutdownNow();
}
@Test
- public void getCurrentVersionShouldReturnCurrentVersion() {
+ void getCurrentVersionShouldReturnCurrentVersion() {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(CURRENT_VERSION)));
assertThat(testee.getCurrentVersion()).contains(CURRENT_VERSION);
}
@Test
- public void getLatestVersionShouldReturnTheLatestVersion() {
+ void getLatestVersionShouldReturnTheLatestVersion() {
assertThat(testee.getLatestVersion()).contains(LATEST_VERSION);
}
@Test
- public void upgradeToVersionShouldNotThrowWhenCurrentVersionIsUpToDate() throws InterruptedException {
+ void upgradeToVersionShouldNotThrowWhenCurrentVersionIsUpToDate() throws InterruptedException {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(CURRENT_VERSION)));
assertThat(testee.upgradeToVersion(OLDER_VERSION).run())
@@ -109,7 +106,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToVersionShouldUpdateToVersion() throws InterruptedException {
+ void upgradeToVersionShouldUpdateToVersion() throws InterruptedException {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION)));
testee.upgradeToVersion(CURRENT_VERSION).run();
@@ -118,7 +115,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToLastVersionShouldNotThrowWhenVersionIsUpToDate() throws InterruptedException {
+ void upgradeToLastVersionShouldNotThrowWhenVersionIsUpToDate() throws InterruptedException {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(LATEST_VERSION)));
@@ -127,7 +124,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToLastVersionShouldUpdateToLatestVersion() throws InterruptedException {
+ void upgradeToLastVersionShouldUpdateToLatestVersion() throws InterruptedException {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION)));
testee.upgradeToLastVersion().run();
@@ -137,19 +134,18 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToVersionShouldThrowOnMissingVersion() throws InterruptedException {
+ void upgradeToVersionShouldThrowOnMissingVersion() throws InterruptedException {
CassandraSchemaTransitions transitions = new CassandraSchemaTransitions(ImmutableMap.of(FROM_OLDER_TO_CURRENT, successfulMigration));
testee = new CassandraMigrationService(schemaVersionDAO, transitions, version -> new MigrationTask(schemaVersionDAO, transitions, version), LATEST_VERSION);
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION)));
- expectedException.expect(NotImplementedException.class);
-
- testee.upgradeToVersion(LATEST_VERSION).run();
+ assertThatThrownBy(() -> testee.upgradeToVersion(LATEST_VERSION).run())
+ .isInstanceOf(NotImplementedException.class);
}
@Test
- public void upgradeToVersionShouldUpdateIntermediarySuccessfulMigrationsInCaseOfError() throws InterruptedException {
+ void upgradeToVersionShouldUpdateIntermediarySuccessfulMigrationsInCaseOfError() throws InterruptedException {
try {
CassandraSchemaTransitions transitions = new CassandraSchemaTransitions(ImmutableMap.of(
FROM_OLDER_TO_CURRENT, successfulMigration,
@@ -160,16 +156,15 @@ public class CassandraMigrationServiceTest {
testee = new CassandraMigrationService(schemaVersionDAO, transitions, version -> new MigrationTask(schemaVersionDAO, transitions, version), LATEST_VERSION);
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION)));
- expectedException.expect(RuntimeException.class);
-
- testee.upgradeToVersion(LATEST_VERSION).run();
+ assertThatThrownBy(() -> testee.upgradeToVersion(LATEST_VERSION).run())
+ .isInstanceOf(RuntimeException.class);
} finally {
verify(schemaVersionDAO).updateVersion(CURRENT_VERSION);
}
}
@Test
- public void partialMigrationShouldThrow() throws InterruptedException {
+ void partialMigrationShouldThrow() throws InterruptedException {
InMemorySchemaDAO schemaVersionDAO = new InMemorySchemaDAO(OLDER_VERSION);
Task failingTask = mock(Task.class);
when(failingTask.run()).thenThrow(MigrationException.class);
@@ -182,13 +177,12 @@ public class CassandraMigrationServiceTest {
testee = new CassandraMigrationService(schemaVersionDAO, transitions, version -> new MigrationTask(schemaVersionDAO, transitions, version), LATEST_VERSION);
- expectedException.expect(MigrationException.class);
-
- testee.upgradeToVersion(LATEST_VERSION).run();
+ assertThatThrownBy(() -> testee.upgradeToVersion(LATEST_VERSION).run())
+ .isInstanceOf(MigrationException.class);
}
@Test
- public void partialMigrationShouldAbortMigrations() throws InterruptedException {
+ void partialMigrationShouldAbortMigrations() throws InterruptedException {
InMemorySchemaDAO schemaVersionDAO = new InMemorySchemaDAO(OLDER_VERSION);
Task failingTask = mock(Task.class);
when(failingTask.run()).thenThrow(MigrationException.class);
@@ -201,15 +195,12 @@ public class CassandraMigrationServiceTest {
testee = new CassandraMigrationService(schemaVersionDAO, transitions, version -> new MigrationTask(schemaVersionDAO, transitions, version), LATEST_VERSION);
- expectedException.expect(MigrationException.class);
+ assertThatThrownBy(() -> testee.upgradeToVersion(LATEST_VERSION).run())
+ .isInstanceOf(MigrationException.class);
- try {
- testee.upgradeToVersion(LATEST_VERSION).run();
- } finally {
- verify(failingTask, times(1)).run();
- verifyNoMoreInteractions(failingTask);
- verifyZeroInteractions(migration2);
- }
+ verify(failingTask, times(1)).run();
+ verifyNoMoreInteractions(failingTask);
+ verifyZeroInteractions(migration2);
}
public static class InMemorySchemaDAO extends CassandraSchemaVersionDAO {
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheckTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheckTest.java
index 3a77ce7..c37f641 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheckTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheckTest.java
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(DockerCassandraExtension.class)
-public class CassandraHealthCheckTest {
+class CassandraHealthCheckTest {
private CassandraHealthCheck healthCheck;
private CassandraCluster cassandra;
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/ZonedDateTimeRepresentationTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/ZonedDateTimeRepresentationTest.java
index be4b973..178231d 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/ZonedDateTimeRepresentationTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/ZonedDateTimeRepresentationTest.java
@@ -23,16 +23,16 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.time.ZonedDateTime;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ZonedDateTimeRepresentationTest {
+class ZonedDateTimeRepresentationTest {
private static final ZonedDateTime ZONED_DATE_TIME_VN = ZonedDateTime.parse("2016-04-13T12:04:40.906+07:00[Asia/Vientiane]");
private static final ZonedDateTime ZONED_DATE_TIME_FR = ZonedDateTime.parse("2016-04-13T07:04:40.906+02:00");
private static final long INSTANT = 1460523880906L;
@Test
- public void zonedDateTimeRepresentationShouldBeReversible() {
+ void zonedDateTimeRepresentationShouldBeReversible() {
ZonedDateTimeRepresentation originalValue = ZonedDateTimeRepresentation.fromZonedDateTime(ZONED_DATE_TIME_VN);
ZonedDateTimeRepresentation generatedValue = ZonedDateTimeRepresentation.fromDate(originalValue.getDate(), originalValue.getSerializedZoneId());
@@ -41,25 +41,25 @@ public class ZonedDateTimeRepresentationTest {
}
@Test
- public void getSerializedZoneIdShouldReturnTheRightZone() {
+ void getSerializedZoneIdShouldReturnTheRightZone() {
assertThat(ZonedDateTimeRepresentation.fromZonedDateTime(ZONED_DATE_TIME_VN).getSerializedZoneId())
.isEqualTo("Asia/Vientiane");
}
@Test
- public void getDateShouldReturnTheRightDate() {
+ void getDateShouldReturnTheRightDate() {
assertThat(ZonedDateTimeRepresentation.fromZonedDateTime(ZONED_DATE_TIME_VN).getDate().getTime())
.isEqualTo(INSTANT);
}
@Test
- public void getSerializedZoneIdShouldWorkWithFrTimeZone() {
+ void getSerializedZoneIdShouldWorkWithFrTimeZone() {
assertThat(ZonedDateTimeRepresentation.fromZonedDateTime(ZONED_DATE_TIME_FR).getSerializedZoneId())
.isEqualTo("+02:00");
}
@Test
- public void getDateShouldWorkWithFrTimeZone() {
+ void getDateShouldWorkWithFrTimeZone() {
assertThat(ZonedDateTimeRepresentation.fromZonedDateTime(ZONED_DATE_TIME_FR).getDate().getTime())
.isEqualTo(INSTANT);
}
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManagerTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManagerTest.java
index cb395dd..852fcce 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManagerTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManagerTest.java
@@ -24,35 +24,31 @@ import static org.apache.james.backends.cassandra.versions.CassandraSchemaVersio
import static org.apache.james.backends.cassandra.versions.CassandraSchemaVersionManager.SchemaState.UPGRADABLE;
import static org.apache.james.backends.cassandra.versions.CassandraSchemaVersionManager.SchemaState.UP_TO_DATE;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Optional;
import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionManager.SchemaState;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
-public class CassandraSchemaVersionManagerTest {
+class CassandraSchemaVersionManagerTest {
private final SchemaVersion minVersion = new SchemaVersion(2);
private final SchemaVersion maxVersion = new SchemaVersion(4);
private CassandraSchemaVersionDAO schemaVersionDAO;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
schemaVersionDAO = mock(CassandraSchemaVersionDAO.class);
}
@Test
- public void computeSchemaStateShouldReturnTooOldWhenVersionIsLessThanMinVersion() {
+ void computeSchemaStateShouldReturnTooOldWhenVersionIsLessThanMinVersion() {
SchemaVersion currentVersion = minVersion.previous();
when(schemaVersionDAO.getCurrentSchemaVersion())
@@ -67,7 +63,7 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void computeSchemaStateShouldReturnTooOldWhenVersionIsMoreThanMaxVersion() {
+ void computeSchemaStateShouldReturnTooOldWhenVersionIsMoreThanMaxVersion() {
SchemaVersion currentVersion = maxVersion.next();
when(schemaVersionDAO.getCurrentSchemaVersion())
@@ -82,7 +78,7 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void computeSchemaStateShouldReturnUpToDateWhenVersionEqualsMaxVersion() {
+ void computeSchemaStateShouldReturnUpToDateWhenVersionEqualsMaxVersion() {
SchemaVersion currentVersion = maxVersion;
when(schemaVersionDAO.getCurrentSchemaVersion())
@@ -97,7 +93,7 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void computeSchemaStateShouldReturnUpgradableWhenVersionBetweenMinAnd() {
+ void computeSchemaStateShouldReturnUpgradableWhenVersionBetweenMinAnd() {
SchemaVersion currentVersion = minVersion.next();
when(schemaVersionDAO.getCurrentSchemaVersion())
@@ -112,19 +108,19 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void constructorShouldThrowMinVersionIsSuperiorToMaxVersion() {
- expectedException.expect(IllegalArgumentException.class);
-
+ void constructorShouldThrowMinVersionIsSuperiorToMaxVersion() {
SchemaVersion minVersion = new SchemaVersion(4);
SchemaVersion maxVersion = new SchemaVersion(2);
- new CassandraSchemaVersionManager(
- schemaVersionDAO,
- minVersion,
- maxVersion);
+
+ assertThatThrownBy(() -> new CassandraSchemaVersionManager(
+ schemaVersionDAO,
+ minVersion,
+ maxVersion))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void computeSchemaStateShouldReturnUpToDateWhenMinMaxAndVersionEquals() {
+ void computeSchemaStateShouldReturnUpToDateWhenMinMaxAndVersionEquals() {
SchemaVersion minVersion = new SchemaVersion(4);
SchemaVersion maxVersion = new SchemaVersion(4);
SchemaVersion currentVersion = new SchemaVersion(4);
@@ -140,7 +136,7 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void defaultComputedSchemaShouldNotBeTooOldNeitherTooRecent() {
+ void defaultComputedSchemaShouldNotBeTooOldNeitherTooRecent() {
when(schemaVersionDAO.getCurrentSchemaVersion())
.thenReturn(Mono.just(Optional.of(CassandraSchemaVersionManager.DEFAULT_VERSION)));
@@ -152,7 +148,7 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void ensureSchemaDefaultConstructorUseCorrectMinVersion() {
+ void ensureSchemaDefaultConstructorUseCorrectMinVersion() {
when(schemaVersionDAO.getCurrentSchemaVersion())
.thenReturn(Mono.just(Optional.empty()));
@@ -162,7 +158,7 @@ public class CassandraSchemaVersionManagerTest {
}
@Test
- public void ensureSchemaDefaultConstructorUseCorrectMaxVersion() {
+ void ensureSchemaDefaultConstructorUseCorrectMaxVersion() {
when(schemaVersionDAO.getCurrentSchemaVersion())
.thenReturn(Mono.just(Optional.empty()));
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org