Search in sources :

Example 11 with FilesystemResourceStorageDao

use of org.opennms.netmgt.dao.support.FilesystemResourceStorageDao in project opennms by OpenNMS.

the class ThresholdingVisitorIT method setUp.

@Before
public void setUp() throws Exception {
    // Resets Counters Cache Data
    CollectionResourceWrapper.s_cache.clear();
    MockLogAppender.setupLogging();
    m_fileAnticipator = new FileAnticipator();
    m_hrStorageProperties = new HashMap<Integer, File>();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(new File(m_fileAnticipator.getTempDir(), "snmp"));
    m_filterDao = EasyMock.createMock(FilterDao.class);
    EasyMock.expect(m_filterDao.getActiveIPAddressList((String) EasyMock.anyObject())).andReturn(Collections.singletonList(addr("127.0.0.1"))).anyTimes();
    m_filterDao.flushActiveIpAddressListCache();
    EasyMock.expectLastCall().anyTimes();
    FilterDaoFactory.setInstance(m_filterDao);
    EasyMock.replay(m_filterDao);
    m_anticipator = new EventAnticipator();
    MockEventIpcManager eventMgr = new MockEventIpcManager();
    eventMgr.setEventAnticipator(m_anticipator);
    eventMgr.setSynchronous(true);
    EventIpcManager eventdIpcMgr = (EventIpcManager) eventMgr;
    EventIpcManagerFactory.setIpcManager(eventdIpcMgr);
    DateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
    StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
    sb.append("<outages>");
    sb.append("<outage name=\"junit outage\" type=\"specific\">");
    sb.append("<time begins=\"");
    sb.append(formatter.format(new Date(System.currentTimeMillis() - 3600000)));
    sb.append("\" ends=\"");
    sb.append(formatter.format(new Date(System.currentTimeMillis() + 3600000)));
    sb.append("\"/>");
    sb.append("<interface address=\"match-any\"/>");
    sb.append("</outage>");
    sb.append("</outages>");
    File file = new File("target/poll-outages.xml");
    FileWriter writer = new FileWriter(file);
    writer.write(sb.toString());
    writer.close();
    PollOutagesConfigFactory.setInstance(new PollOutagesConfigFactory(new FileSystemResource(file)));
    PollOutagesConfigFactory.getInstance().afterPropertiesSet();
    initFactories("/threshd-configuration.xml", "/test-thresholds.xml");
    m_anticipatedEvents = new ArrayList<Event>();
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) FileWriter(java.io.FileWriter) PollOutagesConfigFactory(org.opennms.netmgt.config.PollOutagesConfigFactory) FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) FileSystemResource(org.springframework.core.io.FileSystemResource) Date(java.util.Date) EventAnticipator(org.opennms.netmgt.dao.mock.EventAnticipator) BigInteger(java.math.BigInteger) FilterDao(org.opennms.netmgt.filter.api.FilterDao) JdbcFilterDao(org.opennms.netmgt.filter.JdbcFilterDao) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Event(org.opennms.netmgt.xml.event.Event) FileAnticipator(org.opennms.test.FileAnticipator) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Before(org.junit.Before)

Example 12 with FilesystemResourceStorageDao

use of org.opennms.netmgt.dao.support.FilesystemResourceStorageDao in project opennms by OpenNMS.

the class NodeLevelDataOnMultipleNodesTest method setUp.

/**
     * Sets the up.
     *
     * @throws Exception the exception
     */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_rrdStrategy = getRrdStrategy();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(m_temporaryFolder.getRoot());
    m_temporaryFolder.newFolder("snmp");
    m_persisterFactory = new RrdPersisterFactory();
    m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
    m_persisterFactory.setRrdStrategy(m_rrdStrategy);
    m_eventProxy = EasyMock.createMock(EventProxy.class);
    m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb();
    Resource resource = new FileSystemResource(getXmlConfigFileName());
    m_xmlCollectionDao.setConfigResource(resource);
    m_xmlCollectionDao.afterPropertiesSet();
    m_collector = new XmlCollector();
    m_collector.setXmlCollectionDao(m_xmlCollectionDao);
    EasyMock.replay(m_eventProxy);
}
Also used : FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) RrdPersisterFactory(org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory) FileSystemResource(org.springframework.core.io.FileSystemResource) XmlDataCollectionConfigDaoJaxb(org.opennms.protocols.xml.dao.jaxb.XmlDataCollectionConfigDaoJaxb) EventProxy(org.opennms.netmgt.events.api.EventProxy) Before(org.junit.Before)

