Java Code Examples for io.vertx.core.DeploymentOptions

The following examples show how to use io.vertx.core.DeploymentOptions. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: konduit-serving   Source File: TestMetricsEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp(TestContext testContext) {
    configuration = new InferenceConfiguration()
            .protocol(ServerProtocol.HTTP)
            .pipeline(SequencePipeline.builder()
                    .add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES).logLevel(Level.ERROR))
                    .add(new MetricsTestingStep())
                    .build());

    Async async = testContext.async();

    vertx = DeployKonduitServing.deploy(new VertxOptions(),
            new DeploymentOptions(),
            configuration,
            handler -> {
                if(handler.succeeded()) {
                    inferenceDeploymentResult = handler.result();
                    async.complete();
                } else {
                    testContext.fail(handler.cause());
                }
            });
}
 
Example 2
Source Project: konduit-serving   Source File: InferenceVerticleMqttTest.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp(TestContext testContext) {
    configuration = new InferenceConfiguration()
            .protocol(ServerProtocol.MQTT)
            .pipeline(SequencePipeline.builder()
                    .add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES).logLevel(Level.ERROR))
                    .build());

    Async async = testContext.async();

    vertx = DeployKonduitServing.deploy(new VertxOptions(),
            new DeploymentOptions(),
            configuration,
            handler -> {
                if(handler.succeeded()) {
                    inferenceDeploymentResult = handler.result();
                    async.complete();
                } else {
                    testContext.fail(handler.cause());
                }
            });
}
 
Example 3
Source Project: konduit-serving   Source File: InferenceVerticleHttpTest.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp(TestContext testContext) {
    configuration = new InferenceConfiguration()
            .protocol(ServerProtocol.HTTP)
            .pipeline(SequencePipeline.builder()
                    .add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES).logLevel(Level.ERROR))
                    .add(new FailureTestingPipelineStep())
                    .build());

    Async async = testContext.async();

    vertx = DeployKonduitServing.deploy(new VertxOptions(),
            new DeploymentOptions(),
            configuration,
            handler -> {
                if(handler.succeeded()) {
                    inferenceDeploymentResult = handler.result();
                    async.complete();
                } else {
                    testContext.fail(handler.cause());
                }
            });
}
 
Example 4
Source Project: vertx-shell   Source File: ShellExamples.java    License: Apache License 2.0 6 votes vote down vote up
public void deployHttpServiceWithMongo(Vertx vertx) throws Exception {
  vertx.deployVerticle("maven:{maven-groupId}:{maven-artifactId}:{maven-version}",
    new DeploymentOptions().setConfig(new JsonObject().
      put("httpOptions", new JsonObject().
        put("host", "localhost").
        put("port", 8080).
        put("ssl", true).
        put("keyPairOptions", new JsonObject().
          put("path", "src/test/resources/server-keystore.jks").
          put("password", "wibble")).
        put("authOptions", new JsonObject().
          put("provider", "mongo").
          put("config", new JsonObject().
            put("connection_string", "mongodb://localhost:27018"))))
    )
  );
}
 
Example 5
Source Project: vxms   Source File: RESTJerseyPOSTFileClientTests.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));


  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  awaitLatch(latch2);
}
 
Example 6
Source Project: vertx-in-action   Source File: Main.java    License: MIT License 6 votes vote down vote up
public static void main(String[] args) {
  Vertx vertx = Vertx.vertx();

  vertx.deployVerticle("chapter5.sensor.HeatSensor",
    new DeploymentOptions().setConfig(new JsonObject()
      .put("http.port", 3000)));

  vertx.deployVerticle("chapter5.sensor.HeatSensor",
    new DeploymentOptions().setConfig(new JsonObject()
      .put("http.port", 3001)));

  vertx.deployVerticle("chapter5.sensor.HeatSensor",
    new DeploymentOptions().setConfig(new JsonObject()
      .put("http.port", 3002)));

  vertx.deployVerticle("chapter5.snapshot.SnapshotService");
  vertx.deployVerticle("chapter5.reactivex.CollectorService");
}
 
