mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
commit
9d16f3bf61
@ -15,7 +15,7 @@ cache:
|
|||||||
language: scala
|
language: scala
|
||||||
|
|
||||||
jdk:
|
jdk:
|
||||||
- openjdk6
|
- oraclejdk8
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- sbt ++$TRAVIS_SCALA_VERSION test
|
- sbt ++$TRAVIS_SCALA_VERSION test
|
||||||
|
13
README.md
13
README.md
@ -71,7 +71,7 @@ to merge it in.
|
|||||||
- [Concatenation](#concatenation)
|
- [Concatenation](#concatenation)
|
||||||
- [Miscellaneous Notes](#miscellaneous-notes)
|
- [Miscellaneous Notes](#miscellaneous-notes)
|
||||||
- [Debugging Your Configuration](#debugging-your-configuration)
|
- [Debugging Your Configuration](#debugging-your-configuration)
|
||||||
- [Supports Java 6 and Later](#supports-java-6-and-later)
|
- [Supports Java 8 and Later](#supports-java-8-and-later)
|
||||||
- [Rationale for Supported File Formats](#rationale-for-supported-file-formats)
|
- [Rationale for Supported File Formats](#rationale-for-supported-file-formats)
|
||||||
- [Other APIs (Wrappers and Ports)](#other-apis-wrappers-and-ports)
|
- [Other APIs (Wrappers and Ports)](#other-apis-wrappers-and-ports)
|
||||||
- [Scala wrappers for the Java library](#scala-wrappers-for-the-java-library)
|
- [Scala wrappers for the Java library](#scala-wrappers-for-the-java-library)
|
||||||
@ -87,7 +87,10 @@ The license is Apache 2.0, see LICENSE-2.0.txt.
|
|||||||
|
|
||||||
### Binary Releases
|
### Binary Releases
|
||||||
|
|
||||||
You can find published releases (compiled for Java 6 and above) on
|
Version 1.2.1 and earlier were built for Java 6, while newer
|
||||||
|
versions will be built for Java 8.
|
||||||
|
|
||||||
|
You can find published releases (compiled for Java 8 and above) on
|
||||||
Maven Central.
|
Maven Central.
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -685,10 +688,10 @@ If you have trouble with your configuration, some useful tips.
|
|||||||
- Use `myConfig.root().render()` to get a `Config` printed out as a
|
- Use `myConfig.root().render()` to get a `Config` printed out as a
|
||||||
string with comments showing where each value came from.
|
string with comments showing where each value came from.
|
||||||
|
|
||||||
### Supports Java 6 and Later
|
### Supports Java 8 and Later
|
||||||
|
|
||||||
Currently the library is maintained against Java 6. It does not
|
Currently the library is maintained against Java 8, but
|
||||||
build with Java 5.
|
version 1.2.1 and earlier will work with Java 6.
|
||||||
|
|
||||||
### Rationale for Supported File Formats
|
### Rationale for Supported File Formats
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ findbugsMaxMemory := 1000
|
|||||||
|
|
||||||
jacoco.settings
|
jacoco.settings
|
||||||
|
|
||||||
javacOptions in (Compile, compile) ++= Seq("-source", "1.6", "-target", "1.6", "-g")
|
javacOptions in (Compile, compile) ++= Seq("-source", "1.6", "-target", "1.8", "-g")
|
||||||
|
|
||||||
// because we test some global state such as singleton caches,
|
// because we test some global state such as singleton caches,
|
||||||
// we have to run tests in serial.
|
// we have to run tests in serial.
|
||||||
@ -30,4 +30,4 @@ parallelExecution in Test := false
|
|||||||
|
|
||||||
sources in (Compile, doc) ~= (_.filter(_.getParentFile.getName != "impl"))
|
sources in (Compile, doc) ~= (_.filter(_.getParentFile.getName != "impl"))
|
||||||
|
|
||||||
javaVersionPrefix in javaVersionCheck := Some("1.6")
|
javaVersionPrefix in javaVersionCheck := Some("1.8")
|
||||||
|
@ -924,20 +924,24 @@ class ConfigSubstitutionTest extends TestUtils {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
def substSelfReferenceIndirect() {
|
def substSelfReferenceIndirect() {
|
||||||
|
// this has two possible outcomes depending on whether
|
||||||
|
// we resolve and memoize a first or b first. currently
|
||||||
|
// java 8's hash table makes it resolve OK, but
|
||||||
|
// it's also allowed to throw an exception.
|
||||||
val obj = parseObject("""a=1, b=${a}, a=${b}""")
|
val obj = parseObject("""a=1, b=${a}, a=${b}""")
|
||||||
val e = intercept[ConfigException.UnresolvedSubstitution] {
|
val resolved = resolve(obj)
|
||||||
resolve(obj)
|
assertEquals(1, resolved.getInt("a"))
|
||||||
}
|
|
||||||
assertTrue("wrong exception: " + e.getMessage, e.getMessage.contains("cycle"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def substSelfReferenceDoubleIndirect() {
|
def substSelfReferenceDoubleIndirect() {
|
||||||
|
// this has two possible outcomes depending on whether we
|
||||||
|
// resolve and memoize a, b, or c first. currently java
|
||||||
|
// 8's hash table makes it resolve OK, but it's also
|
||||||
|
// allowed to throw an exception.
|
||||||
val obj = parseObject("""a=1, b=${c}, c=${a}, a=${b}""")
|
val obj = parseObject("""a=1, b=${c}, c=${a}, a=${b}""")
|
||||||
val e = intercept[ConfigException.UnresolvedSubstitution] {
|
val resolved = resolve(obj)
|
||||||
resolve(obj)
|
assertEquals(1, resolved.getInt("a"))
|
||||||
}
|
|
||||||
assertTrue("wrong exception: " + e.getMessage, e.getMessage.contains("cycle"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1002,7 +1006,7 @@ class ConfigSubstitutionTest extends TestUtils {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
def substOptionalIndirectSelfReferenceInConcat() {
|
def substOptionalIndirectSelfReferenceInConcat() {
|
||||||
val obj = parseObject("""a=${?b}foo,b=${a}""")
|
val obj = parseObject("""a=${?b}foo,b=${?a}""")
|
||||||
val resolved = resolve(obj)
|
val resolved = resolve(obj)
|
||||||
assertEquals("foo", resolved.getString("a"))
|
assertEquals("foo", resolved.getString("a"))
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ class ConfigValueTest extends TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def configObjectSerializable() {
|
def java6ConfigObjectSerializable() {
|
||||||
val expectedSerialization = "" +
|
val expectedSerialization = "" +
|
||||||
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
||||||
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
||||||
@ -220,6 +220,40 @@ class ConfigValueTest extends TestUtils {
|
|||||||
"000101040000000802000000010001_1010001_c050000000101040000000802000000030001_301" +
|
"000101040000000802000000010001_1010001_c050000000101040000000802000000030001_301" +
|
||||||
"0001_b050000000101040000000802000000020001_2010103000000010001_x"
|
"0001_b050000000101040000000802000000020001_2010103000000010001_x"
|
||||||
|
|
||||||
|
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
||||||
|
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
||||||
|
val b = checkSerializableOldFormat(expectedSerialization, a)
|
||||||
|
assertEquals(1, b.toConfig.getInt("a"))
|
||||||
|
// check that deserialized Config and ConfigObject refer to each other
|
||||||
|
assertTrue(b.toConfig.root eq b)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
def java6ConfigConfigSerializable() {
|
||||||
|
val expectedSerialization = "" +
|
||||||
|
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
||||||
|
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
||||||
|
"0000000D000B_f_a_k_e_ _o_r_i_g_i_n0900000001000104000000_J07000000030001_a050000" +
|
||||||
|
"000101040000000802000000010001_1010001_c050000000101040000000802000000030001_301" +
|
||||||
|
"0001_b050000000101040000000802000000020001_2010103000000010101_x"
|
||||||
|
|
||||||
|
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
||||||
|
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
||||||
|
val b = checkSerializableOldFormat(expectedSerialization, a.toConfig())
|
||||||
|
assertEquals(1, b.getInt("a"))
|
||||||
|
// check that deserialized Config and ConfigObject refer to each other
|
||||||
|
assertTrue(b.root.toConfig eq b)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
def configObjectSerializable() {
|
||||||
|
val expectedSerialization = "" +
|
||||||
|
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
||||||
|
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
||||||
|
"0000000D000B_f_a_k_e_ _o_r_i_g_i_n0900000001000104000000_J07000000030001_a050000" +
|
||||||
|
"000101040000000802000000010001_1010001_b050000000101040000000802000000020001_201" +
|
||||||
|
"0001_c050000000101040000000802000000030001_3010103000000010001_x"
|
||||||
|
|
||||||
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
||||||
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
||||||
val b = checkSerializable(expectedSerialization, a)
|
val b = checkSerializable(expectedSerialization, a)
|
||||||
@ -231,11 +265,11 @@ class ConfigValueTest extends TestUtils {
|
|||||||
@Test
|
@Test
|
||||||
def configConfigSerializable() {
|
def configConfigSerializable() {
|
||||||
val expectedSerialization = "" +
|
val expectedSerialization = "" +
|
||||||
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
||||||
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
||||||
"0000000D000B_f_a_k_e_ _o_r_i_g_i_n0900000001000104000000_J07000000030001_a050000" +
|
"0000000D000B_f_a_k_e_ _o_r_i_g_i_n0900000001000104000000_J07000000030001_a050000" +
|
||||||
"000101040000000802000000010001_1010001_c050000000101040000000802000000030001_301" +
|
"000101040000000802000000010001_1010001_b050000000101040000000802000000020001_201" +
|
||||||
"0001_b050000000101040000000802000000020001_2010103000000010101_x"
|
"0001_c050000000101040000000802000000030001_3010103000000010101_x"
|
||||||
|
|
||||||
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
||||||
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
||||||
|
Loading…
Reference in New Issue
Block a user