use of org.springframework.core.io.DefaultResourceLoader in project opennms by OpenNMS.
the class DroolsTicketerServiceLayerTest method setUp.
@Before
public void setUp() throws Exception {
m_eventIpcManager = new MockEventIpcManager();
EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
MockLogAppender.setupLogging();
ResourceLoader loader = new DefaultResourceLoader();
Resource resource = loader.getResource("classpath:/drools-ticketer-rules.drl");
m_easyMockUtils = new EasyMockUtils();
m_configDao = m_easyMockUtils.createMock(DroolsTicketerConfigDao.class);
EasyMock.expect(m_configDao.getRulesFile()).andReturn(resource.getFile()).times(1);
EasyMock.replay(m_configDao);
m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
m_droolsTicketerServiceLayer = new DroolsTicketerServiceLayer(m_configDao);
m_droolsTicketerServiceLayer.setAlarmDao(m_alarmDao);
m_droolsTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
EasyMock.reset(m_configDao);
m_alarm = new OnmsAlarm();
m_alarm.setId(1);
m_alarm.setLogMsg("Test Logmsg");
m_alarm.setDescription("Test Description");
m_alarm.setUei("uei.opennms.org/nodes/nodeDown");
m_ticket = new Ticket();
m_ticket.setId("4");
}
use of org.springframework.core.io.DefaultResourceLoader in project opennms by OpenNMS.
the class ProvisionerIT method testProvisionerServiceRescanAfterAddingSnmpNms7838.
// fail if we take more than five minutes
@Test(timeout = 300000)
// Start the test with an empty SNMP agent
@JUnitSnmpAgent(host = "198.51.100.201", port = 161, resource = "classpath:/snmpwalk-empty.properties")
public void testProvisionerServiceRescanAfterAddingSnmpNms7838() throws Exception {
importFromResource("classpath:/requisition_then_scan2.xml", Boolean.TRUE.toString());
final List<OnmsNode> nodes = getNodeDao().findAll();
final OnmsNode node = nodes.get(0);
runPendingScans();
m_nodeDao.flush();
assertEquals(1, getInterfaceDao().countAll());
// Make sure that the OnmsIpInterface doesn't have an ifIndex
assertNull(getInterfaceDao().get(node, "198.51.100.201").getIfIndex());
// Make sure that no OnmsSnmpInterface records exist for the node
assertNull(getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 4));
assertNull(getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 5));
LOG.info("******************** ADDING SNMP DATA ********************");
// Add some SNMP data to the agent
m_mockSnmpDataProvider.setDataForAddress(new SnmpAgentAddress(addr("198.51.100.201"), 161), new DefaultResourceLoader().getResource("classpath:/snmpTestData3.properties"));
// Rescan
m_mockEventIpcManager.sendEventToListeners(nodeUpdated(node.getId()));
runPendingScans();
m_nodeDao.flush();
// Make sure that a second interface was added from the SNMP agent data
assertEquals(2, getInterfaceDao().countAll());
// Verify the ifIndex entries
assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getSnmpInterface().getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getSnmpInterface().getIfIndex().intValue());
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-boot by spring-projects.
the class DataSourceInitializerTests method multipleScriptsAppliedInLexicalOrder.
@Test
public void multipleScriptsAppliedInLexicalOrder() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:true", "spring.datasource.schema:" + ClassUtils.addResourcePathToPackagePath(getClass(), "lexical-schema-*.sql"), "spring.datasource.data:" + ClassUtils.addResourcePathToPackagePath(getClass(), "data.sql"));
this.context.register(DataSourceAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
ReverseOrderResourceLoader resourceLoader = new ReverseOrderResourceLoader(new DefaultResourceLoader());
this.context.setResourceLoader(resourceLoader);
this.context.refresh();
DataSource dataSource = this.context.getBean(DataSource.class);
assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
assertThat(dataSource).isNotNull();
JdbcOperations template = new JdbcTemplate(dataSource);
assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class)).isEqualTo(1);
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-boot by spring-projects.
the class EnableAutoConfigurationImportSelectorTests method setup.
@Before
public void setup() {
this.importSelector.setBeanFactory(this.beanFactory);
this.importSelector.setEnvironment(this.environment);
this.importSelector.setResourceLoader(new DefaultResourceLoader());
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.
the class FreeMarkerConfigurerTests method freeMarkerConfigurationAsBean.
// SPR-12448
@Test
public void freeMarkerConfigurationAsBean() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
RootBeanDefinition loaderDef = new RootBeanDefinition(SpringTemplateLoader.class);
loaderDef.getConstructorArgumentValues().addGenericArgumentValue(new DefaultResourceLoader());
loaderDef.getConstructorArgumentValues().addGenericArgumentValue("/freemarker");
RootBeanDefinition configDef = new RootBeanDefinition(Configuration.class);
configDef.getPropertyValues().add("templateLoader", loaderDef);
beanFactory.registerBeanDefinition("freeMarkerConfig", configDef);
beanFactory.getBean(Configuration.class);
}
Aggregations