@Test public void appHomePropertyIsPresent() throws Exception { final ApplicationFileBuilder globalPropertyAppFileBuilder = new ApplicationFileBuilder("property-app").definedBy("app-properties-config.xml"); addExplodedAppFromBuilder(globalPropertyAppFileBuilder); startDeployment(); assertApplicationDeploymentSuccess(applicationDeploymentListener, globalPropertyAppFileBuilder.getId()); final Application app = findApp(globalPropertyAppFileBuilder.getId(), 1); Optional<ConfigurationProperties> configurationProperties = app.getRegistry().lookupByType(ConfigurationProperties.class); assertThat(configurationProperties.isPresent(), is(true)); File appHome = new File(configurationProperties.get().resolveStringProperty("appHome") .orElseThrow(() -> new RuntimeException("Could not find property appHome"))); assertThat(appHome.exists(), is(true)); assertThat(appHome.getName(), is(globalPropertyAppFileBuilder.getId())); }
@Override protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) { return configurationProperties.resolveStringProperty(placeholder).orElse(null); }
@Override protected String resolvePlaceholder(String placeholder, Properties props) { return configurationProperties.resolveStringProperty(placeholder).orElse(null); }
@Override public Object call(Object[] parameters, BindingContext context) { String name = (String) parameters[0]; String value = configurationProperties.resolveStringProperty(name).orElse(System.getProperty(name)); if (value == null) { value = System.getenv(name); } return value; }
@Test public void appHomePropertyIsPresent() throws Exception { final ApplicationFileBuilder globalPropertyAppFileBuilder = new ApplicationFileBuilder("property-app").definedBy("app-properties-config.xml"); addExplodedAppFromBuilder(globalPropertyAppFileBuilder); startDeployment(); assertApplicationDeploymentSuccess(applicationDeploymentListener, globalPropertyAppFileBuilder.getId()); final Application app = findApp(globalPropertyAppFileBuilder.getId(), 1); Optional<ConfigurationProperties> configurationProperties = app.getRegistry().lookupByType(ConfigurationProperties.class); assertThat(configurationProperties.isPresent(), is(true)); String appHome = configurationProperties.get().resolveStringProperty("appHome") .orElseThrow(() -> new RuntimeException("Could not find property appHome")); assertThat(new File(appHome).exists(), is(true)); }