use of org.opennms.test.DaoTestConfigBean in project opennms by OpenNMS.
the class ConnectionFactoryIT method testMarshalDataSourceFromConfig.
public void testMarshalDataSourceFromConfig() throws Exception {
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.afterPropertiesSet();
AtomikosDataSourceFactory factory1 = null;
AtomikosDataSourceFactory factory2 = null;
try {
factory1 = makeFactory("opennms");
factory1.setUniqueResourceName("opennms");
factory2 = makeFactory("opennms2");
factory2.setUniqueResourceName("opennms2");
Connection conn = null;
Statement s = null;
try {
conn = factory2.getConnection();
s = conn.createStatement();
s.execute("select * from pg_proc");
} finally {
if (s != null) {
s.close();
}
if (conn != null) {
conn.close();
}
}
} finally {
Throwable t1 = null;
Throwable t2 = null;
if (factory1 != null) {
try {
factory1.close();
factory1 = null;
} catch (Throwable e1) {
t1 = e1;
}
}
if (factory2 != null) {
try {
factory2.close();
factory2 = null;
} catch (Throwable e2) {
t2 = e2;
}
}
if (t1 != null || t2 != null) {
StringBuffer message = new StringBuffer();
message.append("Could not successfully close both C3P0 factories. Future tests might fail.");
Throwable choice;
if (t1 != null) {
message.append(" First factory failed with: " + t1.getMessage() + "; see stack back trace.");
choice = t1;
if (t2 != null) {
System.err.println(" Both factories failed to close. See stderr for second stack back trace.");
t2.printStackTrace(System.err);
}
} else {
choice = t2;
}
AssertionError e = new AssertionError(message.toString());
e.initCause(choice);
throw e;
}
}
}
use of org.opennms.test.DaoTestConfigBean in project opennms by OpenNMS.
the class HttpRemotingContextIT method testLoadContext.
public void testLoadContext() throws Throwable {
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.afterPropertiesSet();
MockDatabase db = new MockDatabase(true);
DataSourceFactory.setInstance(db);
servletContext = new MockServletContext("file:src/main/webapp");
servletContext.addInitParameter("contextConfigLocation", "classpath:/META-INF/opennms/applicationContext-commonConfigs.xml " + "classpath:/META-INF/opennms/applicationContext-soa.xml " + "classpath:/META-INF/opennms/applicationContext-mockDao.xml " + "classpath*:/META-INF/opennms/component-service.xml " + "classpath*:/META-INF/opennms/component-dao.xml " + // Contexts within this project
"/WEB-INF/applicationContext-common.xml " + "/WEB-INF/applicationContext-serviceRegistryRemoting.xml " + "/WEB-INF/applicationContext-spring-security.xml " + "/WEB-INF/applicationContext-svclayer.xml ");
servletContext.addInitParameter("parentContextKey", "daoContext");
ServletContextEvent e = new ServletContextEvent(servletContext);
contextListener = new ContextLoaderListener();
contextListener.contextInitialized(e);
servletContext.setContextPath(contextPath);
servletConfig = new MockServletConfig(servletContext, "dispatcher");
servletConfig.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
servletConfig.addInitParameter("com.sun.jersey.config.property.packages", "org.opennms.web.rest");
try {
MockFilterConfig filterConfig = new MockFilterConfig(servletContext, "openSessionInViewFilter");
filter = new OpenSessionInViewFilter();
filter.init(filterConfig);
} catch (ServletException se) {
throw se.getRootCause();
}
}
use of org.opennms.test.DaoTestConfigBean in project opennms by OpenNMS.
the class InstallerIpLikeTest method setUp.
@Before
public void setUp() {
System.setProperty("skip-native", "true");
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.setRelativeHomeDirectory("target/test-classes");
System.setProperty("install.dir", "target/test-classes");
System.setProperty("install.etc.dir", "target/test-classes/etc");
bean.afterPropertiesSet();
m_installer = new Installer();
}
use of org.opennms.test.DaoTestConfigBean in project opennms by OpenNMS.
the class SyslogdConfigFactoryIT method setUp.
@Before
public void setUp() throws Exception {
DaoTestConfigBean daoTestConfig = new DaoTestConfigBean();
daoTestConfig.setRelativeHomeDirectory("src/test/resources");
daoTestConfig.afterPropertiesSet();
MockNetwork network = new MockNetwork();
MockDatabase db = new MockDatabase();
db.populate(network);
DataSourceFactory.setInstance(db);
m_factory = new SyslogdConfigFactory(ConfigurationTestUtils.getInputStreamForResource(this, "/etc/syslogd-configuration.xml"));
}
use of org.opennms.test.DaoTestConfigBean in project opennms by OpenNMS.
the class NotificationsITCase method setUp.
protected void setUp() throws Exception {
MockUtil.println("################# Running Test ################");
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.afterPropertiesSet();
MockLogAppender.setupLogging();
m_network = createMockNetwork();
m_db.populate(m_network);
DataSourceFactory.setInstance(m_db);
m_eventMgr = new MockEventIpcManager();
m_eventMgr.setEventWriter(m_db);
m_notifdConfig = new MockNotifdConfigManager(ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notifd-configuration.xml"));
m_notifdConfig.setNextNotifIdSql(m_db.getNextNotifIdSql());
m_notifdConfig.setNextUserNotifIdSql(m_db.getNextUserNotifIdSql());
m_groupManager = createGroupManager();
m_userManager = createUserManager(m_groupManager);
m_destinationPathManager = new MockDestinationPathManager(ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "destination-paths.xml"));
m_notificationCommandManger = new MockNotificationCommandManager(ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notification-commands.xml"));
m_notificationManager = new MockNotificationManager(m_notifdConfig, m_db, ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notifications.xml"));
m_pollOutagesConfigManager = new MockPollerConfig(m_network);
m_anticipator = new NotificationAnticipator();
MockNotificationStrategy.setAnticipator(m_anticipator);
m_notifd.setConfigManager(m_notifdConfig);
m_eventProcessor.setEventManager(m_eventMgr);
m_eventProcessor.setNotifdConfigManager(m_notifdConfig);
m_eventProcessor.setGroupManager(m_groupManager);
m_eventProcessor.setUserManager(m_userManager);
m_eventProcessor.setDestinationPathManager(m_destinationPathManager);
m_eventProcessor.setNotificationCommandManager(m_notificationCommandManger);
m_eventProcessor.setNotificationManager(m_notificationManager);
m_eventProcessor.setPollOutagesConfigManager(m_pollOutagesConfigManager);
m_notifd.init();
m_notifd.start();
// Date downDate = new Date();
// anticipateNotificationsForGroup("node 2 down.", "All services are down on node 2.", "InitialGroup", downDate, 0);
//
// //bring node down now
// m_eventMgr.sendEventToListeners(m_network.getNode(2).createDownEvent(downDate));
//
// m_anticipator.waitForAnticipated(2000);
//
// m_anticipator.reset();
MockUtil.println("################ Finish Setup ################");
}
Aggregations