Hi team,
Just so you know, if you ever need to assert that a certain log is produced
in your JUnit tests, there's now a tool to do just that in Hibernate
Search: org.hibernate.search.test.util.impl.ExpectedLog4jLog [1]
You may use it much like you would use the ExpectedException rule:
public class MyTest {
@org.junit.Rule
public ExpectedLog4jLog logged = ExpectedLog4jLog.create();
@Test
public void test() {
logged.expectMessage( "HSEARCH400032", "some substring I want in the same
log" );
// ... Do test ...
}
}
You can also assert more complex conditions on the logs, using
a org.hamcrest.Matcher<? extends LoggingEvent>, but then it's starting to
get a bit exotic.
You may find an example of real-life use at [2].
[1]
https://github.com/hibernate/hibernate-search/blob/master/engine/src/test...
[2]
https://github.com/hibernate/hibernate-search/blob/master/elasticsearch/s...
Cheers,
Yoann Rodière <yoann(a)hibernate.org>
Hibernate NoORM Team