### Question:
Consumer { public void consume() { while (true) { try { var msg = queue.take(); if (Message.POISON_PILL.equals(msg)) { LOGGER.info("Consumer {} receive request to terminate.", name); break; } var sender = msg.getHeader(Headers.SENDER); var body = msg.getBody(); LOGGER.info("Message [{}] from [{}] received by [{}]", body, sender, name); } catch (InterruptedException e) { LOGGER.error("Exception caught.", e); return; } } } Consumer(String name, MqSubscribePoint queue); void consume();  }### Answer:
@Test public void testConsume() throws Exception { final var messages = List.of( createMessage("you", "Hello!"), createMessage("me", "Hi!"), Message.POISON_PILL, createMessage("late_for_the_party", "Hello? Anyone here?") ); final var queue = new SimpleMessageQueue(messages.size()); for (final var message : messages) { queue.put(message); } new Consumer("NSA", queue).consume(); assertTrue(appender.logContains("Message [Hello!] from [you] received by [NSA]")); assertTrue(appender.logContains("Message [Hi!] from [me] received by [NSA]")); assertTrue(appender.logContains("Consumer NSA receive request to terminate.")); }