mirror of
https://github.com/lightbend/config.git
synced 2025-02-19 15:50:47 +08:00
Merge pull request #309 from fpringvaldsen/maint/bugfixes
Fix bug with ConfigDocument.setValue
This commit is contained in:
commit
462181578a
@ -27,7 +27,7 @@ final class SimpleConfigDocument implements ConfigDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ConfigDocument setValue(String path, ConfigValue newValue) {
|
public ConfigDocument setValue(String path, ConfigValue newValue) {
|
||||||
return setValue(path, newValue.render());
|
return setValue(path, newValue.render().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigDocument removeValue(String path) {
|
public ConfigDocument removeValue(String path) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.typesafe.config.impl
|
package com.typesafe.config.impl
|
||||||
|
|
||||||
import java.io.{ BufferedReader, FileReader }
|
import java.io.{ BufferedReader, FileReader }
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
import java.nio.file.{ Paths, Files }
|
import java.nio.file.{ Paths, Files }
|
||||||
|
|
||||||
import com.typesafe.config._
|
import com.typesafe.config._
|
||||||
@ -9,6 +8,8 @@ import com.typesafe.config.parser._
|
|||||||
import org.junit.Assert._
|
import org.junit.Assert._
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
class ConfigDocumentTest extends TestUtils {
|
class ConfigDocumentTest extends TestUtils {
|
||||||
private def configDocumentReplaceJsonTest(origText: String, finalText: String, newValue: String, replacePath: String) {
|
private def configDocumentReplaceJsonTest(origText: String, finalText: String, newValue: String, replacePath: String) {
|
||||||
val configDocument = ConfigDocumentFactory.parseString(origText, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
|
val configDocument = ConfigDocumentFactory.parseString(origText, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
|
||||||
@ -437,4 +438,16 @@ class ConfigDocumentTest extends TestUtils {
|
|||||||
assertEquals(" a : 1", configDocument.setValue("a", "1").render)
|
assertEquals(" a : 1", configDocument.setValue("a", "1").render)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
def configDocumentConfigObjectInsertion {
|
||||||
|
val origText = "{ a : b }"
|
||||||
|
val configDocument = ConfigDocumentFactory.parseString(origText)
|
||||||
|
|
||||||
|
val configVal = ConfigValueFactory.fromAnyRef(Map("a" -> 1, "b" -> 2).asJava)
|
||||||
|
|
||||||
|
assertEquals("{ a : {\n # hardcoded value\n \"a\" : 1,\n # hardcoded value\n \"b\" : 2\n } }",
|
||||||
|
configDocument.setValue("a", configVal).render)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user