Example 7
Source Project: vertx-in-action   Source File: Main.java    License: MIT License 6 votes vote down vote up
public static void main(String[] args) {
  Vertx vertx = Vertx.vertx();

  vertx.deployVerticle("chapter5.sensor.HeatSensor",
    new DeploymentOptions().setConfig(new JsonObject()
      .put("http.port", 3000)));

  vertx.deployVerticle("chapter5.sensor.HeatSensor",
    new DeploymentOptions().setConfig(new JsonObject()
      .put("http.port", 3001)));

  vertx.deployVerticle("chapter5.sensor.HeatSensor",
    new DeploymentOptions().setConfig(new JsonObject()
      .put("http.port", 3002)));

  vertx.deployVerticle("chapter5.snapshot.SnapshotService");
  vertx.deployVerticle("chapter5.future.CollectorService");
}
 
Example 8
Source Project: vertx-stomp   Source File: MultiInstanceTransactionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testThatTransactionAreNotShared(TestContext context) {
  vertx.deployVerticle("io.vertx.ext.stomp.verticles.StompServerVerticle", new DeploymentOptions().setInstances(3),
      ar -> {
        if (ar.failed()) {
          context.fail(ar.cause());
        } else {
          deploymentId = ar.result();
          // Deploy the clients.
          vertx.deployVerticle("io.vertx.ext.stomp.verticles.ReceiverStompClient", ar2 -> {
            if (ar.failed()) {
              context.fail(ar.cause());
            } else {
              vertx.deployVerticle("io.vertx.ext.stomp.verticles.TxSenderStompClient", ar3 -> {
                System.out.println("Test started");
              });
            }
          });
        }
      });

  Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> ReceiverStompClient.FRAMES.size() == 5);
}
 
Example 9
Source Project: vertx-config   Source File: VerticleDeployment.java    License: Apache License 2.0 6 votes vote down vote up
public void configureVertx() {
  // Create a first instance of Vert.x
  Vertx vertx = Vertx.vertx();
  // Create the config retriever
  ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
    .addStore(new ConfigStoreOptions().setType("file").setConfig(new JsonObject().put("path", "vertx.json"))));

  // Retrieve the configuration
  retriever.getConfig(json -> {
    JsonObject result = json.result();
    // Close the vert.x instance, we don't need it anymore.
    vertx.close();

    // Create a new Vert.x instance using the retrieve configuration
    VertxOptions options = new VertxOptions(result);
    Vertx newVertx = Vertx.vertx(options);

    // Deploy your verticle
    newVertx.deployVerticle(GreetingVerticle.class.getName(), new DeploymentOptions().setConfig(result.getJsonObject("a")));
  });
}
 
Example 10
Source Project: vxms   Source File: RESTRouteBuilderPOSTFileClientTests.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));


  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  awaitLatch(latch2);
}
 
Example 11
@Test
public void init() throws InterruptedException {
  globalRegistry.add(registry);
  vertxMetersInitializer.init(globalRegistry, eventBus, null);
  logPublisher.init(null, eventBus, null);
  VertxUtils
      .blockDeploy(SharedVertxFactory.getSharedVertx(), TestServerVerticle.class, new DeploymentOptions());
  VertxUtils
      .blockDeploy(SharedVertxFactory.getSharedVertx(), TestClientVerticle.class, new DeploymentOptions());

  globalRegistry.poll(1);
  List<Meter> meters = Lists.newArrayList(registry.iterator());
  List<Measurement> measurements = new ArrayList<>();
  for (Meter meter : meters) {
    meter.measure().forEach(measurements::add);
  }

  LogCollector logCollector = new LogCollector();

  testLog(logCollector, meters, measurements, true);
  logCollector.clear();
  testLog(logCollector, meters, measurements, false);

  logCollector.teardown();
}
 
Example 12
private void doTest(String verticle, String message, TestContext context) throws IOException {
  Async async = context.async();
  int port = getAvailablePort();
  JsonObject config = new JsonObject().put("port", port);
  DeploymentOptions options = new DeploymentOptions().setConfig(config);
  Vertx vertx = runTestOnContext.vertx();
  vertx.deployVerticle(verticle, options, context.asyncAssertSuccess(deploymentID -> {
    HttpClient client = vertx.createHttpClient();
    // retry for 30 seconds and give the verticle a chance to launch the server
    makeRequest(client, port, 30, 1000, context.asyncAssertSuccess(buffer -> {
      context.assertEquals(message, buffer.toString());
      vertx.undeploy(deploymentID, context.asyncAssertSuccess(r -> async.complete()));
      client.close();
    }));
  }));
}
 
