PluginScript implements PluginInterface { @Override public void update(Instance instance, Import importChanged, InstanceStatus statusChanged) throws PluginException { this.logger.fine( this.agentId + " is updating instance " + instance ); try { prepareAndExecuteCommand( "update", instance, importChanged, statusChanged ); } catch( Exception e ) { throw new PluginException( e ); } }  @Override String getPluginName(); @Override void setNames( String applicationName, String scopedInstancePath ); @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; }
@Test public void testUpdate() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/BashScript" ); File file = new File( OUTPUT_DIR, "BashScriptFile.update" ); Assert.assertFalse( file.exists()); Import importChanged = new Import( this.inst ); InstanceStatus statusChanged = InstanceStatus.DEPLOYED_STARTED; this.plugin.update( this.inst, importChanged, statusChanged ); assertTrue( file.exists()); }
@Test( expected = PluginException.class ) public void testUpdate_exception() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/BashScriptError" ); Import importChanged = new Import( this.inst ); InstanceStatus statusChanged = InstanceStatus.DEPLOYED_STARTED; this.plugin.update( this.inst, importChanged, statusChanged ); }
@Test public void testUpdate_template() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/BashTemplate" ); File file = new File( OUTPUT_DIR, "BashTemplateFile.update" ); Assert.assertFalse( file.exists()); Map<String,String> exports = new HashMap<String,String> (); exports.put( "ip", "127.0.0.1" ); exports.put( "port", "8091" ); Import importChanged = new Import( InstanceHelpers.computeInstancePath( this.inst ), this.inst.getComponent().getName(), exports ); InstanceStatus statusChanged = InstanceStatus.DEPLOYED_STARTED; this.plugin.update( this.inst, importChanged, statusChanged ); assertTrue( file.exists()); }
@Test public void testUpdate_scriptWithExports() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/BashScript" ); File file = new File( OUTPUT_DIR, "BashScriptFile.update" ); Assert.assertFalse( file.exists()); Map<String,String> exports = new HashMap<String,String> (); exports.put( "ip", "127.0.0.1" ); exports.put( "port", "8091" ); Import importChanged = new Import( InstanceHelpers.computeInstancePath( this.inst ), this.inst.getComponent().getName(), exports ); InstanceStatus statusChanged = InstanceStatus.DEPLOYED_STARTED; this.plugin.update( this.inst, importChanged, statusChanged ); assertTrue( file.exists()); }