-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added actual testing Added test resource INI files Expanded comments Auto-generating docs during testing now, for completeness
- Loading branch information
1 parent
dc75e5a
commit e0e0bb9
Showing
7 changed files
with
191 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
language: java | ||
script: | ||
- mvn test | ||
- mvn javadoc:javadoc | ||
- mvn javadoc:test-javadoc | ||
cache: | ||
directories: | ||
- ~/.m2/repository |
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
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,60 @@ | ||
package com.thehellings.config; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ConfigTest { | ||
enum TestEnums { | ||
field1, | ||
field2, | ||
field3, | ||
not_present | ||
}; | ||
|
||
@Test | ||
public void developmentEnumeratorConstructor() { | ||
Config config = new Config(Mode.DEVELOPMENT); | ||
assertEquals("dev1", config.get("field1")); | ||
assertEquals("dev2", config.get("field2")); | ||
assertEquals("default3", config.get(TestEnums.field3)); | ||
assertNull(config.get(TestEnums.not_present)); | ||
} | ||
|
||
@Test | ||
public void productionStringConstructor() { | ||
Config config = new Config("PRODUCTION"); | ||
assertEquals("prod1", config.get(TestEnums.field1)); | ||
assertNull(config.get(TestEnums.field2)); | ||
assertEquals("prod3", config.get("field3")); | ||
assertNull(config.get(TestEnums.not_present)); | ||
} | ||
|
||
@Test | ||
public void nonDefaultFilename() { | ||
Config config = new Config("DEVELOPMENT", ConfigTest.class.getClassLoader().getResourceAsStream("other.ini")); | ||
assertEquals("dev1", config.get("field1")); | ||
assertEquals("dev2", config.get("field2")); | ||
assertNull(config.get("field3")); | ||
} | ||
|
||
@Test | ||
public void nonDefaultFilenameEnum() throws Exception { | ||
Config config = new Config(Mode.PRODUCTION, ConfigTest.class.getClassLoader().getResourceAsStream("other.ini")); | ||
assertEquals("prod1", config.get("field1")); | ||
assertNull(config.get("field2")); | ||
assertEquals("prod3", config.get("field3")); | ||
} | ||
|
||
@Test | ||
public void defaultsOnly() { | ||
Config config = new Config("derpenv", ConfigTest.class.getClassLoader().getResourceAsStream("defaultsonly.ini")); | ||
assertEquals("somevalue", config.get("field1")); | ||
} | ||
|
||
@Test | ||
public void failOpen() { | ||
Config config = new Config("anyenv", null); | ||
assertNull(config.get("anything")); | ||
} | ||
} |
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,11 @@ | ||
[DEVELOPMENT] | ||
field1 = dev1 | ||
field2 = dev2 | ||
|
||
[PRODUCTION] | ||
field1 = prod1 | ||
field3 = prod3 | ||
|
||
[default] | ||
field1 = default1 | ||
field3 = default3 |
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 @@ | ||
[default] | ||
field1 = somevalue |
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,7 @@ | ||
[DEVELOPMENT] | ||
field1 = dev1 | ||
field2 = dev2 | ||
|
||
[PRODUCTION] | ||
field1 = prod1 | ||
field3 = prod3 |