@Test public void testMultipleFailedDeploys() throws InterruptedException { int instances = 10; DeploymentOptions options = new DeploymentOptions(); options.setInstances(instances); AtomicBoolean called = new AtomicBoolean(false); vertx.deployVerticle(() -> { Verticle v = new AbstractVerticle() { @Override public void start(final Future<Void> startFuture) throws Exception { startFuture.fail("Fail to deploy."); } }; return v; }, options, asyncResult -> { assertTrue(asyncResult.failed()); assertNull(asyncResult.result()); if (!called.compareAndSet(false, true)) { fail("Completion handler called more than once"); } vertx.setTimer(30, id -> { testComplete(); }); }); await(); }
@Test public void testDeployMultithreadedNotWorker() throws Exception { MyVerticle verticle = new MyVerticle(); try { vertx.deployVerticle(verticle, new DeploymentOptions().setWorker(false).setMultiThreaded(true), ar -> { }); fail("Should throw exception"); } catch (IllegalArgumentException e) { // OK } try { vertx.deployVerticle(MyVerticle.class.getName(), new DeploymentOptions().setWorker(false).setMultiThreaded(true), ar -> { }); fail("Should throw exception"); } catch (IllegalArgumentException e) { // OK } }
@Test public void testMultipleFailedDeploys() throws InterruptedException { int instances = 10; DeploymentOptions options = new DeploymentOptions(); options.setInstances(instances); AtomicBoolean called = new AtomicBoolean(false); vertx.deployVerticle(() -> { Verticle v = new AbstractVerticle() { @Override public void start(final Future<Void> startFuture) throws Exception { startFuture.fail("Fail to deploy."); } }; return v; }, options, asyncResult -> { assertTrue(asyncResult.failed()); assertNull(asyncResult.result()); if (!called.compareAndSet(false, true)) { fail("Completion handler called more than once"); } vertx.setTimer(30, id -> { testComplete(); }); }); await(); }