Search in sources :

Example 1 with FakeVertxMetrics

use of io.vertx.test.fakemetrics.FakeVertxMetrics in project vert.x by eclipse.

the class MetricsOptionsTest method testMetricsFromServiceLoader.

@Test
public void testMetricsFromServiceLoader() {
    vertx.close();
    MetricsOptions metricsOptions = new MetricsOptions().setEnabled(true);
    VertxOptions options = new VertxOptions().setMetricsOptions(metricsOptions);
    vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
    VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
    assertNotNull(metrics);
    assertTrue(metrics instanceof FakeVertxMetrics);
    assertEquals(metricsOptions.isEnabled(), ((FakeVertxMetrics) metrics).options().isEnabled());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxInternal(io.vertx.core.impl.VertxInternal) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 2 with FakeVertxMetrics

use of io.vertx.test.fakemetrics.FakeVertxMetrics in project vert.x by eclipse.

the class MetricsOptionsTest method testMetricsFromServiceLoader.

@Test
public void testMetricsFromServiceLoader() {
    vertx.close();
    VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true));
    vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
    VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
    assertNotNull(metrics);
    assertTrue(metrics instanceof FakeVertxMetrics);
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) VertxInternal(io.vertx.core.impl.VertxInternal) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 3 with FakeVertxMetrics

use of io.vertx.test.fakemetrics.FakeVertxMetrics in project vert.x by eclipse.

the class VertxFactoryTest method testFactoryMetricsOverridesMetaInf.

@Test
public void testFactoryMetricsOverridesMetaInf() {
    runWithServiceFromMetaInf(VertxMetricsFactory.class, FakeVertxMetrics.class.getName(), () -> {
        FakeVertxMetrics metrics = new FakeVertxMetrics();
        MetricsOptions metricsOptions = new MetricsOptions().setEnabled(true);
        VertxBuilder factory = new VertxBuilder(new VertxOptions().setMetricsOptions(metricsOptions));
        factory.metrics(metrics);
        factory.init();
        Vertx vertx = factory.vertx();
        assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
    });
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 4 with FakeVertxMetrics

use of io.vertx.test.fakemetrics.FakeVertxMetrics in project vert.x by eclipse.

the class VertxFactoryTest method testFactoryMetricsFactoryOverridesOptions.

@Test
public void testFactoryMetricsFactoryOverridesOptions() {
    FakeVertxMetrics metrics = new FakeVertxMetrics();
    MetricsOptions metricsOptions = new MetricsOptions().setEnabled(true).setFactory(options -> {
        throw new AssertionError();
    });
    VertxBuilder factory = new VertxBuilder(new VertxOptions().setMetricsOptions(metricsOptions));
    factory.metrics(metrics);
    factory.init();
    Vertx vertx = factory.vertx();
    assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Aggregations

VertxOptions (io.vertx.core.VertxOptions)4 MetricsOptions (io.vertx.core.metrics.MetricsOptions)4 FakeVertxMetrics (io.vertx.test.fakemetrics.FakeVertxMetrics)4 Test (org.junit.Test)4 Vertx (io.vertx.core.Vertx)2 VertxInternal (io.vertx.core.impl.VertxInternal)2 DummyVertxMetrics (io.vertx.core.metrics.impl.DummyVertxMetrics)2 VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)1