-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read configuration settings from client.cfg.dev
- Loading branch information
Showing
11 changed files
with
124 additions
and
88 deletions.
There are no files selected for viewing
27 changes: 19 additions & 8 deletions
27
common/src/main/java/com/genexus/util/IniFileMultiple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
package com.genexus.util; | ||
|
||
import java.io.*; | ||
import com.genexus.diagnostics.core.ILogger; | ||
import com.genexus.diagnostics.core.LogManager; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class IniFileMultiple extends IniFile { | ||
public static final ILogger logger = LogManager.getLogger(IniFileMultiple.class); | ||
private IniFile additionalProperties; | ||
|
||
public IniFileMultiple(InputStream in, InputStream in2) throws IOException { | ||
public IniFileMultiple(InputStream in) throws IOException { | ||
super(in); | ||
try { | ||
additionalProperties = new IniFile(in2); | ||
} catch (Exception e) { } | ||
} | ||
|
||
public void addConfigurationSource(String configId, InputStream in) { | ||
if (in != null) { | ||
try { | ||
additionalProperties = new IniFile(in); | ||
logger.debug(String.format("Additional configuration file '%s' lodad", configId)); | ||
} catch (Exception e) { | ||
logger.warn(String.format("Could not read additional configuration file: '%s'", configId), e); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public String getProperty(String section, String key, String defaultValue) { | ||
String value = null; | ||
if (additionalProperties != null){ | ||
if (additionalProperties != null) { | ||
value = additionalProperties.getProperty(section, key); | ||
} | ||
if (value == null) { | ||
value = super.getProperty(section, key, defaultValue); | ||
} | ||
return value; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Client] | ||
MY_CUSTOM_PTY=SAMPLE_VALUE_FOR_DEV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Client] | ||
MY_CUSTOM_PTY=SAMPLE_VALUE_FOR_PROD | ||
MY_CUSTOM_PTY_PROD=SHOULD_NOT_BE_READ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
java/src/test/java/com/genexus/configuration/TestConfigurationOverride.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.genexus.configuration; | ||
|
||
import com.genexus.Application; | ||
import com.genexus.sampleapp.GXcfg; | ||
import com.genexus.specific.java.Connect; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TestConfigurationOverride { | ||
|
||
@Before | ||
public void setUpStreams() { | ||
Connect.init(); | ||
Application.init(GXcfg.class); | ||
} | ||
|
||
@Test | ||
public void testReadConfiguration() { | ||
String packageName = Application.getClientPreferences().getPACKAGE(); | ||
assertEquals("com.genexus.sampleapp", packageName); | ||
} | ||
|
||
@Test | ||
public void testReadConfigurationFromDev() { | ||
String customOverridablePty = Application.getClientPreferences().getProperty("MY_CUSTOM_PTY", ""); | ||
assertEquals("SAMPLE_VALUE_FOR_DEV", customOverridablePty); | ||
} | ||
|
||
@Test | ||
public void testReadConfigurationFromProdError() { | ||
String customOverridablePty = Application.getClientPreferences().getProperty("MY_CUSTOM_PTY_PROD", ""); | ||
assertEquals("", customOverridablePty); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
java/src/test/java/com/genexus/db/driver/TestMockDataAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
java/src/test/java/com/mockdb/GXcfg.java → ...est/java/com/genexus/sampleapp/GXcfg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.mockdb ; | ||
package com.genexus.sampleapp; | ||
import com.genexus.*; | ||
|
||
public final class GXcfg | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters