Esempio n. 1
0
  /** 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<String>();
    attributes.add("CollectionCount");
    attributes.add("LastGcInfo");
    beanInfo.setAttributes(attributes);

    List<String> compositeAttributes = new ArrayList<String>();
    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());
    // ToDo Tak set the JmxDataSource type to composite?
    dataSourceMap.put(mBeansObjectName + "|LastGcInfo", new JMXDataSource());

    jmxNodeInfo.setDsMap(dataSourceMap);
    CollectionSet collectionSet = jmxCollector.collect(collectionAgent, null, null);
    assertEquals(
        "Collection of one Jvm default value run successfully", 1, collectionSet.getStatus());
  }
Esempio n. 2
0
 /** This test is just a prove of concept. */
 @Test
 public void collectTwoBasicValues() {
   String mBeansObjectName = "org.opennms.netmgt.collectd.jmxhelper:type=JmxTest";
   Map<String, BeanInfo> mBeans = new HashMap<String, BeanInfo>();
   BeanInfo beanInfo = new BeanInfo();
   beanInfo.setObjectName(mBeansObjectName);
   List<String> attributes = new ArrayList<String>();
   attributes.add("X");
   attributes.add("Name");
   // TODO Tak: Test attributes that will return null is the next step
   //        attributes.add("NullString");
   beanInfo.setAttributes(attributes);
   mBeans.put("first", beanInfo);
   jmxNodeInfo.setMBeans(mBeans);
   Map<String, JMXDataSource> dataSourceMap = new HashMap<String, JMXDataSource>();
   dataSourceMap.put(mBeansObjectName + "|X", new JMXDataSource());
   dataSourceMap.put(mBeansObjectName + "|Name", new JMXDataSource());
   //        dataSourceMap.put("org.opennms.netmgt.collectd.jmxhelper:type=JmxTest|NullString", new
   // JMXDataSource());
   jmxNodeInfo.setDsMap(dataSourceMap);
   CollectionSet collectionSet = jmxCollector.collect(collectionAgent, null, null);
   assertEquals("Collection of two dummy values run successfully", 1, collectionSet.getStatus());
 }