Search in sources :

Example 71 with ThrowableAnticipator

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();
}
Also used : SQLException(java.sql.SQLException) IOException(java.io.IOException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 72 with ThrowableAnticipator

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();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 73 with ThrowableAnticipator

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();
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 74 with ThrowableAnticipator

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();
}
Also used : StringReader(java.io.StringReader) SQLException(java.sql.SQLException) IOException(java.io.IOException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 75 with ThrowableAnticipator

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();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Aggregations

ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)105 Test (org.junit.Test)44 Ignore (org.junit.Ignore)12 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)9 Threshold (org.opennms.netmgt.config.threshd.Threshold)8 BindException (org.springframework.validation.BindException)8 Date (java.util.Date)6 LocationMonitorIdCommand (org.opennms.web.svclayer.model.LocationMonitorIdCommand)6 MarshallingResourceFailureException (org.opennms.core.xml.MarshallingResourceFailureException)4 DistributedStatusDetailsCommand (org.opennms.web.svclayer.model.DistributedStatusDetailsCommand)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStreamResource (org.springframework.core.io.InputStreamResource)4 Resource (org.springframework.core.io.Resource)4 Errors (org.springframework.validation.Errors)4 File (java.io.File)3 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 JdbcFilterDao (org.opennms.netmgt.filter.JdbcFilterDao)2 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)2 RrdException (org.opennms.netmgt.rrd.RrdException)2