Search in sources :

Example 26 with ThrowableAnticipator

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

the class RrdStatisticAttributeVisitorTest method testAfterPropertiesSetNoConsolidationFunction.

public void testAfterPropertiesSetNoConsolidationFunction() throws Exception {
    RrdStatisticAttributeVisitor attributeVisitor = new RrdStatisticAttributeVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property consolidationFunction must be set to a non-null value"));
    attributeVisitor.setFetchStrategy(m_fetchStrategy);
    attributeVisitor.setConsolidationFunction(null);
    attributeVisitor.setStartTime(m_startTime);
    attributeVisitor.setEndTime(m_endTime);
    attributeVisitor.setStatisticVisitor(m_statisticVisitor);
    try {
        attributeVisitor.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 27 with ThrowableAnticipator

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

the class RrdStatisticAttributeVisitorTest method testAfterPropertiesSetNoRrdDao.

public void testAfterPropertiesSetNoRrdDao() throws Exception {
    RrdStatisticAttributeVisitor attributeVisitor = new RrdStatisticAttributeVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property fetchStrategy must be set to a non-null value"));
    attributeVisitor.setFetchStrategy(null);
    attributeVisitor.setConsolidationFunction("AVERAGE");
    attributeVisitor.setStartTime(m_startTime);
    attributeVisitor.setEndTime(m_endTime);
    attributeVisitor.setStatisticVisitor(m_statisticVisitor);
    try {
        attributeVisitor.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 28 with ThrowableAnticipator

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

the class RrdResourceAttributeUtilsTest method testLoadPropertiesNullRrdDirectory.

@Test
public void testLoadPropertiesNullRrdDirectory() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("rrdDirectory argument must not be null"));
    try {
        RrdResourceAttributeUtils.getStringProperties(null, "something");
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 29 with ThrowableAnticipator

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

the class RrdStatisticAttributeVisitorTest method testAfterPropertiesSetNoStatisticVisitor.

public void testAfterPropertiesSetNoStatisticVisitor() throws Exception {
    RrdStatisticAttributeVisitor attributeVisitor = new RrdStatisticAttributeVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property statisticVisitor must be set to a non-null value"));
    attributeVisitor.setFetchStrategy(m_fetchStrategy);
    attributeVisitor.setConsolidationFunction("AVERAGE");
    attributeVisitor.setStartTime(m_startTime);
    attributeVisitor.setEndTime(m_endTime);
    attributeVisitor.setStatisticVisitor(null);
    try {
        attributeVisitor.afterPropertiesSet();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 30 with ThrowableAnticipator

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

the class RrdStatisticAttributeVisitorTest method testAfterPropertiesSetNoStartTime.

public void testAfterPropertiesSetNoStartTime() throws Exception {
    RrdStatisticAttributeVisitor attributeVisitor = new RrdStatisticAttributeVisitor();
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("property startTime must be set to a non-null value"));
    attributeVisitor.setFetchStrategy(m_fetchStrategy);
    attributeVisitor.setConsolidationFunction("AVERAGE");
    attributeVisitor.setStartTime(null);
    attributeVisitor.setEndTime(m_endTime);
    attributeVisitor.setStatisticVisitor(m_statisticVisitor);
    try {
        attributeVisitor.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