Java Code Examples for io.vertx.core.Vertx#vertx()

The following examples show how to use io.vertx.core.Vertx#vertx() . 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 File: RouteExtensionTest.java    From weld-vertx with Apache License 2.0 6 votes vote down vote up
@Before
public void init(TestContext context) throws InterruptedException {
    weld = new Weld().disableDiscovery().addExtension(new RouteExtension()).beanClasses(HelloHandler.class, SayHelloService.class).initialize();
    vertx = Vertx.vertx();
    Async async = context.async();
    Router router = Router.router(vertx);
    weld.select(RouteExtension.class).get().registerRoutes(router);
    router.route().handler(BodyHandler.create());
    vertx.createHttpServer().requestHandler(router::accept).listen(8080, (r) -> {
        if (r.succeeded()) {
            async.complete();
        } else {
            context.fail(r.cause());
        }
    });
}
 
Example 2
Source File: SchemaRegistrationTest.java    From vertx-graphql-service-discovery with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    vertx = Vertx.vertx();
    options = new ServiceDiscoveryOptions().setName("theDiscovery")
            .setAnnounceAddress("theAnnounceAddress").setUsageAddress("theUsageAddress");
    discovery = ServiceDiscovery.create(vertx, options);
    record = new Record()
            .setName("theRecord")
            .setType(Queryable.SERVICE_TYPE)
            .setMetadata(new JsonObject().put("publisherId", "thePublisherId"))
            .setLocation(new JsonObject().put(Record.ENDPOINT, Queryable.ADDRESS_PREFIX + ".DroidQueries"))
            .setStatus(Status.UP);
    definition = SchemaDefinition.createInstance(droidsSchema,
            SchemaMetadata.create(new JsonObject().put("publisherId", "thePublisherId")));
    consumer = ProxyHelper.registerService(Queryable.class,
            vertx, definition, Queryable.ADDRESS_PREFIX + ".DroidQueries");
}
 
Example 3
Source File: Application.java    From skywalking with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    //ensures .vertx files are uncreated/deleted
    System.setProperty("vertx.disableFileCPResolving", "true");
    Vertx vertx = Vertx.vertx();
    if (new File(".vertx").exists()) {
        Files.walk(new File(".vertx").toPath())
                .sorted(Comparator.reverseOrder())
                .map(Path::toFile)
                .forEach(File::delete);
    }

    vertx.deployVerticle(new VertxWebController(), it -> {
        if (it.failed()) {
            it.cause().printStackTrace();
            System.exit(-1);
        }
    });
}
 
Example 4
Source File: HttpEndpointTest.java    From vertx-service-discovery with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  vertx = Vertx.vertx();
  discovery = new DiscoveryImpl(vertx, new ServiceDiscoveryOptions());

  Router router = Router.router(vertx);
  router.get("/foo").handler(ctxt -> {
    ctxt.response().end("hello");
  });

  AtomicBoolean done = new AtomicBoolean();
  vertx.createHttpServer().requestHandler(router).listen(8080, ar -> {
    done.set(ar.succeeded());
  });

  await().untilAtomic(done, is(true));
}
 
Example 5
Source File: CleanupTest.java    From vertx-kafka-client with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeTest() {
  vertx = Vertx.vertx();

  // Capture thread counts, so tests that don't cleanup properly won't fail correct tests
  numKafkaProducerNetworkThread = countThreads("kafka-producer-network-thread");
  numKafkaConsumerNetworkThread = countThreads("kafka-consumer-network-thread");
  numKafkaConsumerNetworkThread = countThreads("vert.x-kafka-consumer-thread");
}
 
Example 6
Source File: HystrixDashboardProxyEurekaAppsListingHandlerTest.java    From standalone-hystrix-dashboard with MIT License 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
  vertx = Vertx.vertx();
  proxyEurekaAppsListingHandler = HystrixDashboardProxyEurekaAppsListingHandler.create(vertx);
  routingContext = mock(RoutingContext.class);
  serverRequest = mock(HttpServerRequest.class);
  serverResponse = mock(HttpServerResponse.class);

  when(routingContext.request()).thenReturn(serverRequest);
  when(routingContext.response()).thenReturn(serverResponse);
}
 
