Search in sources :

Example 1 with RTCConfigFactory

use of org.opennms.netmgt.config.RTCConfigFactory in project opennms by OpenNMS.

the class DataSenderTest method testSendData.

/*
     * This doesn't work unless we have a receiver on the other end.... more of an integration test
     */
@Test
@Ignore
public void testSendData() throws IOException, FilterParseException, SAXException, SQLException, RTCException {
    InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/config/rtc-configuration.xml");
    RTCConfigFactory configFactory = new RTCConfigFactory(stream);
    stream.close();
    Resource categoryResource = ConfigurationTestUtils.getSpringResourceForResource(this, "/org/opennms/netmgt/config/categories.xml");
    CategoryFactory.setInstance(new CategoryFactory(categoryResource));
    stream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/config/test-database-schema.xml");
    DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(stream));
    stream.close();
    DataManager dataManager = new DataManager();
    String categoryName = "Database Servers";
    String categoryNameUrl = "Database+Servers";
    Category category = new Category();
    category.setLabel(categoryName);
    category.setComment("Some database servers.  Exciting, eh?");
    category.setNormalThreshold(99.0);
    category.setWarningThreshold(97.0);
    RTCCategory rtcCategory = new RTCCategory(category, categoryName);
    Map<String, RTCCategory> rtcCategories = new HashMap<String, RTCCategory>();
    rtcCategories.put(categoryName, rtcCategory);
    DataSender sender = new DataSender(dataManager, configFactory);
    sender.subscribe("http://localhost:8080/opennms-webapp/rtc/post/" + categoryNameUrl, categoryName, "rtc", "rtc");
    sender.sendData();
}
Also used : Category(org.opennms.netmgt.config.categories.Category) RTCCategory(org.opennms.netmgt.rtc.datablock.RTCCategory) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) DatabaseSchemaConfigFactory(org.opennms.netmgt.config.DatabaseSchemaConfigFactory) RTCConfigFactory(org.opennms.netmgt.config.RTCConfigFactory) CategoryFactory(org.opennms.netmgt.config.CategoryFactory) RTCCategory(org.opennms.netmgt.rtc.datablock.RTCCategory) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 CategoryFactory (org.opennms.netmgt.config.CategoryFactory)1 DatabaseSchemaConfigFactory (org.opennms.netmgt.config.DatabaseSchemaConfigFactory)1 RTCConfigFactory (org.opennms.netmgt.config.RTCConfigFactory)1 Category (org.opennms.netmgt.config.categories.Category)1 RTCCategory (org.opennms.netmgt.rtc.datablock.RTCCategory)1 Resource (org.springframework.core.io.Resource)1