Search in sources :

Example 6 with InputStreamResource

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());
}
Also used : InputStream(java.io.InputStream) InputStreamResource(org.springframework.core.io.InputStreamResource)

Example 7 with InputStreamResource

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());
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) FileSystemResource(org.springframework.core.io.FileSystemResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Example 8 with InputStreamResource

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());
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) FileSystemResource(org.springframework.core.io.FileSystemResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Example 9 with InputStreamResource

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());
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) FileSystemResource(org.springframework.core.io.FileSystemResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Example 10 with InputStreamResource

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());
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) FileSystemResource(org.springframework.core.io.FileSystemResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Aggregations

InputStreamResource (org.springframework.core.io.InputStreamResource)32 Test (org.junit.Test)12 InputStream (java.io.InputStream)11 Resource (org.springframework.core.io.Resource)10 FileSystemResource (org.springframework.core.io.FileSystemResource)8 File (java.io.File)6 DatacollectionConfig (org.opennms.netmgt.config.datacollection.DatacollectionConfig)6 SnmpCollection (org.opennms.netmgt.config.datacollection.SnmpCollection)6 FileInputStream (java.io.FileInputStream)4 ClassPathResource (org.springframework.core.io.ClassPathResource)3 HttpHeaders (org.springframework.http.HttpHeaders)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 X509Certificate (java.security.cert.X509Certificate)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 X509CertificateCredential (org.apereo.cas.adaptors.x509.authentication.principal.X509CertificateCredential)2 DefaultDataCollectionConfigDao (org.opennms.netmgt.config.DefaultDataCollectionConfigDao)2 DefaultStatisticsDaemonConfigDao (org.opennms.netmgt.dao.jaxb.DefaultStatisticsDaemonConfigDao)2 BeansException (org.springframework.beans.BeansException)2 SimpleBeanDefinitionRegistry (org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry)2 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)2