Search in sources :

Example 1 with LoggingListener

use of org.elasticsearch.test.junit.listeners.LoggingListener in project elasticsearch by elastic.

the class LoggingListenerTests method testTestRunStartedSupportsClassInDefaultPackage.

public void testTestRunStartedSupportsClassInDefaultPackage() throws Exception {
    LoggingListener loggingListener = new LoggingListener();
    Description description = Description.createTestDescription(Class.forName("Dummy"), "dummy");
    // Will throw an exception without the check for testClassPackage != null in testRunStarted
    loggingListener.testRunStarted(description);
}
Also used : Description(org.junit.runner.Description) LoggingListener(org.elasticsearch.test.junit.listeners.LoggingListener)

Example 2 with LoggingListener

use of org.elasticsearch.test.junit.listeners.LoggingListener in project elasticsearch by elastic.

the class LoggingListenerTests method testInvalidMethodTestLoggingAnnotation.

public void testInvalidMethodTestLoggingAnnotation() throws Exception {
    final LoggingListener loggingListener = new LoggingListener();
    final Description suiteDescription = Description.createSuiteDescription(InvalidMethod.class);
    loggingListener.testRunStarted(suiteDescription);
    final Method method = InvalidMethod.class.getMethod("invalidMethod");
    final TestLogging annotation = method.getAnnotation(TestLogging.class);
    Description testDescription = Description.createTestDescription(InvalidMethod.class, "invalidMethod", annotation);
    final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> loggingListener.testStarted(testDescription));
    assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc:INFO:WARN]"));
}
Also used : Description(org.junit.runner.Description) TestLogging(org.elasticsearch.test.junit.annotations.TestLogging) LoggingListener(org.elasticsearch.test.junit.listeners.LoggingListener) Method(java.lang.reflect.Method)

Example 3 with LoggingListener

use of org.elasticsearch.test.junit.listeners.LoggingListener in project crate by crate.

the class LoggingListenerTests method testTestRunStartedSupportsClassInDefaultPackage.

public void testTestRunStartedSupportsClassInDefaultPackage() throws Exception {
    LoggingListener loggingListener = new LoggingListener();
    Description description = Description.createTestDescription(Class.forName("Dummy"), "dummy");
    // Will throw an exception without the check for testClassPackage != null in testRunStarted
    loggingListener.testRunStarted(description);
}
Also used : Description(org.junit.runner.Description) LoggingListener(org.elasticsearch.test.junit.listeners.LoggingListener)

Example 4 with LoggingListener

use of org.elasticsearch.test.junit.listeners.LoggingListener in project crate by crate.

the class LoggingListenerTests method testInvalidMethodTestLoggingAnnotation.

public void testInvalidMethodTestLoggingAnnotation() throws Exception {
    final LoggingListener loggingListener = new LoggingListener();
    final Description suiteDescription = Description.createSuiteDescription(InvalidMethod.class);
    loggingListener.testRunStarted(suiteDescription);
    final Method method = InvalidMethod.class.getMethod("invalidMethod");
    final TestLogging annotation = method.getAnnotation(TestLogging.class);
    Description testDescription = Description.createTestDescription(InvalidMethod.class, "invalidMethod", annotation);
    final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> loggingListener.testStarted(testDescription));
    assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc:INFO:WARN]"));
}
Also used : Description(org.junit.runner.Description) TestLogging(org.elasticsearch.test.junit.annotations.TestLogging) LoggingListener(org.elasticsearch.test.junit.listeners.LoggingListener) Method(java.lang.reflect.Method)

Example 5 with LoggingListener

use of org.elasticsearch.test.junit.listeners.LoggingListener in project crate by crate.

the class LoggingListenerTests method testInvalidClassTestLoggingAnnotation.

public void testInvalidClassTestLoggingAnnotation() throws Exception {
    final LoggingListener loggingListener = new LoggingListener();
    final Description suiteDescription = Description.createSuiteDescription(InvalidClass.class);
    final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> loggingListener.testRunStarted(suiteDescription));
    assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc]"));
}
Also used : Description(org.junit.runner.Description) LoggingListener(org.elasticsearch.test.junit.listeners.LoggingListener)

Aggregations

LoggingListener (org.elasticsearch.test.junit.listeners.LoggingListener)12 Description (org.junit.runner.Description)12 Method (java.lang.reflect.Method)6 Level (org.apache.logging.log4j.Level)6 Logger (org.apache.logging.log4j.Logger)6 TestLogging (org.elasticsearch.test.junit.annotations.TestLogging)6 Result (org.junit.runner.Result)6