@Test @Ignore public void testPostEvent() throws Exception { EventLogListener eventLogListener = Mockito.mock(EventLogListener.class); EventLogImpl eventLog = new EventLogImpl(2, 4); eventLog.register(eventLogListener, Collections.singletonList(SimpleEvent.class)); SimpleEvent simpleEvent = new SimpleEvent("Simple event"); eventLog.postEvent(simpleEvent); Assert.assertTrue("Deque doesn't contain correct event.", eventLog.eventDeque.contains(simpleEvent)); Thread eventLogThread = runThread(eventLog); long time = 0; if (eventLog.eventDeque.size() > 0) { while (eventLog.eventDeque.size() > 0) { Thread.sleep(50); time += 50; if (time > 5000) { break; } } } eventLogThread.interrupt(); Mockito.verify(eventLogListener, Mockito.times(1)).postEvent(simpleEvent); }
@Override public void postEvent(EventLogEvent event) { if (event == null) { LOGGER.warn("skipping null EventLogEvent"); return; } eventDeque.offerLast(event); }
EventLogImpl implements EventLog { @Override public void postEvent(EventLogEvent event) { if (event == null) { LOGGER.warn("skipping null EventLogEvent"); return; } eventDeque.offerLast(event); } }
EventLogImpl implements EventLog { @Override public void postEvent(EventLogEvent event) { if (event == null) { LOGGER.warn("skipping null EventLogEvent"); return; } eventDeque.offerLast(event); } @Inject  EventLogImpl(@Named("eventlog.threadpoolsize.core") int threadPoolSizeCore,
                        @Named("eventlog.threadpoolsize.max") int threadPoolSizeMax); }
EventLogImpl implements EventLog { @Override public void postEvent(EventLogEvent event) { if (event == null) { LOGGER.warn("skipping null EventLogEvent"); return; } eventDeque.offerLast(event); } @Inject  EventLogImpl(@Named("eventlog.threadpoolsize.core") int threadPoolSizeCore,
                        @Named("eventlog.threadpoolsize.max") int threadPoolSizeMax); @Override void register(EventLogListener listener); @Override void register(EventLogListener listener, List<Class<? extends EventLogEvent>> events); @Override @SuppressWarnings("unchecked") void register(EventLogListener listener, String... events); @Override void postEvent(EventLogEvent event); @Override void run(); }
EventLogImpl implements EventLog { @Override public void postEvent(EventLogEvent event) { if (event == null) { LOGGER.warn("skipping null EventLogEvent"); return; } eventDeque.offerLast(event); } @Inject  EventLogImpl(@Named("eventlog.threadpoolsize.core") int threadPoolSizeCore,
                        @Named("eventlog.threadpoolsize.max") int threadPoolSizeMax); @Override void register(EventLogListener listener); @Override void register(EventLogListener listener, List<Class<? extends EventLogEvent>> events); @Override @SuppressWarnings("unchecked") void register(EventLogListener listener, String... events); @Override void postEvent(EventLogEvent event); @Override void run();  }