Search in sources :

Example 6 with DatabaseSchemaConfigFactory

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

the class JdbcFilterDaoIT method testAfterPropertiesSetValid.

@Test
public void testAfterPropertiesSetValid() throws Exception {
    JdbcFilterDao dao = new JdbcFilterDao();
    dao.setDataSource(m_dataSource);
    InputStream is = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
    dao.setDatabaseSchemaConfigFactory(new DatabaseSchemaConfigFactory(is));
    is.close();
    dao.afterPropertiesSet();
}
Also used : InputStream(java.io.InputStream) DatabaseSchemaConfigFactory(org.opennms.netmgt.config.DatabaseSchemaConfigFactory) JdbcFilterDao(org.opennms.netmgt.filter.JdbcFilterDao) Test(org.junit.Test)

Example 7 with DatabaseSchemaConfigFactory

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

the class JdbcFilterDaoIT method testAfterPropertiesSetNoDataSource.

@Test
public void testAfterPropertiesSetNoDataSource() throws Exception {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    JdbcFilterDao dao = new JdbcFilterDao();
    InputStream is = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
    dao.setDatabaseSchemaConfigFactory(new DatabaseSchemaConfigFactory(is));
    is.close();
    ta.anticipate(new IllegalStateException("property dataSource cannot be null"));
    try {
        dao.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : InputStream(java.io.InputStream) DatabaseSchemaConfigFactory(org.opennms.netmgt.config.DatabaseSchemaConfigFactory) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) JdbcFilterDao(org.opennms.netmgt.filter.JdbcFilterDao) Test(org.junit.Test)

Example 8 with DatabaseSchemaConfigFactory

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

the class CollectorConfigDaoImplIT method initialize.

private void initialize() throws IOException, Exception {
    System.setProperty("opennms.home", ConfigurationTestUtils.getDaemonEtcDirectory().getParentFile().getAbsolutePath());
    InputStream stream = null;
    stream = getInputStreamForFile("/org/opennms/netmgt/config/test-database-schema.xml");
    DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(stream));
    stream.close();
    stream = getInputStreamForFile("/org/opennms/netmgt/config/snmp-config.xml");
    SnmpPeerFactory.setInstance(new SnmpPeerFactory(new InputStreamResource(stream)));
    stream.close();
    stream = getInputStreamForFile("/org/opennms/netmgt/config/datacollection-config.xml");
    DefaultDataCollectionConfigDao dataCollectionDao = new DefaultDataCollectionConfigDao();
    dataCollectionDao.setConfigResource(new InputStreamResource(stream));
    dataCollectionDao.afterPropertiesSet();
    DataCollectionConfigFactory.setInstance(dataCollectionDao);
    stream.close();
    stream = getInputStreamForFile("/org/opennms/netmgt/config/collectd-testdata.xml");
    try {
        new CollectdConfigFactory(stream, "localhost", false);
    } finally {
        stream.close();
    }
}
Also used : InputStream(java.io.InputStream) SnmpPeerFactory(org.opennms.netmgt.config.SnmpPeerFactory) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory) DatabaseSchemaConfigFactory(org.opennms.netmgt.config.DatabaseSchemaConfigFactory) DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) InputStreamResource(org.springframework.core.io.InputStreamResource)

Aggregations

InputStream (java.io.InputStream)8 DatabaseSchemaConfigFactory (org.opennms.netmgt.config.DatabaseSchemaConfigFactory)8 Test (org.junit.Test)4 JdbcFilterDao (org.opennms.netmgt.filter.JdbcFilterDao)3 GregorianCalendar (java.util.GregorianCalendar)2 MockDatabase (org.opennms.core.test.db.MockDatabase)2 DefaultDataCollectionConfigDao (org.opennms.netmgt.config.DefaultDataCollectionConfigDao)2 MockCategoryFactory (org.opennms.netmgt.mock.MockCategoryFactory)2 Resource (org.springframework.core.io.Resource)2 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1 CategoryFactory (org.opennms.netmgt.config.CategoryFactory)1 CollectdConfigFactory (org.opennms.netmgt.config.CollectdConfigFactory)1 HttpCollectionConfigFactory (org.opennms.netmgt.config.HttpCollectionConfigFactory)1 RTCConfigFactory (org.opennms.netmgt.config.RTCConfigFactory)1 SnmpPeerFactory (org.opennms.netmgt.config.SnmpPeerFactory)1 Category (org.opennms.netmgt.config.categories.Category)1 RTCCategory (org.opennms.netmgt.rtc.datablock.RTCCategory)1 FileAnticipator (org.opennms.test.FileAnticipator)1 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)1