Example 13
Source Project: vxms   Source File: VxmsGateway.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  DeploymentOptions options =
      new DeploymentOptions()
          .setInstances(1)
          .setConfig(
              new JsonObject()
                  .put("kube.offline", true)
                  .put("local", true)
                  .put("read_name", "vxms-k8s-read")
                  .put("read_version", "1.2-SNAPSHOT")
                  .put("write_name", "vxms-k8s-write")
                  .put("write_version", "1.2-SNAPSHOT")
                  .put("name.vxms-k8s-read.version.1.2-SNAPSHOT", "localhost:7070")
                  .put("name.vxms-k8s-write.version.1.2-SNAPSHOT", "localhost:9090"));

  Vertx.vertx().deployVerticle(VxmsGateway.class.getName(), options);
}
 
Example 14
@Before
public void setUp(TestContext tc) {
  Async async = tc.async();
  vertx = Vertx.vertx();
  Record record = MessageSource.createRecord("portfolio-events", "portfolio", JsonObject
      .class);
  ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions()
      .setBackendConfiguration(new JsonObject().put("backend-name", DefaultServiceDiscoveryBackend.class.getName())))
      .publish(record,
          r -> {
            if (r.failed()) {
              r.cause().printStackTrace();
              tc.fail(r.cause());
            }
            vertx.deployVerticle(AuditVerticle.class.getName(), new DeploymentOptions().setConfig(CONFIGURATION), tc.asyncAssertSuccess(s -> async.complete()));
          });
}
 
Example 15
Source Project: okapi   Source File: PullTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp(TestContext context) {
  logger.debug("staring PullTest");
  vertx = Vertx.vertx();
  Async async = context.async();
  DeploymentOptions opt = new DeploymentOptions()
    .setConfig(new JsonObject().put("port", Integer.toString(port2))
    );
  vertx.deployVerticle(MainVerticle.class.getName(), opt, res -> {
    if (res.failed()) {
      context.fail(res.cause());
    } else {
      vert1 = res.result();
      otherDeploy(context, async);
    }
  });
}
 
Example 16
@Test
public void test(TestContext testContext) throws Exception {
    JsonObject config = makeDefaultConfig();
    config.put(KafkaProducerProperties.ADDRESS, ADDRESS);
    config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC);

    final DeploymentOptions deploymentOptions = new DeploymentOptions();
    deploymentOptions.setConfig(config);
    deploy(testContext, deploymentOptions);

    final Async async = testContext.async();
    try {
        final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, ADDRESS);
        kafkaProducerService.sendString(new StringKafkaMessage(MESSAGE), (Handler<AsyncResult<Void>>) message -> {
            if (message.failed()) {
                testContext.assertTrue(message.cause().getMessage().equals("Failed to update metadata after 5 ms."));
                async.complete();
            } else {
                testContext.fail();
            }
        });
    } catch (Exception e) {
        testContext.fail(e);
    }
}
 
Example 17
Source Project: apiman   Source File: InitVerticle.java    License: Apache License 2.0 6 votes vote down vote up
private void deploy(String canonicalName, VerticleType verticleType, @SuppressWarnings("rawtypes") List<Future> deployList) {
    log.info("Will deploy {0} of type {1}", apimanConfig.getVerticleCount(verticleType), verticleType);

    if (apimanConfig.getVerticleCount(verticleType) <= 0) {
        return;
    }

    DeploymentOptions deploymentOptions = new DeploymentOptions(base)
            .setInstances(apimanConfig.getVerticleCount(verticleType));
    // Future for this deployment.
    Future<String> future = Future.future();
    // Do deployment
    vertx.deployVerticle(canonicalName, deploymentOptions, future.completer());
    // Set the future associated with the deployment so #all can wait for it.
    deployList.add(future);
}
 
