顶点。从测试中可以访问 spring 个加载了 Verticle 本身的 beans

Vertx. From test having access to spring beans that are loaded with the verticle itself

我想在部署时使用 spring 上下文初始化一个 Verticle 实例(所有都是基于 @Configurations 等的注释),然后能够在集成测试中对其进行测试,

我的垂直:

public class MyServiceVerticle extends AbstractVerticle {

    final VerticleStringContextLoader verticleStringContextLoader = new VerticleStringContextLoader(
        "com.my.config",
        MyConfig.class
    );

    @Override
    public void start(Future<Void> startFuture) {

        verticleStringContextLoader.connectWithVertx(vertx);

        verticleStringContextLoader.onStart(startFuture);
    }

    @Override
    public void stop() {
        verticleStringContextLoader.onStop();
    }

}

VerticleStringContextLoader 中,我加载了 spring 加载了 Verticle 本身的 bean。

像这样:

            sharedContext = new AnnotationConfigApplicationContext();
            sharedContext.register(VertxConfig.class);
            ...
            sharedContext.scan(componentScanPackages);
            sharedContext.refresh();

在测试中, 我想控制 spring 上下文,以便我能够访问那些已加载的 bean。

在集成测试中: 当我部署我的 verticle 时:

 @RunWith(VertxUnitRunner.class) 
 ....

 vertx.deployVerticle(
                    MyServiceVerticle.class.getName(),
                    deploymentOptions,
                    testContext.asyncAssertSuccess( id -> {
                        ...
                    })
                );

问题是..我想我只是这样走捷径:

如何通过部署 Verticle 并初始化 spring 的测试,我可以 access/references 加载 Spring beans

哦..我想我可以在 vert.x 的 3.5 版本中做到这一点(我使用 3.4.2)-

http://vertx.io/docs/apidocs/io/vertx/core/Vertx.html#deployVerticle-io.vertx.core.Verticle-io.vertx.core.DeploymentOptions-

部署时有合适的方法。