Class EventQueue<E>

  • Type Parameters:
    E - the type of entry in this EventQueue
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.BlockingQueue<E>, java.util.Queue<E>

    public class EventQueue<E>
    extends java.util.concurrent.LinkedBlockingQueue<E>
    Event Queue for capturing potential events within a testing scenario.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.locks.Condition countReached  
      static boolean DEBUG  
      private static long DEBUG_START  
      private int goalCount  
      private java.util.concurrent.locks.ReentrantLock lock  
    • Constructor Summary

      Constructors 
      Constructor Description
      EventQueue()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E o)  
      void awaitEventCount​(int expectedEventCount, int timeoutDuration, java.util.concurrent.TimeUnit timeoutUnit)
      Await a specific event count
      private void debug​(java.lang.String format, java.lang.Object... args)  
      private boolean goalCheck()  
      boolean offer​(E o)  
      void shutdown()
      Shutdown the queue.
      • Methods inherited from class java.util.concurrent.LinkedBlockingQueue

        clear, contains, drainTo, drainTo, forEach, iterator, offer, peek, poll, poll, put, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, take, toArray, toArray, toString
      • Methods inherited from class java.util.AbstractQueue

        addAll, element, remove
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        addAll, containsAll, equals, hashCode, isEmpty, parallelStream, stream, toArray
      • Methods inherited from interface java.util.Queue

        element, remove
    • Field Detail

      • DEBUG_START

        private static final long DEBUG_START
      • lock

        private final java.util.concurrent.locks.ReentrantLock lock
      • countReached

        private final java.util.concurrent.locks.Condition countReached
      • goalCount

        private int goalCount
    • Constructor Detail

      • EventQueue

        public EventQueue()
    • Method Detail

      • add

        public boolean add​(E o)
        Specified by:
        add in interface java.util.concurrent.BlockingQueue<E>
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.Queue<E>
        Overrides:
        add in class java.util.AbstractQueue<E>
      • awaitEventCount

        public void awaitEventCount​(int expectedEventCount,
                                    int timeoutDuration,
                                    java.util.concurrent.TimeUnit timeoutUnit)
                             throws java.util.concurrent.TimeoutException,
                                    java.lang.InterruptedException
        Await a specific event count
        Parameters:
        expectedEventCount - the number of events to wait for
        timeoutDuration - the timeout duration
        timeoutUnit - the timeout unit
        Throws:
        java.util.concurrent.TimeoutException - if timeout while waiting for the event count
        java.lang.InterruptedException - if await was interrupted
      • debug

        private void debug​(java.lang.String format,
                           java.lang.Object... args)
      • goalCheck

        private boolean goalCheck()
      • offer

        public boolean offer​(E o)
        Specified by:
        offer in interface java.util.concurrent.BlockingQueue<E>
        Specified by:
        offer in interface java.util.Queue<E>
        Overrides:
        offer in class java.util.concurrent.LinkedBlockingQueue<E>
      • shutdown

        public void shutdown()
        Shutdown the queue.