Search in sources :

Example 6 with EasyMockUtils

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

the class SecurityAuthenticationEventOnmsEventBuilderTest method setUp.

@Override
public void setUp() {
    m_mocks = new EasyMockUtils();
    m_eventProxy = m_mocks.createMock(EventProxy.class);
}
Also used : EasyMockUtils(org.opennms.test.mock.EasyMockUtils) EventProxy(org.opennms.netmgt.events.api.EventProxy)

Example 7 with EasyMockUtils

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

the class DefaultResourceDaoTest method setUp.

@Before
public void setUp() throws Exception {
    m_fileAnticipator = new FileAnticipator();
    m_easyMockUtils = new EasyMockUtils();
    m_nodeDao = m_easyMockUtils.createMock(NodeDao.class);
    m_locationMonitorDao = m_easyMockUtils.createMock(LocationMonitorDao.class);
    m_resourceTypesDao = m_easyMockUtils.createMock(ResourceTypesDao.class);
    m_filterDao = m_easyMockUtils.createMock(FilterDao.class);
    m_ipInterfaceDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    FilterDaoFactory.setInstance(m_filterDao);
    expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
    m_easyMockUtils.replayAll();
    setUpCollectdConfigFactory();
    m_easyMockUtils.verifyAll();
    RrdStrategy<?, ?> rrdStrategy = new JRobinRrdStrategy();
    m_rrdFileExtension = rrdStrategy.getDefaultFileExtension();
    m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
    m_resourceStorageDao.setRrdStrategy(rrdStrategy);
    m_resourceDao = new DefaultResourceDao();
    m_resourceDao.setNodeDao(m_nodeDao);
    m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
    m_resourceDao.setIpInterfaceDao(m_ipInterfaceDao);
    m_resourceDao.setCollectdConfig(m_collectdConfig);
    m_resourceDao.setResourceTypesDao(m_resourceTypesDao);
    m_resourceDao.setResourceStorageDao(m_resourceStorageDao);
    expect(m_resourceTypesDao.getResourceTypes()).andReturn(new HashMap<String, ResourceType>());
    expect(m_resourceTypesDao.getLastUpdate()).andReturn(m_lastUpdateTime);
    m_easyMockUtils.replayAll();
    m_resourceDao.afterPropertiesSet();
    m_easyMockUtils.verifyAll();
}
Also used : ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) ArrayList(java.util.ArrayList) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) LocationMonitorDao(org.opennms.netmgt.dao.api.LocationMonitorDao) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) NodeDao(org.opennms.netmgt.dao.api.NodeDao) FilterDao(org.opennms.netmgt.filter.api.FilterDao) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) Before(org.junit.Before)

Example 8 with EasyMockUtils

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

the class ResourceDaoIntegrityIT method setUp.

@Before
public void setUp() throws Exception {
    setStoreByForeignSource(false);
    m_easyMockUtils = new EasyMockUtils();
    m_resourceTypesDao = m_easyMockUtils.createMock(ResourceTypesDao.class);
    m_filterDao = m_easyMockUtils.createMock(FilterDao.class);
    FilterDaoFactory.setInstance(m_filterDao);
    expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
    m_easyMockUtils.replayAll();
    InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/collectdconfiguration-testdata.xml");
    m_collectdConfig = new CollectdConfigFactory(stream, "localhost", false);
    m_easyMockUtils.verifyAll();
    m_resourceStorageDao.setRrdDirectory(m_tempFolder.getRoot());
    // Match up with the extensions in resource-tree-files.txt
    m_resourceStorageDao.setRrdExtension(".rrd");
    m_resourceDao = new DefaultResourceDao();
    m_resourceDao.setNodeDao(m_nodeDao);
    m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
    m_resourceDao.setCollectdConfig(m_collectdConfig);
    m_resourceDao.setResourceStorageDao(m_resourceStorageDao);
    m_resourceDao.setResourceTypesDao(m_resourceTypesDao);
    m_resourceDao.setIpInterfaceDao(m_ipInterfaceDao);
}
Also used : FilterDao(org.opennms.netmgt.filter.api.FilterDao) ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) Before(org.junit.Before)

Example 9 with EasyMockUtils

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

the class AnnotationBasedEventListenerAdapterTest method setUp.

/* (non-Javadoc)
     * @see junit.framework.TestCase#setUp()
     */
@Before
public void setUp() throws Exception {
    m_mockUtils = new EasyMockUtils();
    m_eventIpcMgr = m_mockUtils.createMock(EventSubscriptionService.class);
    m_annotatedListener = new AnnotatedListener();
    m_adapter = new AnnotationBasedEventListenerAdapter();
    m_adapter.setAnnotatedListener(m_annotatedListener);
    m_adapter.setEventSubscriptionService(m_eventIpcMgr);
    m_subscriptions = new HashSet<String>();
    Collections.addAll(m_subscriptions, EventConstants.NODE_DOWN_EVENT_UEI, EventConstants.ADD_NODE_EVENT_UEI, EventConstants.NODE_LOST_SERVICE_EVENT_UEI);
    m_eventIpcMgr.addEventListener(m_adapter, m_subscriptions);
}
Also used : EventSubscriptionService(org.opennms.netmgt.events.api.EventSubscriptionService) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AnnotationBasedEventListenerAdapter(org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter) Before(org.junit.Before)

Example 10 with EasyMockUtils

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

the class SnmpCollectorITCase method setUp.

@Before
@Override
public void setUp() throws Exception {
    setStartEventd(false);
    super.setUp();
    m_mockAgent = MockSnmpAgent.createAgentAndRun(new ClassPathResource("org/opennms/netmgt/snmp/snmpTestData1.properties").getURL(), InetAddressUtils.str(myLocalHost()) + "/9161");
    m_config = new MockDataCollectionConfig();
    DataCollectionConfigFactory.setInstance(m_config);
    m_sysNameOid = SnmpObjId.get(".1.3.6.1.2.1.1.5");
    m_ifOutOctets = SnmpObjId.get("..1.3.6.1.2.1.2.2.1.16");
    m_invalid = SnmpObjId.get(".1.5.6.1.2.1.1.5");
    m_ifDescr = SnmpObjId.get(".1.3.6.1.2.1.2.2.1.2");
    m_easyMockUtils = new EasyMockUtils();
    m_ifaceDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    createAgent(1, PrimaryType.PRIMARY);
}
Also used : MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) ClassPathResource(org.springframework.core.io.ClassPathResource) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) 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