Example 13 with FilesystemResourceStorageDao

use of org.opennms.netmgt.dao.support.FilesystemResourceStorageDao in project opennms by OpenNMS.

the class PollableServiceConfigTest method testPollableServiceConfig.

@Test
public void testPollableServiceConfig() throws Exception {
    final FilterDao fd = mock(FilterDao.class);
    FilterDaoFactory.setInstance(fd);
    InputStream is = new FileInputStream(new File("src/test/resources/etc/psm-poller-configuration.xml"));
    PollerConfigFactory factory = new PollerConfigFactory(0, is, "localhost", false);
    PollerConfigFactory.setInstance(factory);
    IOUtils.closeQuietly(is);
    PersisterFactory persisterFactory = new MockPersisterFactory();
    ResourceStorageDao resourceStorageDao = new FilesystemResourceStorageDao();
    final PollContext context = mock(PollContext.class);
    final PollableNetwork network = new PollableNetwork(context);
    final PollableNode node = network.createNodeIfNecessary(1, "foo", null);
    final PollableInterface iface = new PollableInterface(node, InetAddressUtils.addr("127.0.0.1"));
    final PollableService svc = new PollableService(iface, "MQ_API_DirectRte_v2");
    final PollOutagesConfig pollOutagesConfig = mock(PollOutagesConfig.class);
    final Package pkg = factory.getPackage("MapQuest");
    final Timer timer = mock(Timer.class);
    final PollableServiceConfig psc = new PollableServiceConfig(svc, factory, pollOutagesConfig, pkg, timer, persisterFactory, resourceStorageDao, m_locationAwarePollerClient);
    PollStatus pollStatus = psc.poll();
    assertThat(pollStatus.getReason(), not(containsString("Unexpected exception")));
}
Also used : FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) ResourceStorageDao(org.opennms.netmgt.dao.api.ResourceStorageDao) PollStatus(org.opennms.netmgt.poller.PollStatus) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MockPersisterFactory(org.opennms.netmgt.mock.MockPersisterFactory) PersisterFactory(org.opennms.netmgt.collection.api.PersisterFactory) FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) FileInputStream(java.io.FileInputStream) FilterDao(org.opennms.netmgt.filter.api.FilterDao) PollerConfigFactory(org.opennms.netmgt.config.PollerConfigFactory) Timer(org.opennms.netmgt.scheduler.Timer) MockPersisterFactory(org.opennms.netmgt.mock.MockPersisterFactory) Package(org.opennms.netmgt.config.poller.Package) File(java.io.File) PollOutagesConfig(org.opennms.netmgt.config.PollOutagesConfig) Test(org.junit.Test)

Example 14 with FilesystemResourceStorageDao

use of org.opennms.netmgt.dao.support.FilesystemResourceStorageDao in project opennms by OpenNMS.

the class LatencyStoringServiceMonitorAdaptorPersistenceTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(m_tempFolder.newFolder("response"));
    m_persisterFactory = new RrdPersisterFactory();
    m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
    m_rrdStrategy = EasyMock.createMock(RrdStrategy.class);
    m_persisterFactory.setRrdStrategy(m_rrdStrategy);
}
Also used : FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) RrdPersisterFactory(org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory) RrdStrategy(org.opennms.netmgt.rrd.RrdStrategy) Before(org.junit.Before)

Aggregations

FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)14 Before (org.junit.Before)11 JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)8 File (java.io.File)6 RrdPersisterFactory (org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory)6 OnmsNode (org.opennms.netmgt.model.OnmsNode)6 FileSystemResource (org.springframework.core.io.FileSystemResource)6 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)4 MockCollectionAgent (org.opennms.core.collection.test.MockCollectionAgent)3 FilterDao (org.opennms.netmgt.filter.api.FilterDao)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 FileAnticipator (org.opennms.test.FileAnticipator)3 FileWriter (java.io.FileWriter)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 DefaultDataCollectionConfigDao (org.opennms.netmgt.config.DefaultDataCollectionConfigDao)2 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)2 NodeDao (org.opennms.netmgt.dao.api.NodeDao)2 EventProxy (org.opennms.netmgt.events.api.EventProxy)2