use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class OpenNMSITCase method populateDatabase.
protected void populateDatabase() throws Exception {
m_db = new MockDatabase();
m_db.populate(m_network);
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class EventTranslatorIT method createMockDb.
private void createMockDb() throws Exception {
m_db = new MockDatabase();
m_db.populate(m_network);
DataSourceFactory.setInstance(m_db);
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class CollectdConfigFactoryIT method setUp.
@Before
public void setUp() throws Exception {
MockNetwork network = new MockNetwork();
MockDatabase db = new MockDatabase();
db.populate(network);
DataSourceFactory.setInstance(db);
FilterDaoFactory.getInstance();
InputStream in = ConfigurationTestUtils.getInputStreamForResource(this, "collectd-testdata.xml");
try {
m_factory = new CollectdConfigFactory(in, "localhost", false);
} finally {
in.close();
}
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class PollerConfigFactoryIT method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
MockLogAppender.setupLogging();
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/config/test-database-schema.xml")));
MockNetwork network = new MockNetwork();
network.setCriticalService("ICMP");
network.addNode(1, "Router");
network.addInterface("192.168.1.1");
network.addService("ICMP");
network.addService("SMTP");
network.addInterface("192.168.1.2");
network.addService("ICMP");
network.addService("SMTP");
network.addNode(2, "Server");
network.addInterface("192.168.1.3");
network.addService("ICMP");
network.addService("HTTP");
network.addNode(3, "Firewall");
network.addInterface("192.168.1.4");
network.addService("SMTP");
network.addService("HTTP");
network.addInterface("192.168.1.5");
network.addService("SMTP");
network.addService("HTTP");
network.addInterface("192.169.1.5");
network.addService("SMTP");
network.addService("HTTP");
network.addNode(4, "TestNode121");
network.addInterface("123.12.123.121");
network.addService("HTTP");
network.addNode(5, "TestNode122");
network.addInterface("123.12.123.122");
network.addService("HTTP");
MockDatabase db = new MockDatabase();
db.populate(network);
DataSourceFactory.setInstance(db);
// Make sure it gets *our* MockDatabase
FilterDaoFactory.setInstance(null);
FilterDaoFactory.getInstance();
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class AbstractSpringJerseyRestTestCase method setUp.
@Before
public void setUp() throws Throwable {
beforeServletStart();
setUser("admin", new String[] { "ROLE_ADMIN" });
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.afterPropertiesSet();
MockDatabase db = new MockDatabase(true);
DataSourceFactory.setInstance(db);
XADataSourceFactory.setInstance(db);
try {
MockFilterConfig filterConfig = new MockFilterConfig(servletContext, "openSessionInViewFilter");
setFilter(new OpenSessionInViewFilter());
getFilter().init(filterConfig);
// Jersey
/*
setServletConfig(new MockServletConfig(servletContext, "dispatcher"));
getServletConfig().addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
getServletConfig().addInitParameter("com.sun.jersey.config.property.packages", "org.codehaus.jackson.jaxrs;org.opennms.web.rest;org.opennms.web.rest.config");
getServletConfig().addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");
getServletConfig().addInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");
setDispatcher(new SpringServlet());
getDispatcher().init(getServletConfig());
*/
// Apache CXF
setServletConfig(new MockServletConfig(servletContext, "dispatcher"));
getServletConfig().addInitParameter("config-location", m_cxfContextPath);
CXFServlet servlet = new CXFServlet();
setDispatcher(servlet);
getDispatcher().init(getServletConfig());
} catch (ServletException se) {
throw se.getRootCause();
}
afterServletStart();
System.err.println("------------------------------------------------------------------------------");
}
Aggregations