【问题标题】:vertx httpserver wait for port listeningvertx httpserver 等待端口监听
【发布时间】:2015-12-16 12:50:01
【问题描述】:

我在运行我的服务器的 RC 时遇到问题。在这一次启动之前,我的集成测试正在访问服务器。 在我开始测试之前,如何确保服务器的端口实际上正在侦听?

我正在使用 httpServer.listen(port, handle) 功能,但似乎无法按照 API 指定的方式工作。

      RxUtils.<HttpServer>observe(handler -> httpServer.requestHandler(addUrlHandlers())
                                                            .listen(port, handler)).doOnCompleted(
            () -> lifecycleEvent("Successfully Registered handlers {}:{}", getName(), port))
                                                                                   .doOnError(t -> lifecycleError(
                                                                                           "Error while registering handlers for port {} in {}", port,
                                                                                           getName(), t))
                                                                                   .map(o -> Boolean.TRUE);

有什么建议吗?

【问题讨论】:

    标签: java vert.x reactivex vertx3


    【解决方案1】:

    这是我的测试代码,context.asyncAssertSuccess() 确保 vertx 已启动

    @RunWith(VertxUnitRunner.class)
    public class LunarCalendarVerticleIntegrationTest {
        private Vertx vertx;
    
        @Before
        public void setUp(TestContext context) {
            vertx = Vertx.vertx();
    
            vertx.deployVerticle(MainVerticle.class.getName(),context.asyncAssertSuccess());
        }
    }
    

    【讨论】:

    • 它只是等到部署Verticle,如果Verticle中有startHttpServer就不用等待了
    猜你喜欢
    • 1970-01-01
    • 2018-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 2012-03-18
    相关资源
    最近更新 更多