From: Sébastien Lesaint Date: Tue, 28 Apr 2015 15:52:51 +0000 (+0200) Subject: SONAR-6366 add missing impl of PlatformDatabaseMigrationAsynchronousTest X-Git-Tag: 5.2-RC1~2060 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1fecf17c816bcf9f75b10e557ef5b4ec080156d2;p=sonarqube.git SONAR-6366 add missing impl of PlatformDatabaseMigrationAsynchronousTest --- diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/PlatformDatabaseMigrationAsynchronousTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/PlatformDatabaseMigrationAsynchronousTest.java index 978174fd191..7b4fc91c990 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/PlatformDatabaseMigrationAsynchronousTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/PlatformDatabaseMigrationAsynchronousTest.java @@ -19,20 +19,16 @@ */ package org.sonar.server.db.migrations; -import com.google.common.base.Throwables; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import org.junit.After; +import org.junit.Test; import org.sonar.server.platform.Platform; import org.sonar.server.ruby.RubyBridge; -import org.sonar.server.ruby.RubyDatabaseMigration; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; public class PlatformDatabaseMigrationAsynchronousTest { - private ExecutorService pool = Executors.newFixedThreadPool(2); - private ExecutorService delegate = Executors.newSingleThreadExecutor(); + private boolean taskSuppliedForAsyncProcess = false; /** * Implementation of execute wraps specified Runnable to add a delay of 200 ms before passing it * to a SingleThread executor to execute asynchronously. @@ -40,26 +36,17 @@ public class PlatformDatabaseMigrationAsynchronousTest { private PlatformDatabaseMigrationExecutorService executorService = new PlatformDatabaseMigrationExecutorServiceAdaptor() { @Override public void execute(final Runnable command) { - delegate.execute(new Runnable() { - @Override - public void run() { - try { - Thread.currentThread().wait(200); - } catch (InterruptedException e) { - Throwables.propagate(e); - } - command.run(); - } - }); + taskSuppliedForAsyncProcess = true; } }; - private RubyDatabaseMigration rubyDatabaseMigration = mock(RubyDatabaseMigration.class); private RubyBridge rubyBridge = mock(RubyBridge.class); private Platform platform = mock(Platform.class); private PlatformDatabaseMigration underTest = new PlatformDatabaseMigration(rubyBridge, executorService, platform); - @After - public void tearDown() throws Exception { - delegate.shutdownNow(); + @Test + public void testName() throws Exception { + underTest.startIt(); + + assertThat(taskSuppliedForAsyncProcess).isTrue(); } }