@Test
public void testShutdownSignal() throws Exception {

	RoboconfMessageQueue messageQueue = new RoboconfMessageQueue();
	Channel channel = Mockito.mock( Channel.class );
	RoboconfConsumer rc = new RoboconfConsumer( "DM", channel, messageQueue );
	final StringHandler logHandler = new StringHandler();
	Logger logger = TestUtils.getInternalField( rc, "logger", Logger.class );
	logger.setUseParentHandlers( false );
	logger.setLevel( Level.FINE );
	logger.addHandler( logHandler );
	// Depending on the shutdown signal, we do not log the same message.
	ShutdownSignalException sig = Mockito.mock( ShutdownSignalException.class );
	Mockito.when( sig.isInitiatedByApplication()).thenReturn( true );
	rc.handleShutdownSignal( "tag", sig );
	String log1 = logHandler.getLogs();
	// Not initiated by the application, but the source is a channel.
	Mockito.reset( sig );
	Mockito.when( sig.isInitiatedByApplication()).thenReturn( false );
	Mockito.when( sig.getReference()).thenReturn( channel );
	logHandler.getStringBuilder().setLength( 0 );
	rc.handleShutdownSignal( "tag", sig );
	String log2 = logHandler.getLogs();
	// Not initiated by the application and the source is not a channel.
	Mockito.reset( sig );
	Mockito.when( sig.isInitiatedByApplication()).thenReturn( false );
	logHandler.getStringBuilder().setLength( 0 );
	rc.handleShutdownSignal( "tag", sig );
	String log3 = logHandler.getLogs();
	// The 3 messages should be different
	Assert.assertFalse( Utils.isEmptyOrWhitespaces( log1 ));
	Assert.assertFalse( Utils.isEmptyOrWhitespaces( log2 ));
	Assert.assertFalse( Utils.isEmptyOrWhitespaces( log3 ));
	Assert.assertFalse( log1.equals( log2 ));
	Assert.assertFalse( log1.equals( log3 ));
	Assert.assertFalse( log3.equals( log2 ));
}