Search in sources :

Example 91 with ThrowableAnticipator

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

the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNoDsType.

@Test
public void testConstructorThresholdNoDsType() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("threshold must have a 'ds-type' value set"));
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    threshold.setDsName("ds-name");
    threshold.setValue(1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    try {
        new ThresholdEvaluatorStateHighLow(wrapper);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 92 with ThrowableAnticipator

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

the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNoRearm.

@Test
public void testConstructorThresholdNoRearm() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("threshold must have a 'rearm' value set"));
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(1.0);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    try {
        new ThresholdEvaluatorStateHighLow(wrapper);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 93 with ThrowableAnticipator

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

the class AccessPointMonitorConfigDaoJaxbTest method testAfterPropertiesSetWithBogusFileResource.

public void testAfterPropertiesSetWithBogusFileResource() throws Exception {
    Resource resource = new FileSystemResource("/bogus-file");
    AccessPointMonitorConfigDaoJaxb dao = new AccessPointMonitorConfigDaoJaxb();
    dao.setConfigResource(resource);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new MarshallingResourceFailureException(ThrowableAnticipator.IGNORE_MESSAGE));
    try {
        dao.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : MarshallingResourceFailureException(org.opennms.core.xml.MarshallingResourceFailureException) InputStreamResource(org.springframework.core.io.InputStreamResource) FileSystemResource(org.springframework.core.io.FileSystemResource) Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 94 with ThrowableAnticipator

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

the class DefaultDistributedPollerServiceTest method testDeleteLocationMonitorNullBindException.

public void testDeleteLocationMonitorNullBindException() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("errors argument cannot be null"));
    LocationMonitorIdCommand command = new LocationMonitorIdCommand();
    replayMocks();
    try {
        m_distributedPollerService.deleteLocationMonitor(command, null);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
    verifyMocks();
}
Also used : LocationMonitorIdCommand(org.opennms.web.svclayer.model.LocationMonitorIdCommand) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 95 with ThrowableAnticipator

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

the class DefaultDistributedStatusServiceTest method testFindLocationSpecificStatusNullLocation.

public void testFindLocationSpecificStatusNullLocation() {
    DistributedStatusDetailsCommand command = new DistributedStatusDetailsCommand();
    Errors errors = new BindException(command, "command");
    command.setApplication(m_application1.getName());
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("location cannot be null"));
    try {
        m_service.findLocationSpecificStatus(command, errors);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : Errors(org.springframework.validation.Errors) DistributedStatusDetailsCommand(org.opennms.web.svclayer.model.DistributedStatusDetailsCommand) BindException(org.springframework.validation.BindException) 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