App property inherited from app component cannot have repetitive parts separated by spaces #1055

This commit is contained in:
Konstantin Krivopustov 2018-08-08 18:12:47 +04:00
parent dd0b8c618f
commit bc411fd828
2 changed files with 13 additions and 8 deletions

View File

@ -184,14 +184,16 @@ public class AppProperties {
String compValue = component.getProperty(key);
if (StringUtils.isNotEmpty(compValue)) {
index = 0;
for (String valuePart : split(compValue)) {
if (!values.contains(valuePart)) {
values.add(index, valuePart);
index++;
if (component.isAdditiveProperty(key)) {
index = 0;
for (String valuePart : split(compValue)) {
if (!values.contains(valuePart)) {
values.add(index, valuePart);
index++;
}
}
}
if (!component.isAdditiveProperty(key)) {
} else {
values.add(0, compValue);
// we found overwrite, stop iteration
break;
}

View File

@ -46,6 +46,7 @@ public class AppPropertiesTest {
reports.setProperty("prop3", "prop3_reports_val", false);
reports.setProperty("prop4", "prop4_reports_val", true);
reports.setProperty("prop5", "prop5_reports_val", false);
reports.setProperty("cronExpr", "*/10 * * * * *", false);
AppComponents appComponents = new AppComponents("core");
appComponents.add(cuba);
@ -72,6 +73,8 @@ public class AppPropertiesTest {
assertEquals("prop6_app_val", appProperties.getProperty("prop6"));
assertNull(appProperties.getProperty("prop7"));
assertEquals("*/10 * * * * *", appProperties.getProperty("cronExpr"));
}
@Test
@ -84,7 +87,7 @@ public class AppPropertiesTest {
@Test
public void testGetPropertyNames() {
assertArrayEquals(
new String[] {"prop1", "prop2", "prop3", "prop4", "prop5", "prop6"},
new String[] {"cronExpr", "prop1", "prop2", "prop3", "prop4", "prop5", "prop6"},
appProperties.getPropertyNames());
}