Search in sources :

Example 6 with FileAnticipator

use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.

the class PersistenceSerializationTest method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    fa = new FileAnticipator();
    fsr = new MockForeignSourceRepository();
    fsr.save(new ForeignSource("cheese"));
    fsr.flush();
    fs = fsr.getForeignSource("cheese");
    //        fs.setScanInterval(scanInterval)
    XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar("2009-02-25T12:45:38.800-05:00");
    fs.setDateStamp(cal);
    List<PluginConfig> detectors = new ArrayList<PluginConfig>();
    final PluginConfig detector = new PluginConfig("food", "org.opennms.netmgt.provision.persist.detectors.FoodDetector");
    detector.addParameter("type", "cheese");
    detector.addParameter("density", "soft");
    detector.addParameter("sharpness", "mild");
    detectors.add(detector);
    fs.setDetectors(detectors);
    List<PluginConfig> policies = new ArrayList<PluginConfig>();
    PluginConfig policy = new PluginConfig("lower-case-node", "org.opennms.netmgt.provision.persist.policies.NodeCategoryPolicy");
    policy.addParameter("label", "~^[a-z]$");
    policy.addParameter("category", "Lower-Case-Nodes");
    policies.add(policy);
    policy = new PluginConfig("all-ipinterfaces", "org.opennms.netmgt.provision.persist.policies.InclusiveInterfacePolicy");
    policies.add(policy);
    policy = new PluginConfig("10-ipinterfaces", "org.opennms.netmgt.provision.persist.policies.MatchingInterfacePolicy");
    policy.addParameter("ipaddress", "~^10\\..*$");
    policies.add(policy);
    policy = new PluginConfig("cisco-snmp-interfaces", "org.opennms.netmgt.provision.persist.policies.MatchingSnmpInterfacePolicy");
    policy.addParameter("ifdescr", "~^(?i:LEC).*$");
    policies.add(policy);
    fs.setPolicies(policies);
    fsw = new ForeignSourceCollection();
    fsw.getForeignSources().addAll(fsr.getForeignSources());
    c = JAXBContext.newInstance(ForeignSourceCollection.class, ForeignSource.class);
    m = c.createMarshaller();
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setNormalize(true);
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSourceCollection(org.opennms.netmgt.provision.persist.foreignsource.ForeignSourceCollection) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) ArrayList(java.util.ArrayList) FileAnticipator(org.opennms.test.FileAnticipator) Before(org.junit.Before)

Example 7 with FileAnticipator

use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.

the class TcaDataCollectionConfigTest method setUp.

/**
	 * Sets the up.
	 *
	 * @throws Exception the exception
	 */
@Before
public void setUp() throws Exception {
    fileAnticipator = new FileAnticipator();
    context = JAXBContext.newInstance(TcaDataCollectionConfig.class);
    marshaller = context.createMarshaller();
    unmarshaller = context.createUnmarshaller();
    TcaRrd rrd = new TcaRrd();
    rrd.addRra("RRA:AVERAGE:0.5:1:3600");
    rrd.addRra("RRA:AVERAGE:0.5:300:288");
    rrd.addRra("RRA:MIN:0.5:300:288");
    rrd.addRra("RRA:MAX:0.5:300:288");
    rrd.addRra("RRA:AVERAGE:0.5:900:2880");
    rrd.addRra("RRA:MIN:0.5:900:2880");
    rrd.addRra("RRA:MAX:0.5:900:2880");
    rrd.addRra("RRA:AVERAGE:0.5:3600:4300");
    rrd.addRra("RRA:MIN:0.5:3600:4300");
    rrd.addRra("RRA:MAX:0.5:3600:4300");
    TcaDataCollection tcadc = new TcaDataCollection();
    tcadc.setName("default");
    tcadc.setRrd(rrd);
    tcadcc = new TcaDataCollectionConfig();
    tcadcc.addDataCollection(tcadc);
    tcadcc.setRrdRepository("target/snmp/");
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setNormalize(true);
}
Also used : FileAnticipator(org.opennms.test.FileAnticipator) Before(org.junit.Before)

Example 8 with FileAnticipator

use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.

the class RrdPersistOperationBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_rrdStrategy = new JRobinRrdStrategy();
    m_fileAnticipator = new FileAnticipator();
    m_intf = new OnmsIpInterface();
    m_node = new OnmsNode();
    m_node.setId(1);
    m_intf.setNode(m_node);
    m_intf.setIpAddress(InetAddressUtils.addr("1.1.1.1"));
    m_intf.setId(27);
    m_ifDao = EasyMock.createMock(IpInterfaceDao.class);
    EasyMock.expect(m_ifDao.load(m_intf.getId())).andReturn(m_intf).anyTimes();
    EasyMock.replay(m_ifDao);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Before(org.junit.Before)

Example 9 with FileAnticipator

use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.

the class DefaultRrdDaoIntegrationTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    m_rrdStrategy = new JRobinRrdStrategy();
    m_fileAnticipator = new FileAnticipator();
    m_dao = new DefaultRrdDao();
    m_dao.setRrdStrategy(m_rrdStrategy);
    m_dao.setRrdBaseDirectory(m_fileAnticipator.getTempDir());
    m_dao.setRrdBinaryPath("/bin/true");
    m_dao.afterPropertiesSet();
}
Also used : JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator)

Example 10 with FileAnticipator

use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.

the class BasePersisterTest method setUp.

@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test " + m_testName.getMethodName() + " --------------------------");
    MockLogAppender.setupLogging();
    m_fileAnticipator = new FileAnticipator();
    m_rrdStrategy = new JRobinRrdStrategy();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
    m_intf = new OnmsIpInterface();
    m_node = new OnmsNode();
    m_node.setId(1);
    m_intf.setId(25);
    m_intf.setNode(m_node);
    m_intf.setIpAddress(InetAddressUtils.addr("1.1.1.1"));
    m_ifDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    m_serviceParams = new ServiceParameters(new HashMap<String, Object>());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) HashMap(java.util.HashMap) FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Before(org.junit.Before)

Aggregations

FileAnticipator (org.opennms.test.FileAnticipator)24 Before (org.junit.Before)15 File (java.io.File)7 JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)6 FilterDao (org.opennms.netmgt.filter.api.FilterDao)4 ArrayList (java.util.ArrayList)3 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)3 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)3 EasyMockUtils (org.opennms.test.mock.EasyMockUtils)3 FileSystemResource (org.springframework.core.io.FileSystemResource)3 FileWriter (java.io.FileWriter)2 InputStream (java.io.InputStream)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)2 ResourceTypesDao (org.opennms.netmgt.config.api.ResourceTypesDao)2 LocationMonitorDao (org.opennms.netmgt.dao.api.LocationMonitorDao)2 NodeDao (org.opennms.netmgt.dao.api.NodeDao)2 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)2