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());
}