use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method testForeignSource.
@Test
public void testForeignSource() throws Exception {
createRequisition();
ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
Set<ForeignSource> foreignSources = m_foreignSourceRepository.getForeignSources();
assertEquals("number of foreign sources must be 1", 1, foreignSources.size());
assertEquals("getAll() foreign source name must match", m_defaultForeignSourceName, foreignSources.iterator().next().getName());
// check that the foreign source matches
final ForeignSource newForeignSource = m_foreignSourceRepository.getForeignSource(m_defaultForeignSourceName);
assertEquals(foreignSource.getName(), newForeignSource.getName());
assertEquals(foreignSource.getDateStampAsDate(), newForeignSource.getDateStampAsDate());
assertEquals(foreignSource.getDetectorNames(), newForeignSource.getDetectorNames());
assertEquals(foreignSource.getScanInterval(), newForeignSource.getScanInterval());
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method testDefaultForeignSource.
@Test
public void testDefaultForeignSource() throws Exception {
createRequisition();
List<String> detectorList = Arrays.asList(new String[] { "DNS", "FTP", "HTTP", "HTTPS", "ICMP", "IMAP", "LDAP", "NRPE", "POP3", "SMTP", "SNMP", "SSH" });
String uuid = UUID.randomUUID().toString();
ForeignSource defaultForeignSource = m_foreignSourceRepository.getForeignSource(uuid);
assertEquals("name must match requested foreign source repository name", uuid, defaultForeignSource.getName());
assertEquals("scan-interval must be 1 day", 86400000, defaultForeignSource.getScanInterval().getMillis());
assertEquals("foreign source must have no default policies", 0, defaultForeignSource.getPolicies().size());
List<String> fsNames = new ArrayList<String>();
for (PluginConfig config : defaultForeignSource.getDetectors()) {
fsNames.add(config.getName());
}
assertEquals("detector list must match expected defaults", detectorList, fsNames);
assertTrue("foreign source must be tagged as default", defaultForeignSource.isDefault());
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class CachingForeignSourceRepositoryTest method testGetRequisition.
@Test
public void testGetRequisition() throws Exception {
Requisition requisition = createRequisition();
ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
assertRequisitionsMatch("requisitions must match", m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName), m_foreignSourceRepository.getRequisition(foreignSource));
assertRequisitionsMatch("foreign source is the expected one", requisition, m_foreignSourceRepository.getRequisition(foreignSource));
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method testGetRequisition.
@Test
public void testGetRequisition() throws Exception {
Requisition requisition = createRequisition();
ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
assertRequisitionsMatch("requisitions must match", m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName), m_foreignSourceRepository.getRequisition(foreignSource));
assertRequisitionsMatch("foreign source is the expected one", requisition, m_foreignSourceRepository.getRequisition(foreignSource));
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource 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);
}
Aggregations