QuoteEngine implements IQuoteEngine { public void fireErrorEvent(QuoteError error) { synchronized (errorListeners) { for (int i = 0; i < errorListeners.size(); i++) { ((ErrorListener) errorListeners.get(i)).quoteEngineError(error); } } } QuoteEngine(); void addErrorListener(ErrorListener listener); void removeErrorListener(ErrorListener listener); void fireErrorEvent(QuoteError error); void subscribeLevel1(Ticker ticker, Level1QuoteListener listener); void unsubscribeLevel1(Ticker ticker, Level1QuoteListener listener); @Override void fireLevel1Quote(final ILevel1Quote quote); @Override void fireMarketDepthQuote(ILevel2Quote quote); void subscribeMarketDepth(Ticker ticker, Level2QuoteListener listener); void unsubscribeMarketDepth(Ticker ticker, Level2QuoteListener listener);  }
@Test public void testFireErrorEvent() { QuoteEngine engine = createNewQuoteEngine(); QuoteError error = new QuoteError( "foo" ); final StringBuffer sb = new StringBuffer(); ErrorListener listener = new ErrorListener() { public void quoteEngineError(QuoteError error) { sb.append( error.getMessage() ); } }; engine.addErrorListener(listener); engine.fireErrorEvent(error); assertEquals( "foo", sb.toString() ); }