ConfiguratorOnTermination extends ConfiguratorOnCreation { @Override Map<String,String> prepareConfiguration( TargetHandlerParameters parameters, SSHClient ssh, File tmpDir ) throws IOException { try { Map<String,String> keyToNewValue = new HashMap<> (); keyToNewValue.put( AGENT_APPLICATION_NAME, "" ); keyToNewValue.put( AGENT_SCOPED_INSTANCE_PATH, "" ); keyToNewValue.put( AGENT_DOMAIN, "" ); keyToNewValue.put( AGENT_PARAMETERS, Constants.AGENT_RESET ); return keyToNewValue; } finally { this.embedded.releaseIpAddress( this.ip ); } } ConfiguratorOnTermination(
			TargetHandlerParameters parameters,
			String ip,
			String machineId,
			EmbeddedHandler embedded );   }
@Test public void testPrepareConfiguration() throws Exception { 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 ); EmbeddedHandler embedded = new EmbeddedHandler(); embedded.karafData = this.folder.newFolder().getAbsolutePath(); ConfiguratorOnTermination configurator = new ConfiguratorOnTermination( parameters, "ip", "machineId", embedded ); Map<String,String> keyToNewValue = configurator.prepareConfiguration( parameters, ssh, tmpDir ); Mockito.verifyZeroInteractions( scp ); configurator.close(); 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( Constants.AGENT_RESET, keyToNewValue.get( AGENT_PARAMETERS )); }