Search in sources :

Example 1 with EasyMockUtils

use of org.opennms.test.mock.EasyMockUtils in project opennms by OpenNMS.

the class LatencyStoringServiceMonitorAdaptorIT method setUp.

@Before
public // that uses generics
void setUp() throws Exception {
    BeanUtils.setStaticApplicationContext(m_context);
    m_mocks = new EasyMockUtils();
    m_pollerConfig = m_mocks.createMock(PollerConfig.class);
    MockLogAppender.setupLogging();
    String previousOpennmsHome = System.setProperty("opennms.home", "src/test/resources");
    PollOutagesConfigFactory.init();
    System.setProperty("opennms.home", previousOpennmsHome);
    MockNetwork network = new MockNetwork();
    network.setCriticalService("ICMP");
    network.addNode(1, "testNode");
    network.addInterface("127.0.0.1");
    network.setIfAlias("eth0");
    network.addService("ICMP");
    network.addService("SNMP");
    m_db.populate(network);
}
Also used : MockNetwork(org.opennms.netmgt.mock.MockNetwork) PollerConfig(org.opennms.netmgt.config.PollerConfig) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) Before(org.junit.Before)

Example 2 with EasyMockUtils

use of org.opennms.test.mock.EasyMockUtils in project opennms by OpenNMS.

the class DefaultRrdGraphServiceTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    m_mockUtils = new EasyMockUtils();
    m_fileAnticipator = new FileAnticipator(false);
    m_service = new DefaultRrdGraphService();
}
Also used : EasyMockUtils(org.opennms.test.mock.EasyMockUtils) FileAnticipator(org.opennms.test.FileAnticipator)

Example 3 with EasyMockUtils

use of org.opennms.test.mock.EasyMockUtils 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");
}
Also used : ResourceLoader(org.springframework.core.io.ResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Ticket(org.opennms.api.integration.ticketing.Ticket) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Resource(org.springframework.core.io.Resource) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Plugin(org.opennms.api.integration.ticketing.Plugin) Before(org.junit.Before)

Example 4 with EasyMockUtils

use of org.opennms.test.mock.EasyMockUtils in project opennms by OpenNMS.

the class TicketNotificationStrategyTest method setUp.

/** {@inheritDoc} */
@Override
protected void setUp() throws Exception {
    super.setUp();
    m_eventIpcManager = new MockEventIpcManager();
    m_eventIpcManager.setSynchronous(true);
    EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
    MockLogAppender.setupLogging();
    m_ticketNotificationStrategy = new MockTicketNotificationStrategy();
    m_easyMockUtils = new EasyMockUtils();
    m_dataSource = m_easyMockUtils.createMock(DataSource.class);
    DataSourceFactory.setInstance(m_dataSource);
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) DataSource(javax.sql.DataSource)

Example 5 with EasyMockUtils

use of org.opennms.test.mock.EasyMockUtils in project opennms by OpenNMS.

the class DefaultTicketerServiceLayerTest method setUp.

@Before
public void setUp() throws Exception {
    System.clearProperty(DefaultTicketerServiceLayer.SKIP_CREATE_WHEN_CLEARED_SYS_PROP);
    System.clearProperty(DefaultTicketerServiceLayer.SKIP_CLOSE_WHEN_NOT_CLEARED_SYS_PROP);
    m_eventIpcManager = new MockEventIpcManager();
    EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
    MockLogAppender.setupLogging();
    m_defaultTicketerServiceLayer = new DefaultTicketerServiceLayer();
    m_easyMockUtils = new EasyMockUtils();
    m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
    m_defaultTicketerServiceLayer.setAlarmDao(m_alarmDao);
    m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
    m_defaultTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
    m_alarm = new OnmsAlarm();
    m_alarm.setId(1);
    m_alarm.setLogMsg("Test Logmsg");
    m_alarm.setDescription("Test Description");
    m_ticket = new Ticket();
    m_ticket.setId("4");
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) Plugin(org.opennms.api.integration.ticketing.Plugin) Before(org.junit.Before)

Aggregations

EasyMockUtils (org.opennms.test.mock.EasyMockUtils)14 Before (org.junit.Before)10 NodeDao (org.opennms.netmgt.dao.api.NodeDao)5 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)5 FilterDao (org.opennms.netmgt.filter.api.FilterDao)5 ArrayList (java.util.ArrayList)4 CollectdConfigFactory (org.opennms.netmgt.config.CollectdConfigFactory)4 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)4 ResourceTypesDao (org.opennms.netmgt.config.api.ResourceTypesDao)3 FileAnticipator (org.opennms.test.FileAnticipator)3 ClassPathResource (org.springframework.core.io.ClassPathResource)3 Resource (org.springframework.core.io.Resource)3 File (java.io.File)2 InputStream (java.io.InputStream)2 Plugin (org.opennms.api.integration.ticketing.Plugin)2 Ticket (org.opennms.api.integration.ticketing.Ticket)2 InsufficientInformationException (org.opennms.core.utils.InsufficientInformationException)2 DefaultServiceCollectorRegistry (org.opennms.netmgt.collection.support.DefaultServiceCollectorRegistry)2 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)2 CollectdConfiguration (org.opennms.netmgt.config.collectd.CollectdConfiguration)2