@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" ); 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()); 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()); Utils.deleteFilesRecursively( instanceDirectory ); }
private void execute( String actionName, Instance instance ) throws PluginException { Properties props = readProperties( instance ); for( Action action : findActions( actionName, props )) executeAction( action ); }
PluginFile implements PluginInterface { private void execute( String actionName, Instance instance ) throws PluginException { Properties props = readProperties( instance ); for( Action action : findActions( actionName, props )) executeAction( action ); } }
PluginFile implements PluginInterface { private void execute( String actionName, Instance instance ) throws PluginException { Properties props = readProperties( instance ); for( Action action : findActions( actionName, props )) executeAction( action ); }  }
PluginFile implements PluginInterface { private void execute( String actionName, Instance instance ) throws PluginException { Properties props = readProperties( instance ); for( Action action : findActions( actionName, props )) executeAction( action ); }  @Override String getPluginName(); @Override void setNames( String applicationName, String rootInstanceName ); @Override void initialize( Instance instance ); @Override void deploy( Instance instance ); @Override void start( Instance instance ); @Override void update( Instance instance, Import importChanged, InstanceStatus statusChanged ); @Override void stop( Instance instance ); @Override void undeploy( Instance instance ); }
PluginFile implements PluginInterface { private void execute( String actionName, Instance instance ) throws PluginException { Properties props = readProperties( instance ); for( Action action : findActions( actionName, props )) executeAction( action ); }  @Override String getPluginName(); @Override void setNames( String applicationName, String rootInstanceName ); @Override void initialize( Instance instance ); @Override void deploy( Instance instance ); @Override void start( Instance instance ); @Override void update( Instance instance, Import importChanged, InstanceStatus statusChanged ); @Override void stop( Instance instance ); @Override void undeploy( Instance instance ); static final String PLUGIN_NAME; }