/**
   * Executes collector test.
   *
   * @param parameters the parameters
   * @param expectedFiles the expected amount of JRB files
   * @throws Exception the exception
   */
  public void executeCollectorTest(Map<String, Object> parameters, int expectedFiles)
      throws Exception {
    XmlCollector collector = new XmlCollector();
    collector.setXmlCollectionDao(m_xmlCollectionDao);
    collector.initialize(m_collectionAgent, parameters);
    CollectionSet collectionSet = collector.collect(m_collectionAgent, m_eventProxy, parameters);
    collector.release(m_collectionAgent);
    Assert.assertEquals(ServiceCollector.COLLECTION_SUCCEEDED, collectionSet.getStatus());

    ServiceParameters serviceParams = new ServiceParameters(new HashMap<String, Object>());
    BasePersister persister =
        new GroupPersister(
            serviceParams,
            createRrdRepository((String) parameters.get("collection"))); // storeByGroup=true;
    collectionSet.visit(persister);

    Assert.assertEquals(
        expectedFiles,
        FileUtils.listFiles(new File(TEST_SNMP_DIRECTORY), new String[] {"jrb"}, true).size());
  }
예제 #2
0
  /**
   * Executes collector test.
   *
   * @param parameters the parameters
   * @param expectedFiles the expected amount of JRB files
   * @return the collection set
   * @throws Exception the exception
   */
  public CollectionSet executeCollectorTest(Map<String, Object> parameters, int expectedFiles)
      throws Exception {
    XmlCollector collector = new XmlCollector();
    collector.setXmlCollectionDao(m_xmlCollectionDao);
    collector.initialize(m_collectionAgent, parameters);
    CollectionSet collectionSet = collector.collect(m_collectionAgent, m_eventProxy, parameters);
    collector.release(m_collectionAgent);
    Assert.assertEquals(ServiceCollector.COLLECTION_SUCCEEDED, collectionSet.getStatus());

    ServiceParameters serviceParams = new ServiceParameters(new HashMap<String, Object>());
    CollectionSetVisitor persister =
        m_persisterFactory.createGroupPersister(
            serviceParams,
            createRrdRepository((String) parameters.get("collection")),
            false,
            false);
    collectionSet.visit(persister);

    Assert.assertEquals(
        expectedFiles,
        FileUtils.listFiles(getSnmpRootDirectory(), new String[] {getRrdExtension()}, true).size());
    return collectionSet;
  }