use of org.opennms.netmgt.mock.MockCategoryFactory in project opennms by OpenNMS.
the class AvailabilityReportFullIT method setUp.
@Before
public void setUp() throws Exception {
Locale.setDefault(Locale.US);
m_calendar = new GregorianCalendar();
// date fror report run is 18th May 2005
m_calendar.set(2005, Calendar.MAY, 18);
MockLogAppender.setupLogging();
m_categories = new Categories();
m_dbPopulator.populateDatabase();
m_catFactory = new MockCategoryFactory();
CategoryFactory.setInstance(m_catFactory);
}
use of org.opennms.netmgt.mock.MockCategoryFactory in project opennms by OpenNMS.
the class AvailabilityReportIT method setUp.
@Override
protected void setUp() throws Exception {
System.err.println("------------------- begin " + getName() + " ---------------------");
// Reset the FilterDaoFactory so we don't get screwed by having the JdbcFilterDao be connected to an older database
FilterDaoFactory.setInstance(null);
super.setUp();
Locale.setDefault(Locale.US);
calendar = new GregorianCalendar();
//date for report run is 18th May 2005
calendar.set(2005, 4, 18);
MockLogAppender.setupLogging();
m_categories = new Categories();
m_db = new MockDatabase();
DataSourceFactory.setInstance(m_db);
InputStream is = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(is));
is.close();
m_catFactory = new MockCategoryFactory();
CategoryFactory.setInstance(m_catFactory);
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 1,'test1.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 2,'test2.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into service (serviceid, servicename) values\n" + "(1, 'ICMP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(2, 'HTTP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(3, 'SNMP');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(1, 1,'192.168.100.1','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(2, 2,'192.168.100.2','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(3, 2,'192.168.100.3','M');");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 1:192.168.100.1:1
"(1,1,'A',1);");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 2:192.168.100.2:1
"(2,1,'A',2);");
/*
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " +
"(3,2,'A',2);"); // 2:192.168.100.2:2
*/
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 2:192.168.100.3:1
"(4,1,'A',3);");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(1,1,'2005-05-01 09:00:00','2005-05-01 09:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(2,2,'2005-05-01 10:00:00','2005-05-02 10:00:00');");
// test data for LastMonthsDailyAvailability report
// insert 30 minute outage on one node - 99.3056% availability
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(3,1,'2005-04-02 10:00:00','2005-04-02 10:30:00');");
// insert 60 minute outage on one interface and 59 minute outages on another - 97.2454
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(4,1,'2005-04-03 11:30:00','2005-04-03 12:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(5,2,'2005-04-03 23:00:00','2005-04-03 23:59:00');");
// test an outage that spans 60 minutes across midnight - 99.3056% on each day, well, not exactly
// its 29 minutes 99.3059 on the fist day and 31 minutes 99.3052 on the second.
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(6,4,'2005-04-04 23:30:00','2005-04-05 00:30:00');");
}
use of org.opennms.netmgt.mock.MockCategoryFactory in project opennms by OpenNMS.
the class AvailabilityCalculatorIT method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// Reset the FilterDaoFactory so we don't get screwed by having the JdbcFilterDao be connected to an older database
FilterDaoFactory.setInstance(null);
Locale.setDefault(Locale.US);
m_calendar = new GregorianCalendar();
// date for report run is 18th May 2005
m_calendar.set(2005, Calendar.MAY, 18);
MockLogAppender.setupLogging();
m_categories = new Categories();
m_db = new MockDatabase();
DataSourceFactory.setInstance(m_db);
InputStream is = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(is));
is.close();
m_catFactory = new MockCategoryFactory();
CategoryFactory.setInstance(m_catFactory);
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 1,'test1.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 2,'test2.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into service (serviceid, servicename) values\n" + "(1, 'ICMP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(2, 'HTTP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(3, 'SNMP');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(1, 1,'192.168.100.1','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(2, 2,'192.168.100.2','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(3, 2,'192.168.100.3','M');");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + //1:192.168.100.1:1
"(1, 1,'A', 1);");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + //2:192.168.100.2:1
"(2, 1,'A', 2);");
/*
* m_db.update("insert into ifservices (serviceid, status, ipInterfaceId) values " + "(2,'A', 2);"); //2:192.168.100.2:2
*/
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + //2:192.168.100.3:1
"(3, 1,'A', 3);");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(1,1,'2005-05-01 09:00:00','2005-05-01 09:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(2,2,'2005-05-01 10:00:00','2005-05-02 10:00:00');");
// test data for LastMonthsDailyAvailability report
// insert 30 minute outage on one node - 99.3056% availability
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(3,1,'2005-04-02 10:00:00','2005-04-02 10:30:00');");
// insert 60 minute outage on one interface and 59 minute outages on
// another - 97.2454
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(4,1,'2005-04-03 11:30:00','2005-04-03 12:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(5,2,'2005-04-03 23:00:00','2005-04-03 23:59:00');");
// test an outage that spans 60 minutes across midnight - 99.3056% on
// each day, well, not exactly
// its 29 minutes 99.3059 on the fist day and 31 minutes 99.3052 on
// the second.
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(6,3,'2005-04-04 23:30:00','2005-04-05 00:30:00');");
}
use of org.opennms.netmgt.mock.MockCategoryFactory in project opennms by OpenNMS.
the class DefaultCategoryConfigDaoTest method setUp.
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
MockUtil.println("------------ Begin Test " + getName() + " --------------------------");
MockLogAppender.setupLogging();
m_catFactory = new MockCategoryFactory();
CategoryFactory.setInstance(m_catFactory);
m_dao = new DefaultCategoryConfigDao();
}
Aggregations