@Test
public void testPrepareConfiguration() throws Exception {

	// Prepare the mocks
	File tmpDir = this.folder.newFolder();
	TargetHandlerParameters parameters = new TargetHandlerParameters()
			.targetProperties( new HashMap<String,String>( 0 ));
	SSHClient ssh = Mockito.mock( SSHClient.class );
	SCPFileTransfer scp = Mockito.mock( SCPFileTransfer.class );
	Mockito.when( ssh.newSCPFileTransfer()).thenReturn( scp );
	// Invoke the method
	EmbeddedHandler embedded = new EmbeddedHandler();
	embedded.karafData = this.folder.newFolder().getAbsolutePath();
	ConfiguratorOnCreation configurator = new ConfiguratorOnCreation( parameters, "ip", "machineId", embedded );
	Map<String,String> keyToNewValue = configurator.prepareConfiguration( parameters, ssh, tmpDir );
	// We made one upload for this method!
	Mockito.verify( scp ).upload(
			Mockito.any( LocalSourceFile.class ),
			Mockito.anyString());
	// Prevent a compilation warning about leaks
	configurator.close();
	// Verify the map's content
	Assert.assertEquals( 4, keyToNewValue.size());
	Assert.assertEquals( "", keyToNewValue.get( AGENT_APPLICATION_NAME ));
	Assert.assertEquals( "", keyToNewValue.get( AGENT_SCOPED_INSTANCE_PATH ));
	Assert.assertEquals( "", keyToNewValue.get( AGENT_DOMAIN ));
	Assert.assertEquals( "file:" + DEFAULT_SCP_AGENT_CONFIG_DIR + "/" + USER_DATA_FILE, keyToNewValue.get( AGENT_PARAMETERS ));
}