Search in sources :

Example 1 with MetricsBootstrapConfig

use of org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig in project incubator-servicecomb-java-chassis by apache.

the class TestDefaultLogPublisher method init_enabled_false.

@Test
public void init_enabled_false() {
    Holder<Boolean> registered = new Holder<>();
    new MockUp<EventBus>(eventBus) {

        @Mock
        void register(Object object) {
            registered.value = true;
        }
    };
    ArchaiusUtils.setProperty(DefaultLogPublisher.ENABLED, false);
    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
    Assert.assertNull(registered.value);
}
Also used : MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) Holder(javax.xml.ws.Holder) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 2 with MetricsBootstrapConfig

use of org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig in project java-chassis by ServiceComb.

the class TestDefaultLogPublisher method init_enabled_true.

@Test
public void init_enabled_true() {
    Holder<Boolean> registered = new Holder<>();
    new MockUp<EventBus>(eventBus) {

        @Mock
        void register(Object object) {
            registered.value = true;
        }
    };
    ArchaiusUtils.setProperty(DefaultLogPublisher.ENABLED, true);
    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
    Assert.assertTrue(registered.value);
}
Also used : MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) Holder(org.apache.servicecomb.foundation.common.Holder) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 3 with MetricsBootstrapConfig

use of org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig in project java-chassis by ServiceComb.

the class TestMetricsRestPublisher method measure_normal.

@Test
public void measure_normal() {
    Clock clock = new ManualClock();
    GlobalRegistry globalRegistry = new GlobalRegistry();
    Registry registry = new DefaultRegistry(clock);
    registry.timer(registry.createId("name", "t1", "v1", "t2", "v2"));
    globalRegistry.add(registry);
    EventBus eventBus = new EventBus();
    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
    Map<String, Double> result = publisher.measure();
    Assert.assertEquals(2, result.size());
    Assert.assertEquals(0, result.get("name(statistic=count,t1=v1,t2=v2)"), 0);
    Assert.assertEquals(0, result.get("name(statistic=totalTime,t1=v1,t2=v2)"), 0);
}
Also used : ManualClock(com.netflix.spectator.api.ManualClock) GlobalRegistry(org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry) MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) GlobalRegistry(org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry) Registry(com.netflix.spectator.api.Registry) EventBus(com.google.common.eventbus.EventBus) ManualClock(com.netflix.spectator.api.ManualClock) Clock(com.netflix.spectator.api.Clock) Test(org.junit.Test)

Example 4 with MetricsBootstrapConfig

use of org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig in project incubator-servicecomb-java-chassis by apache.

the class TestDefaultLogPublisher method init_enabled_default.

@Test
public void init_enabled_default() {
    Holder<Boolean> registered = new Holder<>();
    new MockUp<EventBus>(eventBus) {

        @Mock
        void register(Object object) {
            registered.value = true;
        }
    };
    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
    Assert.assertTrue(registered.value);
}
Also used : MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) Holder(javax.xml.ws.Holder) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 5 with MetricsBootstrapConfig

use of org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig in project incubator-servicecomb-java-chassis by apache.

the class TestDefaultLogPublisher method init_enabled_true.

@Test
public void init_enabled_true() {
    Holder<Boolean> registered = new Holder<>();
    new MockUp<EventBus>(eventBus) {

        @Mock
        void register(Object object) {
            registered.value = true;
        }
    };
    ArchaiusUtils.setProperty(DefaultLogPublisher.ENABLED, true);
    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
    Assert.assertTrue(registered.value);
}
Also used : MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) Holder(javax.xml.ws.Holder) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

MetricsBootstrapConfig (org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig)10 Test (org.junit.Test)9 MockUp (mockit.MockUp)8 EventBus (com.google.common.eventbus.EventBus)4 Holder (org.apache.servicecomb.foundation.common.Holder)4 Holder (javax.xml.ws.Holder)3 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)2 ManualClock (com.netflix.spectator.api.ManualClock)2 Registry (com.netflix.spectator.api.Registry)2 Expectations (mockit.Expectations)2 GlobalRegistry (org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry)2 Clock (com.netflix.spectator.api.Clock)1 CompositeRegistry (com.netflix.spectator.api.CompositeRegistry)1 Measurement (com.netflix.spectator.api.Measurement)1 VertxImpl (io.vertx.core.impl.VertxImpl)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Status (javax.ws.rs.core.Response.Status)1