@Test public void testExpandProperties_noIp() throws Exception { Map<String,String> map = new HashMap<> (); map.put( "test.ip", "{{ip}}:4243" ); final Component component = new Component( "my-vm" ).installerName( Constants.TARGET_INSTALLER ); Instance instance = new Instance( "my-scope-instance" ).component( component ); Map<String,String> loadedProperties = TargetHelpers.expandProperties( instance, map ); Assert.assertNotNull( loadedProperties ); Assert.assertEquals( ":4243", loadedProperties.get("test.ip")); }
public static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); String ipAddress = scopedInstance.data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = InstanceHelpers.findRootInstance( scopedInstance ).data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = ""; Properties params = new Properties(); params.setProperty( Constants.SPECIFIC_VARIABLE_IP, ipAddress ); Map<String,String> newTargetProperties = new HashMap<>( targetProperties.size()); for( Map.Entry<String,String> entry : targetProperties.entrySet()) { String p = Utils.expandTemplate( entry.getValue(), params ); newTargetProperties.put( entry.getKey(), p ); if( ! p.equals( entry.getValue())) logger.fine( "Target property '" + entry.getKey() + "' was expanded to " + p ); } return newTargetProperties; }
TargetHelpers { public static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); String ipAddress = scopedInstance.data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = InstanceHelpers.findRootInstance( scopedInstance ).data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = ""; Properties params = new Properties(); params.setProperty( Constants.SPECIFIC_VARIABLE_IP, ipAddress ); Map<String,String> newTargetProperties = new HashMap<>( targetProperties.size()); for( Map.Entry<String,String> entry : targetProperties.entrySet()) { String p = Utils.expandTemplate( entry.getValue(), params ); newTargetProperties.put( entry.getKey(), p ); if( ! p.equals( entry.getValue())) logger.fine( "Target property '" + entry.getKey() + "' was expanded to " + p ); } return newTargetProperties; } }
TargetHelpers { public static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); String ipAddress = scopedInstance.data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = InstanceHelpers.findRootInstance( scopedInstance ).data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = ""; Properties params = new Properties(); params.setProperty( Constants.SPECIFIC_VARIABLE_IP, ipAddress ); Map<String,String> newTargetProperties = new HashMap<>( targetProperties.size()); for( Map.Entry<String,String> entry : targetProperties.entrySet()) { String p = Utils.expandTemplate( entry.getValue(), params ); newTargetProperties.put( entry.getKey(), p ); if( ! p.equals( entry.getValue())) logger.fine( "Target property '" + entry.getKey() + "' was expanded to " + p ); } return newTargetProperties; } private  TargetHelpers(); }
TargetHelpers { public static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); String ipAddress = scopedInstance.data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = InstanceHelpers.findRootInstance( scopedInstance ).data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = ""; Properties params = new Properties(); params.setProperty( Constants.SPECIFIC_VARIABLE_IP, ipAddress ); Map<String,String> newTargetProperties = new HashMap<>( targetProperties.size()); for( Map.Entry<String,String> entry : targetProperties.entrySet()) { String p = Utils.expandTemplate( entry.getValue(), params ); newTargetProperties.put( entry.getKey(), p ); if( ! p.equals( entry.getValue())) logger.fine( "Target property '" + entry.getKey() + "' was expanded to " + p ); } return newTargetProperties; } private  TargetHelpers(); static void verifyTargets(
			ITargetHandlerResolver targetHandlerResolver,
			ManagedApplication ma,
			ITargetsMngr targetsMngr ); static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ); static String findTargetHandlerName( Properties props ); static String findTargetHandlerName( Map<String,String> props ); }
TargetHelpers { public static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); String ipAddress = scopedInstance.data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = InstanceHelpers.findRootInstance( scopedInstance ).data.get( Instance.IP_ADDRESS ); if( ipAddress == null ) ipAddress = ""; Properties params = new Properties(); params.setProperty( Constants.SPECIFIC_VARIABLE_IP, ipAddress ); Map<String,String> newTargetProperties = new HashMap<>( targetProperties.size()); for( Map.Entry<String,String> entry : targetProperties.entrySet()) { String p = Utils.expandTemplate( entry.getValue(), params ); newTargetProperties.put( entry.getKey(), p ); if( ! p.equals( entry.getValue())) logger.fine( "Target property '" + entry.getKey() + "' was expanded to " + p ); } return newTargetProperties; } private  TargetHelpers(); static void verifyTargets(
			ITargetHandlerResolver targetHandlerResolver,
			ManagedApplication ma,
			ITargetsMngr targetsMngr ); static Map<String,String> expandProperties( Instance scopedInstance, Map<String,String> targetProperties ); static String findTargetHandlerName( Properties props ); static String findTargetHandlerName( Map<String,String> props );  }