Search in sources :

Example 11 with JmxResultProcessor

use of com.googlecode.jmxtrans.model.JmxResultProcessor in project jmxtrans by jmxtrans.

the class JmxResultProcessorTest method canReadSingleIntegerValue.

@Test
public void canReadSingleIntegerValue() throws MalformedObjectNameException, InstanceNotFoundException {
    Attribute integerAttribute = new Attribute("CollectionCount", 51L);
    ObjectInstance runtime = getRuntime();
    List<Result> results = new JmxResultProcessor(dummyQueryWithResultAlias(), runtime, ImmutableList.of(integerAttribute), runtime.getClassName(), TEST_DOMAIN_NAME).getResults();
    assertThat(results).hasSize(1);
    Result integerResult = results.get(0);
    assertThat(integerResult.getAttributeName()).isEqualTo("CollectionCount");
    assertThat(integerResult.getValue()).isInstanceOf(Long.class);
    assertThat(integerResult.getValue()).isEqualTo(51L);
}
Also used : Attribute(javax.management.Attribute) ObjectInstance(javax.management.ObjectInstance) JmxResultProcessor(com.googlecode.jmxtrans.model.JmxResultProcessor) Result(com.googlecode.jmxtrans.model.Result) Test(org.junit.Test)

Aggregations

JmxResultProcessor (com.googlecode.jmxtrans.model.JmxResultProcessor)11 Result (com.googlecode.jmxtrans.model.Result)11 ObjectInstance (javax.management.ObjectInstance)11 Test (org.junit.Test)11 Attribute (javax.management.Attribute)7 AttributeList (javax.management.AttributeList)4 InstanceNotFoundException (javax.management.InstanceNotFoundException)1