-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#531 Implement ability to override properties in AppConfig from a pro…
…perty file located on file system
- Loading branch information
Igor Polevoy
committed
Dec 27, 2016
1 parent
bf8fb7f
commit 38ba557
Showing
5 changed files
with
163 additions
and
44 deletions.
There are no files selected for viewing
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
24 changes: 20 additions & 4 deletions
24
app-config/src/test/java/org/javalite/app_config/AppConfigTest.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,37 +1,53 @@ | ||
package org.javalite.app_config; | ||
|
||
import org.javalite.test.jspec.JSpecSupport; | ||
import org.junit.FixMethodOrder; | ||
import org.junit.Test; | ||
import org.junit.runners.MethodSorters; | ||
|
||
import static org.javalite.app_config.AppConfig.p; | ||
|
||
|
||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
public class AppConfigTest implements JSpecSupport { | ||
|
||
@Test | ||
public void shouldGetNameInDevelopmentEnv() { | ||
public void should_A_GetNameInDevelopmentEnv() { | ||
the(p("first.name")).shouldBeEqual("John"); | ||
} | ||
|
||
@Test | ||
public void shouldReadAsMapFromDevelopmentFile() { | ||
public void should_B_ReadAsMapFromDevelopmentFile() { | ||
the(new AppConfig().get("first.name")).shouldBeEqual("John"); | ||
} | ||
|
||
@Test | ||
public void shouldFindPropertiesWithPrefix(){ | ||
public void should_C_FindPropertiesWithPrefix(){ | ||
|
||
the(AppConfig.getProperties("prop")).shouldContain("one"); | ||
the(AppConfig.getProperties("prop")).shouldContain("two"); | ||
the(AppConfig.getProperties("prop")).shouldNotContain("John"); | ||
} | ||
|
||
@Test | ||
public void shouldFindKeysWithPrefix(){ | ||
public void should_D_FindKeysWithPrefix(){ | ||
|
||
the(AppConfig.getKeys("prop")).shouldContain("prop.1"); | ||
the(AppConfig.getKeys("prop")).shouldContain("prop.1"); | ||
the(AppConfig.getKeys("prop")).shouldNotContain("first.name"); | ||
} | ||
|
||
@Test | ||
public void should_E_OverridePropertyFromFile(){ | ||
the(AppConfig.getKeys("prop")).shouldContain("prop.1"); | ||
the(AppConfig.getKeys("prop")).shouldContain("prop.1"); | ||
the(AppConfig.getKeys("prop")).shouldNotContain("first.name"); | ||
} | ||
|
||
@Test | ||
public void should_F_OverrideFromFile(){ | ||
System.setProperty("app_config.properties", "target/test-classes/production.properties"); | ||
AppConfig.reload(); | ||
the(p("first.name")).shouldBeEqual("Larry"); | ||
} | ||
} |
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 @@ | ||
first.name=Larry |
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