CommandHandlerShould.java 文件源码

java
阅读 52 收藏 0 点赞 0 评论 0

项目:core-java 作者:
@Test
public void log_errors() {
    final CommandEnvelope commandEnvelope = givenCommandEnvelope();

    // Since we're in the tests mode `Environment` returns `SubstituteLogger` instance.
    final SubstituteLogger log = (SubstituteLogger) handler.log();

    // Restrict the queue size only to the number of calls we want to make.
    final Queue<SubstituteLoggingEvent> queue = Queues.newArrayBlockingQueue(1);
    log.setDelegate(new EventRecodingLogger(log, queue));

    SubstituteLoggingEvent loggingEvent;

    final RuntimeException exception = new RuntimeException("log_errors");
    handler.onError(commandEnvelope, exception);

    loggingEvent = queue.poll();

    assertEquals(Level.ERROR, loggingEvent.getLevel());
    assertEquals(commandEnvelope, handler.getLastErrorEnvelope());
    assertEquals(exception, handler.getLastException());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号