use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class InstallerDbIT method testCatchSnmpInterfaceHasNullNodeIdValueOnUpgrade.
@Test
@Ignore("Tests deprecated upgrade functions of InstallerDb")
public void testCatchSnmpInterfaceHasNullNodeIdValueOnUpgrade() throws Exception {
getInstallerDb().createSequences();
getInstallerDb().updatePlPgsql();
getInstallerDb().addStoredProcedures();
addTableFromSQL("distpoller");
addTableFromSQL("node");
addTableFromSQLWithReplacements("snmpinterface", new String[][] { new String[] { "(?i)nodeID\\s+integer not null,", "nodeId integer," } });
executeSQL("INSERT INTO node (nodeId, nodeCreateTime) VALUES ( 1, now() )");
executeSQL("INSERT INTO snmpInterface (nodeId, snmpIfIndex) VALUES ( null, 1 )");
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new Exception("Error changing table 'snmpinterface'. Nested exception: The 'nodeId' column in the 'snmpInterface' table should never be null, but the entry for this row does have a null 'nodeId' column. It needs to be removed or udpated to reflect a valid 'nodeId' value."));
try {
getInstallerDb().createTables();
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class BroadcastEventProcessorTest method testInstantiateWithNullEventIpcManager.
public void testInstantiateWithNullEventIpcManager() {
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalArgumentException("argument eventIpcManager must not be null"));
try {
new BroadcastEventProcessor(null, m_eventConfDao);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class BroadcastEventProcessorTest method testInstantiateWithNullEventConfDao.
public void testInstantiateWithNullEventConfDao() {
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalArgumentException("argument eventConfDao must not be null"));
try {
new BroadcastEventProcessor(new MockEventIpcManager(), null);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class InstallerDbIT method testConstraintOnBogusColumn.
@Test
public void testConstraintOnBogusColumn() throws Exception {
String s_create_sql = " create table distPoller (\n" + " dpName varchar(12),\n" + " dpIP text not null,\n" + " dpComment varchar(256),\n" + " dpDiscLimit numeric(5,2),\n" + " dpLastNodePull timestamp without time zone,\n" + " dpLastEventPull timestamp without time zone,\n" + " dpLastPackagePush timestamp without time zone,\n" + " dpAdminState integer,\n" + " dpRunState integer,\n" + " constraint pk_dpName primary key (dpNameBogus) );\n";
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new Exception("constraint pk_dpname references column \"dpnamebogus\", which is not a column in the table distpoller"));
getInstallerDb().readTables(new StringReader(s_create_sql));
try {
getInstallerDb().getTableColumnsFromSQL("distpoller");
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class EventIpcManagerFactoryTest method testGetIpcManagerNotInitialized.
public void testGetIpcManagerNotInitialized() {
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalStateException("this factory has not been initialized"));
try {
EventIpcManagerFactory.getIpcManager();
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
Aggregations