-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from ntviet18/set_syntax_from_filename_option
Add syntax from file name parser option
- Loading branch information
Showing
6 changed files
with
94 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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
fromProps.abc=abc | ||
fromProps.one=1 | ||
fromProps.bool=true | ||
fromProps.specialChars=hello^^ |
30 changes: 30 additions & 0 deletions
30
config/src/test/scala/com/typesafe/config/impl/ParseableReaderTest.scala
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,30 @@ | ||
package com.typesafe.config.impl | ||
|
||
import java.io.InputStreamReader | ||
|
||
import com.typesafe.config.{ConfigException, ConfigFactory, ConfigParseOptions} | ||
import org.hamcrest.CoreMatchers.containsString | ||
import org.junit.Assert.{assertEquals, assertThat} | ||
import org.junit.Test | ||
|
||
class ParseableReaderTest extends TestUtils { | ||
|
||
@Test | ||
def parse(): Unit = { | ||
val filename = "/test01.properties" | ||
val configInput = new InputStreamReader(getClass.getResourceAsStream(filename)) | ||
val config = ConfigFactory.parseReader(configInput, ConfigParseOptions.defaults() | ||
.setSyntaxFromFilename(filename)) | ||
assertEquals("hello^^", config.getString("fromProps.specialChars")) | ||
} | ||
|
||
@Test | ||
def parseIncorrectFormat(): Unit = { | ||
val filename = "/test01.properties" | ||
val configInput = new InputStreamReader(getClass.getResourceAsStream(filename)) | ||
val e = intercept[ConfigException.Parse] { | ||
ConfigFactory.parseReader(configInput) | ||
} | ||
assertThat(e.getMessage, containsString("Expecting end of input or a comma, got '^'")) | ||
} | ||
} |
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