use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class JmxReporterTest method registersMBeansForMetricObjectsUsingProvidedObjectNameFactory.
@Test
public void registersMBeansForMetricObjectsUsingProvidedObjectNameFactory() throws Exception {
ObjectName n = new ObjectName(name + ":name=dummy");
try {
String widgetName = "something";
when(mockObjectNameFactory.createName(any(String.class), any(String.class), any(MetricName.class))).thenReturn(n);
Gauge aGauge = mock(Gauge.class);
when(aGauge.getValue()).thenReturn(1);
JmxReporter reporter = JmxReporter.forRegistry(registry).registerWith(mBeanServer).inDomain(name).createsObjectNamesWith(mockObjectNameFactory).build();
registry.register(widgetName, aGauge);
reporter.start();
verify(mockObjectNameFactory).createName(eq("gauges"), any(String.class), eq(MetricName.build("something")));
// verifyNoMoreInteractions(mockObjectNameFactory);
} finally {
reporter.stop();
if (mBeanServer.isRegistered(n)) {
mBeanServer.unregisterMBean(n);
}
}
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class JvmAttributeGaugeSetTest method hasAGaugeForTheJVMVendor.
@Test
public void hasAGaugeForTheJVMVendor() throws Exception {
final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("vendor"));
assertThat(gauge.getValue()).isEqualTo("Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 23.7-b01 (1.7)");
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class JvmAttributeGaugeSetTest method autoDiscoversTheRuntimeBean.
@Test
public void autoDiscoversTheRuntimeBean() throws Exception {
final Gauge gauge = (Gauge) new JvmAttributeGaugeSet().getMetrics().get(MetricName.build("uptime"));
assertThat((Long) gauge.getValue()).isPositive();
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class JvmAttributeGaugeSetTest method hasAGaugeForTheJVMName.
@Test
public void hasAGaugeForTheJVMName() throws Exception {
final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("name"));
assertThat(gauge.getValue()).isEqualTo("9928@example.com");
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class Slf4jReporterTest method gauge.
private <T> Gauge gauge(T value) {
final Gauge gauge = mock(Gauge.class);
when(gauge.getValue()).thenReturn(value);
return gauge;
}
Aggregations