@Test
public void testRemoveInstanceNotImmediately() throws Exception {

	// Prepare the manager
	INotificationMngr notificationMngr = Mockito.mock( INotificationMngr.class );
	IRandomMngr randomMngr = Mockito.mock( IRandomMngr.class );
	ITargetConfigurator targetConfigurator = Mockito.mock( ITargetConfigurator.class );
	IMessagingMngr messagingMngr = Mockito.mock( IMessagingMngr.class );
	ITargetsMngr targetsMngr = Mockito.mock( ITargetsMngr.class );
	IConfigurationMngr configurationMngr = new ConfigurationMngrImpl();
	configurationMngr.setWorkingDirectory( this.folder.newFolder());
	IInstancesMngr mngr = new InstancesMngrImpl( messagingMngr, notificationMngr, targetsMngr, randomMngr, targetConfigurator );
	// No immediate deletion => marker
	TestApplication app = new TestApplication();
	app.setDirectory( this.folder.newFolder());
	ManagedApplication ma = new ManagedApplication( app );
	app.getMySqlVm().setStatus( InstanceStatus.DEPLOYED_STARTED );
	mngr.removeInstance( ma, app.getMySqlVm(), false );
	// Verify it was not deleted but marked
	Assert.assertEquals( app.getMySqlVm(), InstanceHelpers.findInstanceByPath( app, "/" + app.getMySqlVm().getName()));
	Assert.assertEquals( "true", app.getMySqlVm().data.get( Instance.DELETE_WHEN_NOT_DEPLOYED ));
}