AppConstants extends Properties implements Serializable { public String getResolvedProperty(String key) { String value = null; value=getSystemProperty(key); if (value==null) { value = super.getProperty(key); } if (value != null) { try { String result=StringResolver.substVars(value, this); if (log.isTraceEnabled()) { if (!value.equals(result)){ log.trace("resolved key ["+key+"], value ["+value+"] to ["+result+"]"); } } return result; } catch (IllegalArgumentException e) { log.error("Bad option value [" + value + "].", e); return value; } } else { if (log.isTraceEnabled()) log.trace("getResolvedProperty: key ["+key+"] resolved to value ["+value+"]"); return null; } } private  AppConstants(ClassLoader classLoader); static AppConstants getInstance(); static synchronized AppConstants getInstance(final ClassLoader cl); static void removeInstance(); static synchronized void removeInstance(final ClassLoader cl); @Override String get(Object key); @Override String getProperty(String key); String getUnresolvedProperty(String key); String getResolvedProperty(String key); StringTokenizer getTokenizedProperty(String key); StringTokenizer getTokenizedProperty(String key, String defaults); Properties getAppConstants(String keyBase); Properties getAppConstants(String keyBase, boolean useSystemProperties, boolean useEnvironmentVariables); @Deprecated @Override synchronized Object put(Object key, Object value); @Override Object setProperty(String key, String value); Object setProperty(String key, boolean value); void put(String key, String value); @Deprecated String toXml(); @Deprecated String toXml(boolean resolve); String getString(String key, String dfault); boolean getBoolean(String key, boolean dfault); int getInt(String key, int dfault); long getLong(String key, long dfault); double getDouble(String key, double dfault); void setVariableExpander(VariableExpander expander); VariableExpander getVariableExpander(); static final String APPLICATION_SERVER_TYPE_PROPERTY; }
@Test public void onlyInAppConstants() { assertEquals("1", constants.getResolvedProperty("only.in.appconstants")); }
@Test public void onlyInDeploymentSpecifics() { assertEquals("2", constants.getResolvedProperty("only.in.deploymentspecifics")); }
@Test public void overwriteInDeploymentSpecifics() { assertEquals("2", constants.getResolvedProperty("overwrite.in.deploymentspecifics")); }
@Test public void onlyInDeploymentSpecificsParent() { assertEquals("3", constants.getResolvedProperty("only.in.deploymentspecifics.parent")); }
@Test public void overwriteInDeploymentSpecificsParent() { assertEquals("3", constants.getResolvedProperty("overwrite.in.deploymentspecifics.parent")); }
@Test public void onlyInBuildInfo() { assertEquals("4", constants.getResolvedProperty("only.in.buildinfo")); }
@Test public void overwriteInBuildInfo() { assertEquals("4", constants.getResolvedProperty("overwrite.in.buildinfo")); }
@Test public void callResolvedProperty() { assertEquals("123", constants.getResolvedProperty("unresolved.property")); }
@Test public void callNonExistingProperty() { assertEquals(null, constants.getResolvedProperty("i.dont.exist")); }