Search in sources :

Example 81 with FileSystemResource

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

the class BSFNorthbounderIT method setUp.

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

Example 82 with FileSystemResource

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

the class DroolsNorthbounderConfigDaoIT 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/drools-northbounder-config.xml"));
    configDao = new DroolsNorthbounderConfigDao();
    configDao.setConfigResource(resource);
    configDao.afterPropertiesSet();
}
Also used : DroolsNorthbounderConfigDao(org.opennms.netmgt.alarmd.northbounder.drools.DroolsNorthbounderConfigDao) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Before(org.junit.Before)

Example 83 with FileSystemResource

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

the class EmailNorthbounderConfigDaoTest 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/email-northbounder-config.xml"));
    configDao = new EmailNorthbounderConfigDao();
    configDao.setConfigResource(resource);
    configDao.afterPropertiesSet();
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Before(org.junit.Before)

Example 84 with FileSystemResource

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

the class EmailNorthbounderTest method setUp.

/**
 * Sets up the test.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    // Setup the Email northbounder configuration DAO
    System.setProperty("opennms.home", "src/test/resources");
    EmailNorthbounderConfigDao configDao = new EmailNorthbounderConfigDao();
    configDao.setConfigResource(new FileSystemResource(new File("src/test/resources/etc/email-northbounder-config.xml")));
    configDao.afterPropertiesSet();
    // Setup JavaMail configuration DAO
    DefaultJavamailConfigurationDao javaMailDao = new DefaultJavamailConfigurationDao();
    javaMailDao.setConfigResource(new FileSystemResource(new File("src/test/resources/etc/javamail-configuration.xml")));
    javaMailDao.afterPropertiesSet();
    // Setup the trap northbounder (overriding the settings of the first sink to use the test trap receiver)
    nbi = new EmailNorthbounder(configDao, javaMailDao, "google");
    nbi.afterPropertiesSet();
}
Also used : DefaultJavamailConfigurationDao(org.opennms.netmgt.dao.jaxb.DefaultJavamailConfigurationDao) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Before(org.junit.Before)

Example 85 with FileSystemResource

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

the class SnmpTrapNorthbounderConfigDaoTest 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/snmptrap-northbounder-config.xml"));
    configDao = new SnmpTrapNorthbounderConfigDao();
    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