@Test public void testAdd() throws RainbowException { System.out.println("add"); IRainbowMessage event1 = new RainbowESEBMessage(); IRainbowMessage event2 = new RainbowESEBMessage(); event1.setProperty(ESEBConstants.MSG_CHANNEL_KEY, "MODEL_DS"); event2.setProperty(ESEBConstants.MSG_CHANNEL_KEY, "MODEL_US"); EventBuffer instance = new EventBuffer(1); instance.activate(); instance.add(event1); instance.add(event2); List<IRainbowMessage> collection = new ArrayList<>(); int num = instance.drainToCollection(collection); assertEquals(1, num); IRainbowMessage result = collection.get(0); assertEquals(event1.toString(), result.toString()); }
@Override public void add(IRainbowMessage event) { if (isActive) { if (!queue.offer(event)) { Logger.getLogger(EventBuffer.class.getName()).warning( "Cannot add an event. The buffer is full."); } } }
EventBuffer implements IEventBuffer { @Override public void add(IRainbowMessage event) { if (isActive) { if (!queue.offer(event)) { Logger.getLogger(EventBuffer.class.getName()).warning( "Cannot add an event. The buffer is full."); } } } }
EventBuffer implements IEventBuffer { @Override public void add(IRainbowMessage event) { if (isActive) { if (!queue.offer(event)) { Logger.getLogger(EventBuffer.class.getName()).warning( "Cannot add an event. The buffer is full."); } } } EventBuffer(int size); }
EventBuffer implements IEventBuffer { @Override public void add(IRainbowMessage event) { if (isActive) { if (!queue.offer(event)) { Logger.getLogger(EventBuffer.class.getName()).warning( "Cannot add an event. The buffer is full."); } } } EventBuffer(int size); @Override int drainToCollection(Collection<IRainbowMessage> collection); @Override void add(IRainbowMessage event); @Override void clear(); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); }
EventBuffer implements IEventBuffer { @Override public void add(IRainbowMessage event) { if (isActive) { if (!queue.offer(event)) { Logger.getLogger(EventBuffer.class.getName()).warning( "Cannot add an event. The buffer is full."); } } } EventBuffer(int size); @Override int drainToCollection(Collection<IRainbowMessage> collection); @Override void add(IRainbowMessage event); @Override void clear(); @Override void activate(); @Override void deactivate(); @Override boolean isActive();  }