mercredi 18 avril 2018

vertx.createHttpClient().getNow() not invoking the handler

I have the following test method:

private Vertx vertx;

@Before
public void setUp(TestContext context) throws IOException {
    vertx = Vertx.vertx();
    vertx.deployVerticle(MainVerticle.class.getName(), context.asyncAssertSuccess());
}

@After
public void tearDown(TestContext context) {
    vertx.close(context.asyncAssertSuccess());
}

@Test
public void serverIsStarted(TestContext context) {
    vertx.createHttpClient().getNow(8080, "localhost", "/inexistent", response -> {
        System.out.println("Handler running");
        Assert.assertEquals(response.statusCode(), 200);
        context.assertEquals(response.statusCode(), 200);
    });
    System.out.println("Done");
}

Taken from this sample repo. However, it doesn't really do anything. The path inexistent doesn't exist, and even if I remove the code that launches the server in setUp, the test still passes. Also the text "Handler running" is not printed, only "Done".

What am I missing, why doesn't it do anything?

Aucun commentaire:

Enregistrer un commentaire