]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6366 add missing impl of PlatformDatabaseMigrationAsynchronousTest
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 28 Apr 2015 15:52:51 +0000 (17:52 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 5 May 2015 07:18:54 +0000 (09:18 +0200)
server/sonar-server/src/test/java/org/sonar/server/db/migrations/PlatformDatabaseMigrationAsynchronousTest.java

index 978174fd191848dfef3cf5a1e348688d596eb131..7b4fc91c9905938d4d70accd92c701f9b3ccad85 100644 (file)
  */
 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();
   }
 }