Search in sources :

Example 76 with FileSystemResource

use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.

the class DefaultSnmpHwInventoryAdapterConfigDaoTest method initDao.

/**
 * Initialized the DAO
 *
 * @param configFile the configuration file
 * @return the configuration
 * @throws Exception the exception
 */
private void initDao(String configFile) throws Exception {
    File file = new File(configFile);
    Assert.assertTrue(file.exists());
    dao = new DefaultSnmpHwInventoryAdapterConfigDao();
    dao.setConfigResource(new FileSystemResource(file));
    dao.afterPropertiesSet();
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File)

Example 77 with FileSystemResource

use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.

the class DefaultSnmpHwInventoryAdapterConfigDaoTest method emulateReload.

/**
 * Emulate reload.
 *
 * @param fileName the file name
 */
private void emulateReload(String fileName) {
    boolean exception = false;
    try {
        dao.setConfigResource(new FileSystemResource(new File(fileName)));
        dao.afterPropertiesSet();
    } catch (Exception e) {
        System.err.println(e);
        exception = true;
    }
    Assert.assertTrue(exception);
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File)

Example 78 with FileSystemResource

use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.

the class EventFormTest method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    File config = new File(ConfigurationTestUtils.getDaemonEtcDirectory(), "events/MPLS.events.xml");
    Assert.assertTrue(config.exists());
    dao = new DefaultEventConfDao();
    dao.setConfigResource(new FileSystemResource(config));
    dao.afterPropertiesSet();
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) DefaultEventConfDao(org.opennms.netmgt.config.DefaultEventConfDao) File(java.io.File) Before(org.junit.Before)

Example 79 with FileSystemResource

use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.

the class AbstractVTDXmlCollectorTest method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_rrdStrategy = new JRobinRrdStrategy();
    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_collectionAgent = new MockCollectionAgent(1, "mynode.local", InetAddrUtils.addr("127.0.0.1"));
    m_eventProxy = EasyMock.createMock(EventProxy.class);
    m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb();
    Resource resource = new FileSystemResource(getXmlConfigFileName());
    m_xmlCollectionDao.setConfigResource(resource);
    m_xmlCollectionDao.afterPropertiesSet();
    MockDocumentBuilder.setXmlFileName(getXmlSampleFileName());
    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) MockCollectionAgent(org.opennms.core.collection.test.MockCollectionAgent) FileSystemResource(org.springframework.core.io.FileSystemResource) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) XmlDataCollectionConfigDaoJaxb(org.opennms.protocols.xml.dao.jaxb.XmlDataCollectionConfigDaoJaxb) EventProxy(org.opennms.netmgt.events.api.EventProxy) Before(org.junit.Before)

Example 80 with FileSystemResource

use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.

the class BSFNorthbounderConfigDaoIT method setUp.

/**
 * Sets up the test..
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    FileUtils.copyDirectory(new File("src/test/resources/etc"), tempFolder.newFolder("etc"));
    System.setProperty("opennms.home", tempFolder.getRoot().getAbsolutePath());
    // Setup the configuration DAO
    FileSystemResource resource = new FileSystemResource(new File(tempFolder.getRoot(), "etc/bsf-northbounder-config.xml"));
    configDao = new BSFNorthbounderConfigDao();
    configDao.setConfigResource(resource);
    configDao.afterPropertiesSet();
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Before(org.junit.Before)

Aggregations

FileSystemResource (org.springframework.core.io.FileSystemResource)148 File (java.io.File)77 Test (org.junit.Test)44 Resource (org.springframework.core.io.Resource)42 Before (org.junit.Before)27 ClassPathResource (org.springframework.core.io.ClassPathResource)16 IOException (java.io.IOException)12 FileWriter (java.io.FileWriter)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 Properties (java.util.Properties)8 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)8 FileOutputStream (java.io.FileOutputStream)7 URL (java.net.URL)7 InputStreamResource (org.springframework.core.io.InputStreamResource)7 UrlResource (org.springframework.core.io.UrlResource)7 Date (java.util.Date)5 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)5 FileReader (java.io.FileReader)4 OutputStreamWriter (java.io.OutputStreamWriter)4