Example 18
@Before
public void startVerticles() throws InterruptedException {
  initKubernetes();
  initService();
  CountDownLatch latch2 = new CountDownLatch(1);
  JsonObject conf = new JsonObject();
  conf.put("service1.name", "myTestService").put("service1.port", "mytcp");
  conf.put("service2.name", "myTestService2").put("service2.value", "v2");
  DeploymentOptions options = new DeploymentOptions().setConfig(conf).setInstances(1);

  vertx.deployVerticle(
      new WsServiceOne(config),
      options,
      asyncResult -> {
        // Deployment is asynchronous and this this handler will be called when it's complete
        // (or failed)
        System.out.println("start service: " + asyncResult.succeeded());
        assertTrue(asyncResult.succeeded());
        assertNotNull("deploymentID should not be null", asyncResult.result());
        // If deployed correctly then start the tests!
        //   latch2.countDown();

        latch2.countDown();
      });

  httpClient = vertx.createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}
 
Example 19
Source Project: vertx-kue   Source File: Kue.java    License: Apache License 2.0 5 votes vote down vote up
private void processInternal(String type, Handler<Job> handler, boolean isWorker) {
  KueWorker worker = new KueWorker(type, handler, this);
  vertx.deployVerticle(worker, new DeploymentOptions().setWorker(isWorker), r0 -> {
    if (r0.succeeded()) {
      this.on("job_complete", msg -> {
        long dur = new Job(((JsonObject) msg.body()).getJsonObject("job")).getDuration();
        client.incrby(RedisHelper.getKey("stats:work-time"), dur, r1 -> {
          if (r1.failed())
            r1.cause().printStackTrace();
        });
      });
    }
  });
}
 
Example 20
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);

  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)).setInstances(1);
  // Deploy the module - the System property `vertx.modulename` will contain the name of the
  // module so you
  // don'failure have to hardecode it in your tests

  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  client = getVertx().createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}
 
Example 21
Source Project: vxms   Source File: RESTServiceOnFailureByteResponseTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));
  // Deploy the module - the System property `vertx.modulename` will contain the name of the
  // module so you
  // don'failure have to hardecode it in your tests

  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  awaitLatch(latch2);
}
 
Example 22
Source Project: okapi   Source File: ModuleTenantsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp(TestContext context) {
  logger.debug("starting ModuleTenantsTest");
  vertx = Vertx.vertx();
  httpClient = vertx.createHttpClient();
  JsonObject conf = new JsonObject()
    .put("port", Integer.toString(port))
    .put("logWaitMs", 200);

  DeploymentOptions opt = new DeploymentOptions()
    .setConfig(conf);

  vertx.deployVerticle(MainVerticle.class.getName(), opt, context.asyncAssertSuccess());
}
 
Example 23
Source Project: vxms   Source File: RESTJerseyMimeTypeClientTests.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));
  // Deploy the module - the System property `vertx.modulename` will contain the name of the
  // module so you
  // don'failure have to hardecode it in your tests

  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  client = getVertx().createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}
 
Example 24
Source Project: vert.x-microservice   Source File: WSConsumesTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    CountDownLatch latch2 = new CountDownLatch(1);
    DeploymentOptions options = new DeploymentOptions().setInstances(1);
    options.setConfig(new JsonObject().put("host", HOST));
    // Deploy the module - the System property `vertx.modulename` will contain the name of the module so you
    // don't have to hardecode it in your tests
    getVertx().deployVerticle("org.jacpfx.vertx.entrypoint.ServiceEntryPoint",options, asyncResult -> {
        // Deployment is asynchronous and this this handler will be called when it's complete (or failed)
        System.out.println("start org.jacpfx.vertx.entrypoint.ServiceEntryPoint: " + asyncResult.succeeded());
        assertTrue(asyncResult.succeeded());
        assertNotNull("deploymentID should not be null", asyncResult.result());
        // If deployed correctly then start the tests!
        latch.countDown();

    });
    awaitLatch(latch);
    getVertx().deployVerticle(new WsServiceOne(), options, asyncResult -> {
        // Deployment is asynchronous and this this handler will be called when it's complete (or failed)
        System.out.println("start WsServiceOne: " + asyncResult.succeeded());
        assertTrue(asyncResult.succeeded());
        assertNotNull("deploymentID should not be null", asyncResult.result());
        // If deployed correctly then start the tests!
        //   latch2.countDown();

        latch2.countDown();

    });

    client = getVertx().
            createHttpClient(new HttpClientOptions());
    awaitLatch(latch2);

}
 
