Search in sources :

Example 66 with ThrowableAnticipator

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

the class JavaMailerTest method testJavaMailerWithEmptyMessageText.

@Test
@Ignore
public final void testJavaMailerWithEmptyMessageText() throws Exception {
    JavaMailer jm = createMailer("Test message from testJavaMailer without MTA");
    jm.setMessageText("");
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new JavaMailerException("Cannot have an empty messageText."));
    try {
        jm.mailSend();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 67 with ThrowableAnticipator

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

the class JavaMailerTest method testJavaMailerWithEmptyFrom.

@Test
@Ignore
public final void testJavaMailerWithEmptyFrom() throws Exception {
    JavaMailer jm = createMailer("Test message from testJavaMailer without MTA");
    jm.setFrom("");
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new JavaMailerException("Cannot have an empty from address."));
    try {
        jm.mailSend();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 68 with ThrowableAnticipator

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

the class JavaMailerTest method testJavaMailerWithNullMessageText.

@Test
@Ignore
public final void testJavaMailerWithNullMessageText() throws Exception {
    JavaMailer jm = createMailer("Test message from testJavaMailer without MTA");
    jm.setMessageText(null);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new JavaMailerException("Cannot have a null messageText."));
    try {
        jm.mailSend();
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 69 with ThrowableAnticipator

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

the class AbstractJaxbConfigDaoTest method testAfterPropertiesSetWithBogusFileResource.

public void testAfterPropertiesSetWithBogusFileResource() throws Exception {
    Resource resource = new FileSystemResource("/bogus-file");
    TestJaxbConfigDao dao = new TestJaxbConfigDao();
    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 70 with ThrowableAnticipator

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

the class JdbcDataCollectionConfigDaoJaxbTest method testAfterPropertiesSetWithNoConfigSet.

public void testAfterPropertiesSetWithNoConfigSet() {
    JdbcDataCollectionConfigDaoJaxb dao = new JdbcDataCollectionConfigDaoJaxb();
    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)

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