RunRightFastVertxApplicationLauncher extends AbstractIdleService { private static void runApp(final Supplier<RunRightFastVertxApplication> app) { final RunRightFastVertxApplicationLauncher service = RunRightFastVertxApplicationLauncher.builder().app(app.get()).build(); log.logp(INFO, CLASS_NAME, "runApp", "starting"); service.startAsync(); service.awaitRunning(); log.logp(INFO, CLASS_NAME, "runApp", "running"); service.awaitTerminated(); log.logp(INFO, CLASS_NAME, "runApp", "terminated"); }  static int run(@NonNull final Supplier<RunRightFastVertxApplication> app, final String... args);  }
@Test public void testRunApp() throws Exception { ForkJoinPool.commonPool().execute(() -> RunRightFastVertxApplicationLauncher.run(() -> app)); final RunRightFastVerticleId verticleManagerId = RunRightFastVerticleManager.VERTICLE_ID; final CompletableFuture future = new CompletableFuture(); final String address = EventBusAddress.eventBusAddress(verticleManagerId, "get-verticle-deployments"); final Vertx vertx = app.vertxService().getVertx(); vertx.eventBus().send( address, GetVerticleDeployments.Request.newBuilder().build(), new DeliveryOptions().setSendTimeout(2000L), getVerticleDeploymentsResponseHandler(future) ); final Object result = future.get(2000L, TimeUnit.MILLISECONDS); final ApplicationMXBean appMXBean = JMX.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), applicationMBeanObjectName(JmxUtils.RUNRIGHTFAST_JMX_DOMAIN, ApplicationMXBean.class), ApplicationMXBean.class); assertThat(appMXBean.getApplicationGroup(), is("co.runrightfast")); assertThat(appMXBean.getApplicationName(), is("test-app")); assertThat(appMXBean.getApplicationVersion(), is("1.0.0")); log.logp(INFO, getClass().getName(), "testRunApp", "{0}:\n{1}", new Object[]{"configAsHConf", appMXBean.configAsHConf()}); log.logp(INFO, getClass().getName(), "testRunApp", "{0}:\n{1}", new Object[]{"configAsHJson", appMXBean.configAsJson()}); log.logp(INFO, getClass().getName(), "testRunApp", "{0}:\n{1}", new Object[]{"configWithCommentsAndSourceInfo", appMXBean.configWithCommentsAndSourceInfo()}); appMXBean.shutdown(); app.vertxService().awaitTerminated(); }