Example 7
Source File: RedisConfigStoreTest.java    From vertx-config with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp(TestContext tc) throws IOException {
  vertx = Vertx.vertx();
  vertx.exceptionHandler(tc.exceptionHandler());

  redisServer = new RedisServer(6379);
  redisServer.start();

  redis = Redis.createClient(vertx, "redis://localhost:6379");
}
 
Example 8
Source File: MqttEventChannelTestCase.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Before
public void start() throws Exception {
    vertx = Vertx.vertx();
    session = MqttClient.create(vertx);
    CountDownLatch latch = new CountDownLatch(1);
    session.connect(1883, "localhost", (connect) -> {
        latch.countDown();
    });
    latch.await();
}
 
Example 9
Source File: Main.java    From vertx-in-action with MIT License 5 votes vote down vote up
public static void main(String[] args) {
  Vertx vertx = Vertx.vertx();
  vertx.deployVerticle("chapter3.HeatSensor", new DeploymentOptions().setInstances(4));
  vertx.deployVerticle("chapter3.Listener");
  vertx.deployVerticle("chapter3.SensorData");
  vertx.deployVerticle("chapter3.HttpServer");
}
 
Example 10
Source File: InboundEndpointTest.java    From vertx-camel-bridge with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  vertx = Vertx.vertx();
  camel = new DefaultCamelContext();
}
 
Example 11
Source File: VertxGraphqlTest.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BeforeAll
public static void initializeVertx() {
    vertx = Vertx.vertx();
}
 
Example 12
Source File: MSSQLPreparedQueryPooledTest.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public void setUp(TestContext ctx) throws Exception {
  vertx = Vertx.vertx();
  initConnector();
  cleanTestTable(ctx); // need to use batch instead of prepared statements
}
 
Example 13
Source File: RunBootedTestOnContextRx.java    From sfs with Apache License 2.0 4 votes vote down vote up
public RunBootedTestOnContextRx(VertxOptions options) {
    this(() -> Vertx.vertx(options));
}
 
Example 14
Source File: VaultClientTest.java    From vertx-config with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
  vertx = Vertx.vertx();
  client = new SlimVaultClient(vertx, process.getConfigurationWithRootToken());
}
 
Example 15
Source File: BesuCommand.java    From besu with Apache License 2.0 4 votes vote down vote up
protected Vertx createVertx(final VertxOptions vertxOptions) {
  return Vertx.vertx(vertxOptions);
}
 
Example 16
Source File: Exercise4.java    From vertx-kubernetes-workshop with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    Vertx vertx = Vertx.vertx();
    vertx.deployVerticle(Exercise4SenderVerticle.class.getName());
    vertx.deployVerticle(Exercise4ReceiverVerticle.class.getName());
}
 
Example 17
Source File: KafkaConnectAssemblyOperatorMockTest.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@BeforeAll
public static void before() {
    vertx = Vertx.vertx();
}
 
Example 18
Source File: SessionStoreAdapterIT.java    From vertx-vaadin with MIT License 4 votes vote down vote up
@Before
public void setUp(TestContext context) {
    vertx = Vertx.vertx();
    testVerticle = new SessionTestVerticle();
    vertx.deployVerticle(testVerticle, context.asyncAssertSuccess());
}
 
Example 19
Source File: TestRunner.java    From vertx-deploy-tools with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    System.setProperty(DISABLE_CP_RESOLVING_PROP_NAME, TRUE.toString());
    Vertx vertx = Vertx.vertx();
    vertx.deployVerticle("nl.jpoint.vertx.mod.test.DeployTestApplication");
}
 
Example 20
Source File: DiscoveryRegistrarTest.java    From vertx-graphql-service-discovery with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    vertx = Vertx.vertx();
}