Search in sources :

Example 61 with ThrowableAnticipator

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

the class EventIpcManagerDefaultImplTest method testAddEventListenerTwoArgumentStringNullUeiList.

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

Example 62 with ThrowableAnticipator

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

the class EventIpcManagerDefaultImplTest method testSendNowNullEvent.

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

Example 63 with ThrowableAnticipator

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

the class JRobinRrdStrategyTest method testSampleSetFloatingPointValueWithExtraJunk.

/**
 * This test fails because of
 * <a href="http://bugzilla.opennms.org/show_bug.cgi?id=2272">bug #2272</a>
 * in org.jrobin.core.Sample.
 */
@Test
@Ignore("fails due to bug 2272")
public void testSampleSetFloatingPointValueWithExtraJunk() throws Exception {
    File rrdFile = createRrdFile();
    RrdDb openedFile = m_strategy.openFile(rrdFile.getAbsolutePath());
    Sample sample = openedFile.createSample();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new Exception("Some exception that complains about bogus data"));
    try {
        sample.set("N:1.234 extra junk");
    } catch (Throwable t) {
        ta.throwableReceived(t);
    } finally {
        m_strategy.closeFile(openedFile);
    }
    ta.verifyAnticipated();
}
Also used : Sample(org.jrobin.core.Sample) RrdDb(org.jrobin.core.RrdDb) File(java.io.File) RrdException(org.opennms.netmgt.rrd.RrdException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 64 with ThrowableAnticipator

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

the class XmlDataCollectionConfigDaoJaxbTest method testAfterPropertiesSetWithNoConfigSet.

/**
 * Test after properties set with no configuration set.
 */
@Test
public void testAfterPropertiesSetWithNoConfigSet() {
    XmlDataCollectionConfigDaoJaxb dao = new XmlDataCollectionConfigDaoJaxb();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property configResource must be set and be non-null"));
    try {
        dao.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 65 with ThrowableAnticipator

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

the class AttributeMatchingResourceVisitorTest method testAfterPropertiesSetNoAttributeVisitor.

public void testAfterPropertiesSetNoAttributeVisitor() throws Exception {
    AttributeMatchingResourceVisitor resourceVisitor = new AttributeMatchingResourceVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property attributeVisitor must be set to a non-null value"));
    resourceVisitor.setAttributeVisitor(null);
    resourceVisitor.setAttributeMatch("ifInOctets");
    try {
        resourceVisitor.afterPropertiesSet();
    } 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