@Test public void testInvalidExternalExports_2() throws Exception { File f = this.folder.newFile(); Utils.writeStringInto( "exports: HAProxy.ip as lb-ip HAProxy.httpPort as lb-port", f ); ApplicationTemplateDescriptor desc = ApplicationTemplateDescriptor.load( f ); Assert.assertEquals( 0, desc.externalExports.size()); Assert.assertEquals( 1, desc.invalidExternalExports.size()); Assert.assertEquals( "HAProxy.ip as lb-ip HAProxy.httpPort as lb-port", desc.invalidExternalExports.iterator().next()); }
public static ApplicationTemplateDescriptor load( Properties properties ) { ApplicationTemplateDescriptor result = new ApplicationTemplateDescriptor(); result.name = getLegacyProperty( properties, APPLICATION_NAME, null ); result.description = getLegacyProperty( properties, APPLICATION_DESCRIPTION, null ); result.version = getLegacyProperty( properties, APPLICATION_VERSION, null ); result.dslId = getLegacyProperty( properties, APPLICATION_DSL_ID, null ); result.graphEntryPoint = properties.getProperty( APPLICATION_GRAPH_EP, null ); result.instanceEntryPoint = properties.getProperty( APPLICATION_INSTANCES_EP, null ); result.externalExportsPrefix = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS_PREFIX, null ); final Pattern pattern = Pattern.compile( "([^=\\s]+)\\s+" + APPLICATION_EXTERNAL_EXPORTS_AS + "\\s+([^=\\s]+)", Pattern.CASE_INSENSITIVE ); String rawExports = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS, "" ); for( String rawExport : Utils.splitNicely( rawExports, "," )) { Matcher m = pattern.matcher( rawExport ); if( m.matches()) result.externalExports.put( m.group( 1 ), m.group( 2 )); else result.invalidExternalExports.add( rawExport ); } String rawTags = properties.getProperty( APPLICATION_TAGS, "" ); result.tags.addAll( Utils.splitNicely( rawTags, "," )); return result; }
ApplicationTemplateDescriptor { public static ApplicationTemplateDescriptor load( Properties properties ) { ApplicationTemplateDescriptor result = new ApplicationTemplateDescriptor(); result.name = getLegacyProperty( properties, APPLICATION_NAME, null ); result.description = getLegacyProperty( properties, APPLICATION_DESCRIPTION, null ); result.version = getLegacyProperty( properties, APPLICATION_VERSION, null ); result.dslId = getLegacyProperty( properties, APPLICATION_DSL_ID, null ); result.graphEntryPoint = properties.getProperty( APPLICATION_GRAPH_EP, null ); result.instanceEntryPoint = properties.getProperty( APPLICATION_INSTANCES_EP, null ); result.externalExportsPrefix = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS_PREFIX, null ); final Pattern pattern = Pattern.compile( "([^=\\s]+)\\s+" + APPLICATION_EXTERNAL_EXPORTS_AS + "\\s+([^=\\s]+)", Pattern.CASE_INSENSITIVE ); String rawExports = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS, "" ); for( String rawExport : Utils.splitNicely( rawExports, "," )) { Matcher m = pattern.matcher( rawExport ); if( m.matches()) result.externalExports.put( m.group( 1 ), m.group( 2 )); else result.invalidExternalExports.add( rawExport ); } String rawTags = properties.getProperty( APPLICATION_TAGS, "" ); result.tags.addAll( Utils.splitNicely( rawTags, "," )); return result; } }
ApplicationTemplateDescriptor { public static ApplicationTemplateDescriptor load( Properties properties ) { ApplicationTemplateDescriptor result = new ApplicationTemplateDescriptor(); result.name = getLegacyProperty( properties, APPLICATION_NAME, null ); result.description = getLegacyProperty( properties, APPLICATION_DESCRIPTION, null ); result.version = getLegacyProperty( properties, APPLICATION_VERSION, null ); result.dslId = getLegacyProperty( properties, APPLICATION_DSL_ID, null ); result.graphEntryPoint = properties.getProperty( APPLICATION_GRAPH_EP, null ); result.instanceEntryPoint = properties.getProperty( APPLICATION_INSTANCES_EP, null ); result.externalExportsPrefix = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS_PREFIX, null ); final Pattern pattern = Pattern.compile( "([^=\\s]+)\\s+" + APPLICATION_EXTERNAL_EXPORTS_AS + "\\s+([^=\\s]+)", Pattern.CASE_INSENSITIVE ); String rawExports = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS, "" ); for( String rawExport : Utils.splitNicely( rawExports, "," )) { Matcher m = pattern.matcher( rawExport ); if( m.matches()) result.externalExports.put( m.group( 1 ), m.group( 2 )); else result.invalidExternalExports.add( rawExport ); } String rawTags = properties.getProperty( APPLICATION_TAGS, "" ); result.tags.addAll( Utils.splitNicely( rawTags, "," )); return result; }  }
ApplicationTemplateDescriptor { public static ApplicationTemplateDescriptor load( Properties properties ) { ApplicationTemplateDescriptor result = new ApplicationTemplateDescriptor(); result.name = getLegacyProperty( properties, APPLICATION_NAME, null ); result.description = getLegacyProperty( properties, APPLICATION_DESCRIPTION, null ); result.version = getLegacyProperty( properties, APPLICATION_VERSION, null ); result.dslId = getLegacyProperty( properties, APPLICATION_DSL_ID, null ); result.graphEntryPoint = properties.getProperty( APPLICATION_GRAPH_EP, null ); result.instanceEntryPoint = properties.getProperty( APPLICATION_INSTANCES_EP, null ); result.externalExportsPrefix = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS_PREFIX, null ); final Pattern pattern = Pattern.compile( "([^=\\s]+)\\s+" + APPLICATION_EXTERNAL_EXPORTS_AS + "\\s+([^=\\s]+)", Pattern.CASE_INSENSITIVE ); String rawExports = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS, "" ); for( String rawExport : Utils.splitNicely( rawExports, "," )) { Matcher m = pattern.matcher( rawExport ); if( m.matches()) result.externalExports.put( m.group( 1 ), m.group( 2 )); else result.invalidExternalExports.add( rawExport ); } String rawTags = properties.getProperty( APPLICATION_TAGS, "" ); result.tags.addAll( Utils.splitNicely( rawTags, "," )); return result; }  String getName(); void setName( String name ); String getDescription(); void setDescription( String description ); String getVersion(); void setVersion( String version ); String getExternalExportsPrefix(); void setExternalExportsPrefix( String externalExportsId ); String getGraphEntryPoint(); void setGraphEntryPoint( String graphEntryPoint ); String getInstanceEntryPoint(); void setInstanceEntryPoint( String instanceEntryPoint ); String getDslId(); void setDslId( String dslId ); static ApplicationTemplateDescriptor load( Properties properties ); static ApplicationTemplateDescriptor load( File f ); static void save( File f, ApplicationTemplateDescriptor descriptor ); }
ApplicationTemplateDescriptor { public static ApplicationTemplateDescriptor load( Properties properties ) { ApplicationTemplateDescriptor result = new ApplicationTemplateDescriptor(); result.name = getLegacyProperty( properties, APPLICATION_NAME, null ); result.description = getLegacyProperty( properties, APPLICATION_DESCRIPTION, null ); result.version = getLegacyProperty( properties, APPLICATION_VERSION, null ); result.dslId = getLegacyProperty( properties, APPLICATION_DSL_ID, null ); result.graphEntryPoint = properties.getProperty( APPLICATION_GRAPH_EP, null ); result.instanceEntryPoint = properties.getProperty( APPLICATION_INSTANCES_EP, null ); result.externalExportsPrefix = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS_PREFIX, null ); final Pattern pattern = Pattern.compile( "([^=\\s]+)\\s+" + APPLICATION_EXTERNAL_EXPORTS_AS + "\\s+([^=\\s]+)", Pattern.CASE_INSENSITIVE ); String rawExports = properties.getProperty( APPLICATION_EXTERNAL_EXPORTS, "" ); for( String rawExport : Utils.splitNicely( rawExports, "," )) { Matcher m = pattern.matcher( rawExport ); if( m.matches()) result.externalExports.put( m.group( 1 ), m.group( 2 )); else result.invalidExternalExports.add( rawExport ); } String rawTags = properties.getProperty( APPLICATION_TAGS, "" ); result.tags.addAll( Utils.splitNicely( rawTags, "," )); return result; }  String getName(); void setName( String name ); String getDescription(); void setDescription( String description ); String getVersion(); void setVersion( String version ); String getExternalExportsPrefix(); void setExternalExportsPrefix( String externalExportsId ); String getGraphEntryPoint(); void setGraphEntryPoint( String graphEntryPoint ); String getInstanceEntryPoint(); void setInstanceEntryPoint( String instanceEntryPoint ); String getDslId(); void setDslId( String dslId ); static ApplicationTemplateDescriptor load( Properties properties ); static ApplicationTemplateDescriptor load( File f ); static void save( File f, ApplicationTemplateDescriptor descriptor ); static final String APPLICATION_NAME; static final String APPLICATION_VERSION; static final String APPLICATION_TAGS; static final String APPLICATION_DESCRIPTION; static final String APPLICATION_DSL_ID; static final String APPLICATION_GRAPH_EP; static final String APPLICATION_INSTANCES_EP; static final String APPLICATION_EXTERNAL_EXPORTS_PREFIX; static final String APPLICATION_EXTERNAL_EXPORTS; static final String APPLICATION_EXTERNAL_EXPORTS_AS; final Map<String,Integer> propertyToLine; final Map<String,String> externalExports; final Set<String> invalidExternalExports; final Set<String> tags; }