@Test public void topicMessage() { Threads.sleep(1000); LogbackListAppender appender = new LogbackListAppender(); appender.addToLogger(NotifyMessageListener.class); User user = new User(); user.setName("calvin"); user.setEmail("*****@*****.**"); notifyMessageProducer.sendTopic(user); logger.info("sended message"); Threads.sleep(1000); assertEquals("UserName:calvin, Email:[email protected]", appender.getFirstMessage()); }
@BeforeClass public static void initLogger() { // 加载测试用logger appender appender = new LogbackListAppender(); appender.addToLogger(UserCountScanner.class.getName() + ".jdk timer job"); }