use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class JdbcDataCollectionConfigDaoJaxbTest method testAfterPropertiesSetWithGoodConfigFile.
public void testAfterPropertiesSetWithGoodConfigFile() throws Exception {
JdbcDataCollectionConfigDaoJaxb dao = new JdbcDataCollectionConfigDaoJaxb();
InputStream in = ConfigurationTestUtils.getInputStreamForConfigFile("jdbc-datacollection-config.xml");
dao.setConfigResource(new InputStreamResource(in));
dao.afterPropertiesSet();
assertNotNull("jdbc data collection should not be null", dao.getConfig());
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testLoadWithOnlyExternalReferences.
@Test
public void testLoadWithOnlyExternalReferences() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-onlyimports.xml"));
DatacollectionConfig config = JaxbUtils.unmarshal(DatacollectionConfig.class, resource, false);
// Validate default datacollection content
SnmpCollection collection = config.getSnmpCollections().get(0);
Assert.assertEquals(3, collection.getIncludeCollections().size());
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertNull(collection.getSystems());
Assert.assertNull(collection.getGroups());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(2, collection.getSystems().getSystemDefs().size());
// Unused groups will be ignored
Assert.assertEquals(6, collection.getGroups().getGroups().size());
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testLoadHybridConfiguration.
@Test
public void testLoadHybridConfiguration() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-hybrid.xml"));
DatacollectionConfig config = JaxbUtils.unmarshal(DatacollectionConfig.class, resource, false);
// Validate default datacollection content
SnmpCollection collection = config.getSnmpCollections().get(0);
Assert.assertEquals(13, collection.getIncludeCollections().size());
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(1, collection.getSystems().getSystemDefs().size());
Assert.assertEquals(1, collection.getGroups().getGroups().size());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(17, collection.getSystems().getSystemDefs().size());
Assert.assertEquals(65, collection.getGroups().getGroups().size());
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testLoadSimple.
@Test
public void testLoadSimple() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-simple.xml"));
DatacollectionConfig config = JaxbUtils.unmarshal(DatacollectionConfig.class, resource, false);
// Validate default datacollection content
SnmpCollection collection = config.getSnmpCollections().get(0);
Assert.assertEquals(1, collection.getIncludeCollections().size());
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertNull(collection.getSystems());
Assert.assertNull(collection.getGroups());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(71, collection.getSystems().getSystemDefs().size());
Assert.assertEquals(28, collection.getGroups().getGroups().size());
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testSingleSystemDefs.
@Test
public void testSingleSystemDefs() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-single-systemdef.xml"));
DatacollectionConfig config = JaxbUtils.unmarshal(DatacollectionConfig.class, resource, false);
// Validate default datacollection content
SnmpCollection collection = config.getSnmpCollections().get(0);
Assert.assertEquals(2, collection.getIncludeCollections().size());
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertNull(collection.getSystems());
Assert.assertNull(collection.getGroups());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(2, collection.getSystems().getSystemDefs().size());
Assert.assertEquals(32, collection.getGroups().getGroups().size());
}
Aggregations