/** * Associates a message processor with this instance. * <p> * The message processor cannot be started before. This method will start it. * </p> * <p> * This method must be invoked only once. * </p> * @param messageProcessor the message processor */ public void associateMessageProcessor( AbstractMessageProcessor<T> messageProcessor ) { if( this.messageProcessor != null ) throw new IllegalArgumentException( "The message processor was already defined." ); this.messageProcessor = messageProcessor; configureMessageProcessor( messageProcessor ); this.messageProcessor.start(); }
/** * Associates a message processor with this instance. * <p> * The message processor cannot be started before. This method will start it. * </p> * <p> * This method must be invoked only once. * </p> * @param messageProcessor the message processor */ public void associateMessageProcessor( AbstractMessageProcessor<T> messageProcessor ) { if( this.messageProcessor != null ) throw new IllegalArgumentException( "The message processor was already defined." ); this.messageProcessor = messageProcessor; configureMessageProcessor( messageProcessor ); this.messageProcessor.start(); }
@Test public void testStartAndStop() throws Exception { Assert.assertFalse( this.processor.isRunning()); this.processor.start(); Thread.sleep( 200 ); Assert.assertTrue( this.processor.isRunning()); this.processor.stopProcessor();; Thread.sleep( 200 ); Assert.assertFalse( this.processor.isRunning()); }
@Test public void testInterrupt() throws Exception { Assert.assertFalse( this.processor.isRunning()); this.processor.start(); Thread.sleep( 200 ); Assert.assertTrue( this.processor.isRunning()); this.processor.interrupt(); Thread.sleep( 200 ); Assert.assertFalse( this.processor.isRunning()); }
@Test public void testProcessing() throws Exception { // The message is processed... this.processor.start(); this.processor.storeMessage( new MsgCmdResynchronize()); Thread.sleep( 1000 ); this.processor.stopProcessor(); Assert.assertEquals( 0, this.processor.getMessageQueue().size()); }