Search in sources :

Example 6 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class EventIpcManagerDefaultImplTest method testRemoveEventListenerNullListener.

public void testRemoveEventListenerNullListener() throws Exception {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("listener argument cannot be null"));
    try {
        m_manager.removeEventListener((EventListener) null);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 7 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class EventIpcManagerDefaultImplTest method testAddEventListenerTwoArgumentListNullListener.

public void testAddEventListenerTwoArgumentListNullListener() throws Exception {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("listener argument cannot be null"));
    try {
        m_manager.addEventListener((EventListener) null, new ArrayList<String>(0));
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 8 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class EventIpcManagerDefaultImplTest method testRemoveEventListenerTwoArgumentStringNullUeiList.

public void testRemoveEventListenerTwoArgumentStringNullUeiList() throws Exception {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("uei argument cannot be null"));
    try {
        m_manager.removeEventListener(m_listener, (String) null);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 9 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class SnmpMonitorStrategyTest method testErrorConditions.

@Test
public void testErrorConditions() {
    SnmpValue result = int32Value(1);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("operator X is unknown"));
    try {
        monitor.meetsCriteria(result, "X", "123");
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : SnmpValue(org.opennms.netmgt.snmp.SnmpValue) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 10 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class SnmpMonitorStrategyTest method testErrorConditions2.

@Test
public void testErrorConditions2() {
    SnmpValue result = int32Value(1);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new NumberFormatException("For input string: \"abc\""));
    try {
        monitor.meetsCriteria(result, "<", "abc");
        fail("expected an exception");
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : SnmpValue(org.opennms.netmgt.snmp.SnmpValue) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

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