use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class EventconfFactoryIT method loadConfiguration.
private DefaultEventConfDao loadConfiguration(String relativeResourcePath, boolean passFile) throws DataAccessException, IOException {
DefaultEventConfDao dao = new DefaultEventConfDao();
if (passFile) {
URL url = getUrlForRelativeResourcePath(relativeResourcePath);
dao.setConfigResource(new MockFileSystemResourceWithInputStream(new File(url.getFile()), getFilteredInputStreamForConfig(relativeResourcePath)));
} else {
dao.setConfigResource(new InputStreamResource(getFilteredInputStreamForConfig(relativeResourcePath)));
}
dao.afterPropertiesSet();
return dao;
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class XmlDataCollectionConfigDaoJaxbTest method testAfterPropertiesSetWithNestedFiles.
/**
* Test after properties set with nested files (external references to XML groups).
*
* @throws Exception the exception
*/
@Test
public void testAfterPropertiesSetWithNestedFiles() throws Exception {
System.setProperty("opennms.home", "src/test/resources");
XmlDataCollectionConfigDaoJaxb dao = new XmlDataCollectionConfigDaoJaxb();
File xmlCollectionConfig = new File("src/test/resources/etc", XmlDataCollectionConfig.XML_DATACOLLECTION_CONFIG_FILE);
assertTrue(XmlDataCollectionConfig.XML_DATACOLLECTION_CONFIG_FILE + " is readable", xmlCollectionConfig.canRead());
InputStream in = new FileInputStream(xmlCollectionConfig);
dao.setConfigResource(new InputStreamResource(in));
dao.afterPropertiesSet();
XmlDataCollectionConfig config = dao.getConfig();
Assert.assertNotNull("xml data collection should not be null", config);
Assert.assertEquals(2, config.getXmlDataCollections().get(0).getXmlSources().get(0).getXmlGroups().size());
Assert.assertEquals(5, config.getXmlDataCollections().get(1).getXmlSources().get(0).getXmlGroups().size());
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDaoIT method instantiateDao.
private DefaultDataCollectionConfigDao instantiateDao(String fileName, boolean setConfigDirectory) throws Exception {
DefaultDataCollectionConfigDao dao = new DefaultDataCollectionConfigDao();
File configFile = new File("src/test/opennms-home/etc", fileName);
if (setConfigDirectory) {
File configFolder = new File(configFile.getParentFile(), "datacollection");
Assert.assertTrue(configFolder.isDirectory());
dao.setConfigDirectory(configFolder.getAbsolutePath());
}
dao.setConfigResource(new InputStreamResource(new FileInputStream(configFile)));
dao.afterPropertiesSet();
return dao;
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DefaultStatisticsDaemonConfigDaoTest method testAfterPropertiesSetWithGoodConfigFile.
public void testAfterPropertiesSetWithGoodConfigFile() throws Exception {
DefaultStatisticsDaemonConfigDao dao = new DefaultStatisticsDaemonConfigDao();
InputStream in = ConfigurationTestUtils.getInputStreamForConfigFile("statsd-configuration.xml");
dao.setConfigResource(new InputStreamResource(in));
dao.afterPropertiesSet();
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DefaultSurveillanceViewConfigDaoIT method createDaoWithConfigFile.
private void createDaoWithConfigFile(final String configFileName) throws IOException {
Resource resource = new InputStreamResource(ConfigurationTestUtils.getInputStreamForConfigFile(configFileName));
m_dao = new DefaultSurveillanceViewConfigDao();
m_dao.setConfigResource(resource);
m_dao.afterPropertiesSet();
}
Aggregations