Example 25
Source Project: vxms   Source File: EventbusBasicTests.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));
  // Deploy the module - the System property `vertx.modulename` will contain the name of the
  // module so you
  // don'failure have to hardecode it in your tests
  WsServiceOne one = new WsServiceOne();
  one.init(vertx, vertx.getOrCreateContext());
  getVertx()
      .deployVerticle(
          one,
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  client = getVertx().createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}
 
Example 26
Source Project: vertx-in-action   Source File: WorkerVerticle.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) {
  Vertx vertx = Vertx.vertx();
  DeploymentOptions opts = new DeploymentOptions()
    .setInstances(2)
    .setWorker(true);
  vertx.deployVerticle("chapter2.worker.WorkerVerticle", opts);
}
 
Example 27
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));
  // Deploy the module - the System property `vertx.modulename` will contain the name of the
  // module so you
  // don'failure have to hardecode it in your tests

  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  client = getVertx().createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}
 
Example 28
@Test
public void testMapCleaned() {
  LocalMap<String, SessionHolder> holders = vertx.sharedData().getLocalMap(CassandraClientImpl.HOLDERS_LOCAL_MAP_NAME);
  int instances = 5;
  vertx.deployVerticle(() -> new SampleVerticle(), new DeploymentOptions().setInstances(instances), onSuccess(id -> {
    assertEquals(instances, holders.get(CLIENT_NAME).refCount);
    vertx.undeploy(id, onSuccess(v -> {
      assertEquals(0, holders.size());
      testComplete();
    }));
  }));
  await();
}
 
Example 29
Source Project: quarkus   Source File: VerticleDeployer.java    License: Apache License 2.0 5 votes vote down vote up
public void init(@Observes StartupEvent ev) {
    CountDownLatch latch = new CountDownLatch(5);
    vertx.deployVerticle(BareVerticle::new, new DeploymentOptions().setConfig(new JsonObject()
            .put("id", "bare")))
            .thenAccept(x -> latch.countDown());

    vertx.deployVerticle(BareVerticle.class.getName(), new DeploymentOptions().setConfig(new JsonObject()
            .put("id", "bare-classname")))
            .thenAccept(x -> latch.countDown());

    vertx.deployVerticle(RxVerticle::new, new DeploymentOptions().setConfig(new JsonObject()
            .put("id", "rx")))
            .thenAccept(x -> latch.countDown());

    vertx.deployVerticle(RxVerticle.class.getName(), new DeploymentOptions().setConfig(new JsonObject()
            .put("id", "rx-classname")))
            .thenAccept(x -> latch.countDown());

    vertx.deployVerticle(MutinyAsyncVerticle::new, new DeploymentOptions().setConfig(new JsonObject()
            .put("id", "mutiny")))
            .thenAccept(x -> latch.countDown());

    vertx.deployVerticle(MutinyAsyncVerticle.class.getName(), new DeploymentOptions().setConfig(new JsonObject()
            .put("id", "mutiny-classname")))
            .thenAccept(x -> latch.countDown());
    latch.countDown();
}
 
Example 30
Source Project: vxms   Source File: RESTServiceSelfhostedTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {

  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);
  options.setConfig(new JsonObject().put("clustered", false).put("host", HOST));
  // Deploy the module - the System property `vertx.modulename` will contain the name of the
  // module so you
  // don'failure have to hardecode it in your tests

  getVertx()
      .deployVerticle(
          new WsServiceOne(),
          options,
          asyncResult -> {
            // Deployment is asynchronous and this this handler will be called when it's complete
            // (or failed)
            System.out.println("start service: " + asyncResult.succeeded());
            assertTrue(asyncResult.succeeded());
            assertNotNull("deploymentID should not be null", asyncResult.result());
            // If deployed correctly then start the tests!
            //   latch2.countDown();

            latch2.countDown();
          });

  client = getVertx().createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}