Search in sources :

Example 21 with ThrowableAnticipator

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

the class ResourceTreeWalkerTest method testAfterPropertiesSetNoResourceDao.

public void testAfterPropertiesSetNoResourceDao() {
    ResourceTreeWalker walker = new ResourceTreeWalker();
    walker.setResourceDao(null);
    walker.setVisitor(m_visitor);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property resourceDao must be set to a non-null value"));
    m_mocks.replayAll();
    try {
        walker.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
    m_mocks.verifyAll();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 22 with ThrowableAnticipator

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

the class ResourceTypeFilteringResourceVisitorTest method testAfterPropertiesSetNoDelegatedVisitor.

public void testAfterPropertiesSetNoDelegatedVisitor() throws Exception {
    ResourceTypeFilteringResourceVisitor filteringVisitor = new ResourceTypeFilteringResourceVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property delegatedVisitor must be set to a non-null value"));
    filteringVisitor.setDelegatedVisitor(null);
    filteringVisitor.setResourceTypeMatch("interfaceSnmp");
    try {
        filteringVisitor.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 23 with ThrowableAnticipator

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

the class ResourceTypeFilteringResourceVisitorTest method testAfterPropertiesSetNoResourceTypeMatch.

public void testAfterPropertiesSetNoResourceTypeMatch() throws Exception {
    ResourceTypeFilteringResourceVisitor filteringVisitor = new ResourceTypeFilteringResourceVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property resourceTypeMatch must be set to a non-null value"));
    filteringVisitor.setDelegatedVisitor(m_delegatedVisitor);
    filteringVisitor.setResourceTypeMatch(null);
    try {
        filteringVisitor.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 24 with ThrowableAnticipator

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

the class DefaultDistributedPollerServiceTest method testDeleteLocationMonitorNullCommand.

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

Example 25 with ThrowableAnticipator

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

the class DefaultDistributedStatusServiceTest method testFindLocationSpecificStatusInvalidLocation.

public void testFindLocationSpecificStatusInvalidLocation() {
    DistributedStatusDetailsCommand command = new DistributedStatusDetailsCommand();
    Errors errors = new BindException(command, "command");
    command.setLocation("invalid location");
    command.setApplication(m_application1.getName());
    expect(m_monitoringLocationDao.get(command.getLocation())).andReturn(null);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("Could not find location for location name \"" + command.getLocation() + "\""));
    m_easyMockUtils.replayAll();
    try {
        m_service.findLocationSpecificStatus(command, errors);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    m_easyMockUtils.verifyAll();
    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