title: Vertx unit-test blocking the main thread
body: <p>While trying to test a <em>Vert.x</em> verticle using the event bus through a test class, I'm getting an "blocking errors". Here down the verticle and test classes:</p>
  
  <p><code>EventBusReceiverVerticle</code>:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class EventBusReceiverVerticle extends AbstractVerticle {
  
      public EventBusReceiverVerticle(String name) {
          this.name = name;
      }
  
      public void start() {
  
                vertx.eventBus().consumer("geo-service", (Message&lt;JsonObject&gt; handler) -&gt; {
              {
                  try {
                      System.out.println("sleep 10 seconds");
                      Thread.sleep(10000);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }           
              }
          });
      }
  }
  </code></pre>
  
  <p>The test class:</p>
  
  <pre class="lang-java prettyprint-override"><code>@RunWith(VertxUnitRunner.class)
  public class MyFirstVerticleTest {
      Vertx vertx;
      EventBus eb;
      private static final Logger logger = LoggerFactory.getLogger(MyFirstVerticleTest.class);
  
  
      @Before
      public void setUp(TestContext context) {
          logger.info("@Before");
          vertx = Vertx.vertx();
          eb = vertx.eventBus();
  
          Async async = context.async();
          vertx.deployVerticle(new EventBusReceiverVerticle("R1"), res -&gt; {
              if (res.succeeded()) {
                  async.complete();
              } else {
                  context.fail();
              }
          });
      }
  
      @After
      public void tearDown(TestContext context) {
          logger.info("@After");
          Async async = context.async();
          vertx.close(event -&gt; async.complete());
      }
  
  
      @Test
      public void testEventBusVerticle(TestContext context) {
          Async async = context.async();
          JsonObject msg = new JsonObject("{\"action\":\"pos\"}");
          eb.send("geo-service", msg, reply -&gt; {
              if (reply.succeeded()) {
                  async.complete();
              } else {
                  context.fail();
              }
          });
          async.complete();
      }
  }
  </code></pre>
  
  <p>Console output:</p>
  
  <pre><code>Sep 05, 2015 2:20:23 PM com.company.MyFirstVerticleTest
  INFO: @Before
  sleep 10 seconds
  Sep 05, 2015 2:20:24 PM com.company.MyFirstVerticleTest
  INFO: @After
  Sep 05, 2015 2:20:27 PM io.vertx.core.impl.BlockedThreadChecker
  WARNING: Thread Thread[vert.x-eventloop-thread-2,5,main] has been blocked for 2790 ms, time limit is 2000
  Sep 05, 2015 2:20:28 PM io.vertx.core.impl.BlockedThreadChecker
  WARNING: Thread Thread[vert.x-eventloop-thread-2,5,main] has been blocked for 3794 ms, time limit is 2000
  Sep 05, 2015 2:20:29 PM io.vertx.core.impl.BlockedThreadChecker
  WARNING: Thread Thread[vert.x-eventloop-thread-2,5,main] has been blocked for 4796 ms, time limit is 2000
  Sep 05, 2015 2:20:30 PM io.vertx.core.impl.BlockedThreadChecker
  WARNING: Thread Thread[vert.x-eventloop-thread-2,5,main] has been blocked for 5799 ms, time limit is 2000
  io.vertx.core.VertxException: Thread blocked
      at java.lang.Thread.sleep(Native Method)
      at com.company.verticals.EventBusReceiverVerticle.lambda$start$1(EventBusReceiverVerticle.java:35)
      at com.company.verticals.EventBusReceiverVerticle$$Lambda$10/2029238960.handle(Unknown Source)
      at io.vertx.core.eventbus.impl.EventBusImpl$HandlerRegistration.handle(EventBusImpl.java:1108)
      at io.vertx.core.eventbus.impl.EventBusImpl.lambda$doReceive$189(EventBusImpl.java:755)
      at io.vertx.core.eventbus.impl.EventBusImpl$$Lambda$17/1888442711.handle(Unknown Source)
      at io.vertx.core.impl.ContextImpl.lambda$wrapTask$15(ContextImpl.java:314)
      at io.vertx.core.impl.ContextImpl$$Lambda$9/911312317.run(Unknown Source)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:357)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
      at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>