Search in sources :

Example 1 with LogCaptureRule

use of org.opendaylight.infrautils.testutils.LogCaptureRule in project infrautils by opendaylight.

the class LogCaptureRuleInternalTest method testLogCaptureRuleExpectErrorNegative.

@Test(expected = LogCaptureRuleException.class)
@SuppressWarnings("checkstyle:IllegalThrows")
public void testLogCaptureRuleExpectErrorNegative() throws Throwable {
    LogCaptureRule logCaptureRule = new LogCaptureRule();
    logCaptureRule.expectError("...");
    logCaptureRule.apply(new Statement() {

        @Override
        public void evaluate() throws Throwable {
        // do not LOG.error("boum")
        }
    }, Description.EMPTY).evaluate();
}
Also used : Statement(org.junit.runners.model.Statement) LogCaptureRule(org.opendaylight.infrautils.testutils.LogCaptureRule) Test(org.junit.Test)

Example 2 with LogCaptureRule

use of org.opendaylight.infrautils.testutils.LogCaptureRule in project infrautils by opendaylight.

the class LogCaptureRuleInternalTest method testLogCaptureRuleExpectErrorPositive.

@Test
@SuppressWarnings("checkstyle:IllegalThrows")
public void testLogCaptureRuleExpectErrorPositive() throws Throwable {
    LogCaptureRule logCaptureRule = new LogCaptureRule();
    logCaptureRule.expectError("boum");
    logCaptureRule.apply(new Statement() {

        @Override
        public void evaluate() throws Throwable {
            LOG.error("boum");
        }
    }, Description.EMPTY).evaluate();
}
Also used : Statement(org.junit.runners.model.Statement) LogCaptureRule(org.opendaylight.infrautils.testutils.LogCaptureRule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Statement (org.junit.runners.model.Statement)2 LogCaptureRule (org.opendaylight.infrautils.testutils.LogCaptureRule)2