use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class JMXDataCollectionConfigDao method translateConfig.
@Override
public JmxDatacollectionConfig translateConfig(JmxDatacollectionConfig config) {
for (JmxCollection collection : config.getJmxCollectionList()) {
if (collection.hasImportMbeans()) {
for (String importMbeans : collection.getImportGroupsList()) {
final File file = getOpennmsHome().resolve(Paths.get("etc", importMbeans)).toFile();
LOG.debug("parseJmxMbeans: parsing {}", file);
final Mbeans mbeans = JaxbUtils.unmarshal(Mbeans.class, new FileSystemResource(file));
collection.addMbeans(mbeans.getMbeanList());
}
}
}
return config;
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method createRequisition.
private Requisition createRequisition() throws Exception {
FileSystemResource resource = new FileSystemResource(getRequisitionFile());
Requisition r = m_foreignSourceRepository.importResourceRequisition(resource);
m_foreignSourceRepository.save(r);
m_foreignSourceRepository.flush();
// Give enough time to watcher's thread to cache the requisition
Thread.sleep(2000);
return r;
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class AccessPointMonitorConfigDaoJaxbTest method testAfterPropertiesSetWithBogusFileResource.
public void testAfterPropertiesSetWithBogusFileResource() throws Exception {
Resource resource = new FileSystemResource("/bogus-file");
AccessPointMonitorConfigDaoJaxb dao = new AccessPointMonitorConfigDaoJaxb();
dao.setConfigResource(resource);
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new MarshallingResourceFailureException(ThrowableAnticipator.IGNORE_MESSAGE));
try {
dao.afterPropertiesSet();
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class WmiPeerFactory method init.
/**
* Load the config from the default config file and create the singleton
* instance of this factory.
*
* @exception java.io.IOException
* Thrown if the specified config file cannot be read
* @throws java.io.IOException
* if any.
*/
public static synchronized void init() throws IOException {
if (m_loaded) {
// to reload, reload() will need to be called
return;
}
WmiPeerFactory factory = new WmiPeerFactory(new FileSystemResource(ConfigFileConstants.getFile(ConfigFileConstants.WMI_CONFIG_FILE_NAME)));
factory.afterPropertiesSet();
setInstance(factory);
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class LatencyThresholdingSetIT method setUp.
@Before
public void setUp() throws Exception {
BeanUtils.setStaticApplicationContext(m_context);
// Resets Counters Cache Data
CollectionResourceWrapper.s_cache.clear();
MockLogAppender.setupLogging();
m_fileAnticipator = new FileAnticipator();
m_resourceStorageDao = new FilesystemResourceStorageDao();
m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
// Use a mock FilterDao that always returns 127.0.0.1 in the active IP list
FilterDao filterDao = EasyMock.createMock(FilterDao.class);
EasyMock.expect(filterDao.getActiveIPAddressList((String) EasyMock.anyObject())).andReturn(Collections.singletonList(addr("127.0.0.1"))).anyTimes();
filterDao.flushActiveIpAddressListCache();
EasyMock.expectLastCall().anyTimes();
FilterDaoFactory.setInstance(filterDao);
EasyMock.replay(filterDao);
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>();
}
Aggregations