Search in sources :

Example 1 with BeanInfo

use of org.opennms.netmgt.config.BeanInfo in project opennms by OpenNMS.

the class JMXCollectorTest method collectJvmDefaultComposites.

/**
 * Check if CompositeAttributes will be collected
 */
@Test
public void collectJvmDefaultComposites() {
    String mBeansObjectName = "java.lang:type=GarbageCollector,name=PS MarkSweep";
    Map<String, BeanInfo> mBeans = new HashMap<String, BeanInfo>();
    BeanInfo beanInfo = new BeanInfo();
    beanInfo.setObjectName(mBeansObjectName);
    List<String> attributes = new ArrayList<>();
    attributes.add("CollectionCount");
    attributes.add("LastGcInfo");
    beanInfo.setAttributes(attributes);
    List<String> compositeAttributes = new ArrayList<>();
    compositeAttributes.add("LastGcInfo");
    beanInfo.setCompositeAttributes(compositeAttributes);
    mBeans.put("first", beanInfo);
    jmxNodeInfo.setMBeans(mBeans);
    Map<String, JMXDataSource> dataSourceMap = new HashMap<String, JMXDataSource>();
    dataSourceMap.put(mBeansObjectName + "|CollectionCount", new JMXDataSource());
    dataSourceMap.put(mBeansObjectName + "|LastGcInfo", new JMXDataSource());
    jmxNodeInfo.setDsMap(dataSourceMap);
    CollectionSet collectionSet = jmxCollector.collect(collectionAgent, Collections.emptyMap());
    assertEquals("Collection of one Jvm default value failed", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
}
Also used : HashMap(java.util.HashMap) BeanInfo(org.opennms.netmgt.config.BeanInfo) ArrayList(java.util.ArrayList) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) JmxTest(org.opennms.netmgt.collectd.jmxhelper.JmxTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 JmxTest (org.opennms.netmgt.collectd.jmxhelper.JmxTest)1 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)1 BeanInfo (org.opennms.netmgt.config.BeanInfo)1