Skip to content

Commit 4bd3679

Browse files
author
mccabd
committed
Include does substitution
1 parent 7675259 commit 4bd3679

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/main/java/com/github/bordertech/config/DefaultConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ public synchronized Object put(final Object aKey, final Object aValue) {
14561456

14571457
// Act on "include" directives immediately
14581458
if (INCLUDE.equals(key)) {
1459-
for (String subFile : parseStringArray(value)) {
1459+
for (String subFile : parseStringArray(StringSubstitutor.replace(value, backing))) {
14601460
DefaultConfiguration.this.load(subFile);
14611461
}
14621462
return value;

src/test/java/com/github/bordertech/config/DefaultConfigurationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public void testIncludes() {
130130
assertPropertyEquals("test.includeAfter.secondaryString", "secondary");
131131
}
132132

133+
@Test
134+
public void testIncludeWithSubstitution() {
135+
Assert.assertTrue(config.getBoolean("test.property.included"));
136+
}
137+
133138
@Test
134139
public void testGetSubProperties() {
135140
final int propertyCount = 7;

src/test/resources/com/github/bordertech/config/DefaultConfigurationTest.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ includeAfter=${includeAfter.test.path}/DefaultConfigurationTest_includeAfterWith
8686
test.includeAfter.secondaryString=anIncludeAfterWillOvverrideThis
8787

8888
include=./path/to/a/non/existent/file.properties
89+
90+
include.substitution.property=includeWithSubstitution
91+
92+
include=com/github/bordertech/config/DefaultConfigurationTest_${include.substitution.property}.properties
93+
94+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
############################################################################
2+
# This property file is for the DefaultConfiguration_Test jUnit test
3+
# It must not be included or be included by property file that is not
4+
# directly related to the test.
5+
############################################################################
6+
7+
test.property.included=true
8+

0 commit comments

Comments
 (0)