Search in sources :

Example 6 with JdbcFilterDao

use of org.opennms.netmgt.filter.JdbcFilterDao in project opennms by OpenNMS.

the class JdbcFilterDaoIT method setUp.

@Before
public void setUp() throws Exception {
    m_populator.populateDatabase();
    // Initialize Filter DAO
    // Give the filter DAO access to the same TemporaryDatabase data source
    // as the autowired DAOs
    DatabaseSchemaConfigFactory.init();
    m_dao = new JdbcFilterDao();
    m_dao.setDataSource(m_dataSource);
    m_dao.setDatabaseSchemaConfigFactory(DatabaseSchemaConfigFactory.getInstance());
    m_dao.afterPropertiesSet();
    FilterDaoFactory.setInstance(m_dao);
}
Also used : JdbcFilterDao(org.opennms.netmgt.filter.JdbcFilterDao) Before(org.junit.Before)

Example 7 with JdbcFilterDao

use of org.opennms.netmgt.filter.JdbcFilterDao 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 8 with JdbcFilterDao

use of org.opennms.netmgt.filter.JdbcFilterDao 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)

Aggregations

JdbcFilterDao (org.opennms.netmgt.filter.JdbcFilterDao)8 Test (org.junit.Test)5 InputStream (java.io.InputStream)3 DatabaseSchemaConfigFactory (org.opennms.netmgt.config.DatabaseSchemaConfigFactory)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 MockDatabase (org.opennms.core.test.db.MockDatabase)2 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)2 MibObject (org.opennms.netmgt.config.datacollection.MibObject)2 MockNetwork (org.opennms.netmgt.mock.MockNetwork)2 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)2 ArrayList (java.util.ArrayList)1 MockNotifdConfigManager (org.opennms.netmgt.config.mock.MockNotifdConfigManager)1 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)1