IBQuoteProcessor implements Runnable { public void startProcessor() { if( ! started ) { started = true; thread.start(); } } IBQuoteProcessor( BlockingQueue<T> queue, IQuoteEngine quoteEngine ); void startProcessor(); void stopProcessor(); void run(); boolean isRunning();  }
@Test public void testStartProcessor() throws Exception { final BlockingQueue<Object> mockQueue = mockery.mock(BlockingQueue.class); IQuoteEngine mockQuoteEngine = mockery.mock( IQuoteEngine.class ); IBQuoteProcessor<Object> quoteProcessor = new MockIBQuoteProcessor(mockQueue, mockQuoteEngine); mockery.checking( new Expectations() {{ allowing(mockQueue).take(); will(returnValue( getNewObject() )); }} ); quoteProcessor.startProcessor(); assertTrue( quoteProcessor.isRunning() ); quoteProcessor.stopProcessor(); assertFalse( quoteProcessor.isRunning() ); }