I have vert.x app-server with simplest authorisation, which has some route like this:
router.post("/user/sign").handler(this::userSignIn);
While I'm doing this from UI, it works, all ok.
But I want to create unit-test for this action. That code:
@Test
public void testServerUserRegister(TestContext context) {
HttpClient client = vertx.createHttpClient();
HttpClientRequest request = client.post("user/sign", response -> {
System.out.println("Some callback " + response.statusCode());
});
String body = "{'username':'www','password':'www'}";
request.putHeader("content-length", "1000");
request.putHeader("content-type", "application/x-www-form-urlencoded");
request.write(body);
request.end();
}
When I start this test
mvn test
I see result that test is OK, however:
- I don't see any string like "Some callback..."
- I'm getting exeption:
вер. 16, 2016 4:29:20 PM io.vertx.core.http.impl.HttpClientImpl SEVERE: java.nio.channels.ClosedChannelException вер. 16, 2016 4:29:20 PM io.netty.channel.AbstractChannel$AbstractUnsafe invokeLater WARNING: Can't invoke task later as EventLoop rejected it java.util.concurrent.RejectedExecutionException: event executor terminated at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:707) at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:299) at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:687) at io.netty.channel.AbstractChannel$AbstractUnsafe.invokeLater(AbstractChannel.java:826) at io.netty.channel.AbstractChannel$AbstractUnsafe.deregister(AbstractChannel.java:656) at io.netty.channel.AbstractChannel$AbstractUnsafe.fireChannelInactiveAndDeregister(AbstractChannel.java:626) at io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:600) at io.netty.channel.nio.NioEventLoop.closeAll(NioEventLoop.java:576) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:361) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) at java.lang.Thread.run(Thread.java:745)
Really I would like to know what I'm doing wrong.
Thx.
Aucun commentaire:
Enregistrer un commentaire