@Test
public void testExecute() throws Exception {

	Instance instance = new Instance( "inst" ).component( new Component( "c" ).installerName( "whatever" ));
	PluginFile plugin = new PluginFile();
	plugin.setNames( "my-app", "my-root" );
	// We execute a full life cycle here.
	// Let's prepare it.
	File instructionsFile = TestUtils.findTestFile( "/instructions.properties" );
	Assert.assertTrue( instructionsFile.exists());
	File resourceFile = TestUtils.findTestFile( "/resource.txt" );
	Assert.assertTrue( resourceFile.exists());
	String s = Utils.readFileContent( instructionsFile );
	s = s.replace( "$URL", resourceFile.toURI().toURL().toString());
	String path = System.getProperty( "java.io.tmpdir" );
	if( path.endsWith( "/" ))
		path = path.substring( 0, path.length() - 1 );
	s = s.replace( "$TMP", path );
	File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance );
	Utils.deleteFilesRecursively( instanceDirectory );
	Assert.assertTrue( instanceDirectory.mkdirs());
	File targetFile = new File( instanceDirectory, PluginFile.FILE_NAME );
	Utils.writeStringInto( s, targetFile );
	Assert.assertTrue( targetFile.exists());
	// Now, let's run it.
	File tmpFile = new File( path, PluginFile.TMP_FILE );
	File bckFile = new File( path, PluginFile.TMP_FILE + "_bck" );
	File file_2 = new File( path, PluginFile.TMP_FILE + "_2" );
	Utils.deleteFilesRecursively( tmpFile, bckFile, file_2 );
	Assert.assertFalse( tmpFile.exists());
	Assert.assertFalse( bckFile.exists());
	Assert.assertFalse( file_2.exists());
	plugin.deploy( instance );
	Assert.assertTrue( tmpFile.exists());
	Assert.assertTrue( bckFile.exists());
	Assert.assertFalse( file_2.exists());
	plugin.start( instance );
	Assert.assertFalse( tmpFile.exists());
	Assert.assertTrue( bckFile.exists());
	Assert.assertTrue( file_2.exists());
	plugin.update( instance, null, null );
	Assert.assertFalse( tmpFile.exists());
	Assert.assertTrue( bckFile.exists());
	Assert.assertTrue( file_2.exists());
	plugin.stop( instance );
	Assert.assertTrue( tmpFile.exists());
	Assert.assertTrue( bckFile.exists());
	Assert.assertFalse( file_2.exists());
	plugin.undeploy( instance );
	Assert.assertFalse( tmpFile.exists());
	Assert.assertFalse( bckFile.exists());
	Assert.assertFalse( file_2.exists());
	// Clean...
	Utils.deleteFilesRecursively( instanceDirectory );
}