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/06/17 04:52:48 UTC
[james-project] branch master updated: Revert "JAMES-2777 fix too
strong expectation about task cancellation"
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
The following commit(s) were added to refs/heads/master by this push:
new ace9f15 Revert "JAMES-2777 fix too strong expectation about task cancellation"
ace9f15 is described below
commit ace9f15ef11f203d98d54b2882ef95887afaab92
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 17 11:41:38 2019 +0700
Revert "JAMES-2777 fix too strong expectation about task cancellation"
This reverts commit 6cfdc93a153a6cd4b178010b7466b318dc76a80f.
and commit e370028ffce53847c131be036a252da7174f1089.
Revert "JAMES-2777 fix too strong expectation about task cancellation"
This reverts commit f9373996c22b12aecce6d19ae277b26a67fa0432.
---
.../backends/cassandra/migration/MigrationTask.java | 2 +-
.../migration/CassandraMigrationServiceTest.java | 17 ++++++++---------
.../backends/cassandra/migration/MigrationTest.java | 8 ++++----
.../apache/james/vault/DeletedMessageVaultContract.java | 14 +++++++-------
.../webadmin/routes/CassandraMigrationRoutesTest.java | 4 ++--
.../task/src/main/java/org/apache/james/task/Task.java | 2 +-
.../org/apache/james/task/MemoryTaskManagerTest.java | 1 -
7 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/migration/MigrationTask.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/migration/MigrationTask.java
index 40c7c62..7fd3bdd 100644
--- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/migration/MigrationTask.java
+++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/migration/MigrationTask.java
@@ -48,7 +48,7 @@ public class MigrationTask implements Migration {
}
@Override
- public Result run() throws InterruptedException {
+ public Result run() {
return migration.run();
}
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 efa90e3..e0a849e 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
@@ -47,7 +47,6 @@ import org.junit.rules.ExpectedException;
import com.datastax.driver.core.Session;
import com.google.common.collect.ImmutableMap;
-
import reactor.core.publisher.Mono;
public class CassandraMigrationServiceTest {
@@ -98,7 +97,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToVersionShouldNotThrowWhenCurrentVersionIsUpToDate() throws Exception {
+ public void upgradeToVersionShouldNotThrowWhenCurrentVersionIsUpToDate() {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(CURRENT_VERSION)));
assertThat(testee.upgradeToVersion(OLDER_VERSION).run())
@@ -106,7 +105,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToVersionShouldUpdateToVersion() throws Exception {
+ public void upgradeToVersionShouldUpdateToVersion() {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION)));
testee.upgradeToVersion(CURRENT_VERSION).run();
@@ -115,7 +114,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToLastVersionShouldNotThrowWhenVersionIsUpToDate() throws Exception {
+ public void upgradeToLastVersionShouldNotThrowWhenVersionIsUpToDate() {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(LATEST_VERSION)));
@@ -124,7 +123,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToLastVersionShouldUpdateToLatestVersion() throws Exception {
+ public void upgradeToLastVersionShouldUpdateToLatestVersion() {
when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION)));
testee.upgradeToLastVersion().run();
@@ -133,7 +132,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToVersionShouldThrowOnMissingVersion() throws Exception {
+ public void upgradeToVersionShouldThrowOnMissingVersion() {
Map<SchemaVersion, Migration> allMigrationClazz = ImmutableMap.<SchemaVersion, Migration>builder()
.put(OLDER_VERSION, successfulMigration)
.put(LATEST_VERSION, successfulMigration)
@@ -147,7 +146,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void upgradeToVersionShouldUpdateIntermediarySuccessfulMigrationsInCaseOfError() throws Exception {
+ public void upgradeToVersionShouldUpdateIntermediarySuccessfulMigrationsInCaseOfError() {
try {
Map<SchemaVersion, Migration> allMigrationClazz = ImmutableMap.<SchemaVersion, Migration>builder()
.put(OLDER_VERSION, successfulMigration)
@@ -166,7 +165,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void partialMigrationShouldThrow() throws Exception {
+ public void partialMigrationShouldThrow() {
Migration migration1 = mock(Migration.class);
when(migration1.run()).thenReturn(Migration.Result.PARTIAL);
Migration migration2 = successfulMigration;
@@ -183,7 +182,7 @@ public class CassandraMigrationServiceTest {
}
@Test
- public void partialMigrationShouldAbortMigrations() throws Exception {
+ public void partialMigrationShouldAbortMigrations() {
Migration migration1 = mock(Migration.class);
when(migration1.run()).thenReturn(Migration.Result.PARTIAL);
Migration migration2 = mock(Migration.class);
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/MigrationTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/MigrationTest.java
index 7f110c3..f1a0092 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/MigrationTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/migration/MigrationTest.java
@@ -27,7 +27,7 @@ import org.junit.Test;
public class MigrationTest {
@Test
- public void combineShouldNotExecuteSecondMigrationExecutionWhenTheFirstOneIsFailing() throws Exception {
+ public void combineShouldNotExecuteSecondMigrationExecutionWhenTheFirstOneIsFailing() {
AtomicBoolean migration2Done = new AtomicBoolean(false);
Migration migration1 = () -> Migration.Result.PARTIAL;
@@ -42,7 +42,7 @@ public class MigrationTest {
}
@Test
- public void combineShouldTriggerSecondMigrationWhenTheFirstOneSucceed() throws Exception {
+ public void combineShouldTriggerSecondMigrationWhenTheFirstOneSucceed() {
AtomicBoolean migration2Done = new AtomicBoolean(false);
Migration migration1 = () -> Migration.Result.COMPLETED;
@@ -57,7 +57,7 @@ public class MigrationTest {
}
@Test
- public void combineShouldExecuteTheFirstMigrationWhenSecondWillFail() throws Exception {
+ public void combineShouldExecuteTheFirstMigrationWhenSecondWillFail() {
AtomicBoolean migration1Done = new AtomicBoolean(false);
Migration migration1 = () -> {
@@ -73,7 +73,7 @@ public class MigrationTest {
}
@Test
- public void combineShouldExecuteTheFirstMigration() throws Exception {
+ public void combineShouldExecuteTheFirstMigration() {
AtomicBoolean migration1Done = new AtomicBoolean(false);
Migration migration1 = () -> {
diff --git a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageVaultContract.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageVaultContract.java
index 273d288..c28f79f 100644
--- a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageVaultContract.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageVaultContract.java
@@ -221,14 +221,14 @@ public interface DeletedMessageVaultContract {
}
@Test
- default void deleteExpiredMessagesTaskShouldCompleteWhenNoMail() throws Exception {
+ default void deleteExpiredMessagesTaskShouldCompleteWhenNoMail() {
Task.Result result = getVault().deleteExpiredMessagesTask().run();
assertThat(result).isEqualTo(Task.Result.COMPLETED);
}
@Test
- default void deleteExpiredMessagesTaskShouldCompleteWhenAllMailsDeleted() throws Exception {
+ default void deleteExpiredMessagesTaskShouldCompleteWhenAllMailsDeleted() {
Mono.from(getVault().append(USER, DELETED_MESSAGE, new ByteArrayInputStream(CONTENT))).block();
Mono.from(getVault().delete(USER, DELETED_MESSAGE.getMessageId())).block();
@@ -238,7 +238,7 @@ public interface DeletedMessageVaultContract {
}
@Test
- default void deleteExpiredMessagesTaskShouldCompleteWhenOnlyRecentMails() throws Exception {
+ default void deleteExpiredMessagesTaskShouldCompleteWhenOnlyRecentMails() {
Mono.from(getVault().append(USER, DELETED_MESSAGE, new ByteArrayInputStream(CONTENT))).block();
Task.Result result = getVault().deleteExpiredMessagesTask().run();
@@ -247,7 +247,7 @@ public interface DeletedMessageVaultContract {
}
@Test
- default void deleteExpiredMessagesTaskShouldCompleteWhenOnlyOldMails() throws Exception {
+ default void deleteExpiredMessagesTaskShouldCompleteWhenOnlyOldMails() {
Mono.from(getVault().append(USER, OLD_DELETED_MESSAGE, new ByteArrayInputStream(CONTENT))).block();
Task.Result result = getVault().deleteExpiredMessagesTask().run();
@@ -256,7 +256,7 @@ public interface DeletedMessageVaultContract {
}
@Test
- default void deleteExpiredMessagesTaskShouldDoNothingWhenEmpty() throws Exception {
+ default void deleteExpiredMessagesTaskShouldDoNothingWhenEmpty() {
getVault().deleteExpiredMessagesTask().run();
assertThat(Flux.from(getVault().search(USER, ALL)).collectList().block())
@@ -264,7 +264,7 @@ public interface DeletedMessageVaultContract {
}
@Test
- default void deleteExpiredMessagesTaskShouldNotDeleteRecentMails() throws Exception {
+ default void deleteExpiredMessagesTaskShouldNotDeleteRecentMails() {
Mono.from(getVault().append(USER, DELETED_MESSAGE, new ByteArrayInputStream(CONTENT))).block();
getVault().deleteExpiredMessagesTask().run();
@@ -274,7 +274,7 @@ public interface DeletedMessageVaultContract {
}
@Test
- default void deleteExpiredMessagesTaskShouldDeleteOldMails() throws Exception {
+ default void deleteExpiredMessagesTaskShouldDeleteOldMails() {
Mono.from(getVault().append(USER, OLD_DELETED_MESSAGE, new ByteArrayInputStream(CONTENT))).block();
getVault().deleteExpiredMessagesTask().run();
diff --git a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
index fc853d3..5e09109 100644
--- a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
@@ -66,7 +66,7 @@ public class CassandraMigrationRoutesTest {
private CassandraSchemaVersionDAO schemaVersionDAO;
private MemoryTaskManager taskManager;
- private void createServer() throws InterruptedException {
+ private void createServer() {
Migration successfulMigration = mock(Migration.class);
when(successfulMigration.run()).thenReturn(Migration.Result.COMPLETED);
@@ -92,7 +92,7 @@ public class CassandraMigrationRoutesTest {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
createServer();
}
diff --git a/server/task/src/main/java/org/apache/james/task/Task.java b/server/task/src/main/java/org/apache/james/task/Task.java
index 0c79ec0..82b7670 100644
--- a/server/task/src/main/java/org/apache/james/task/Task.java
+++ b/server/task/src/main/java/org/apache/james/task/Task.java
@@ -74,7 +74,7 @@ public interface Task {
*
* @return Return true if fully migrated. Returns false otherwise.
*/
- Result run() throws InterruptedException;
+ Result run();
default String type() {
diff --git a/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java b/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java
index 691bbc9..3533eb3 100644
--- a/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java
+++ b/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java
@@ -92,7 +92,6 @@ class MemoryTaskManagerTest {
TaskId id = memoryTaskManager.submit(() -> {
waitForTaskToBeLaunched.countDown();
await(task1Latch);
- Thread.sleep(1);
count.incrementAndGet();
return Task.Result.COMPLETED;
});
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org