@Test public void testConsume() throws Exception { final ItemQueue queue = spy(new ItemQueue()); for (int id = 0; id < ITEM_COUNT; id++) { queue.put(new Item("producer", id)); } reset(queue); final Consumer consumer = new Consumer("consumer", queue); for (int id = 0; id < ITEM_COUNT; id++) { consumer.consume(); } verify(queue, times(ITEM_COUNT)).take(); }
public void consume() throws InterruptedException { Item item = queue.take(); LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer()); }
Consumer { public void consume() throws InterruptedException { Item item = queue.take(); LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer()); } }
Consumer { public void consume() throws InterruptedException { Item item = queue.take(); LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer()); } Consumer(String name, ItemQueue queue); }
Consumer { public void consume() throws InterruptedException { Item item = queue.take(); LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer()); } Consumer(String name, ItemQueue queue); void consume(); }
Consumer { public void consume() throws InterruptedException { Item item = queue.take(); LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer()); } Consumer(String name, ItemQueue queue); void consume();  }