0

I want to create a vertx unit test. This test just create a consumer and execute a request.

EventBus eventBus = this.vertx.eventBus();
final TestSuite processTestSuite = TestSuite.create("Use Case Verticle Test Suite");
processTestSuite
    .before(context -> {
         Async async = context.async(2);
         this.vertx.eventBus().<String>consumer("WORLD", event -> {
              event.reply("Hallo Welt");
         }).completionHandler(dEvent -> {
              context.assertTrue(dEvent.succeeded());
              async.countDown(); // <-- code reached
              this.vertx.eventBus().<String>request("WORLD", new JsonObject(), event2 -> {
                   context.assertTrue(event2.succeeded()); // <-- this code never reached
                   context.assertEquals(event2.result().body(), "Hallo Welt");
                        async.countDown();
                    });
              });
        });

TestOptions options = new TestOptions();
options.addReporter(new ReportOptions().setTo("console"));

TestCompletion completion = processTestSuite.run(vertx, options);

completion.handler(event -> {
    if (event.succeeded()) {
        System.out.println("PROCESS TEST DONE!");
    } else {
        event.cause().printStackTrace();
    }
});
completion.awaitSuccess();

Why the the request never execute?

Qeychon
  • 477
  • 1
  • 5
  • 15
  • i have tested, and this code works for me. Can you maybe show what the processTestSuite does? – taygetos Jan 24 '22 at 09:50
  • @taygetos thank you for your response. I extended the source code. I thought the TestSuite is not really complex so i didn't added here. It still not works and I'm not sure why. – Qeychon Jan 24 '22 at 20:09

0 Answers0