Skip to content

Commit

Permalink
Merge pull request #519 from lkoe/master
Browse files Browse the repository at this point in the history
#518 Testcase for Spring property reference notation in scalar values
  • Loading branch information
amihaiemil authored Oct 21, 2022
2 parents ee485e1 + a3ed69b commit 84fe615
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,42 @@ public void supportsBracketedNotation() throws IOException {
MatcherAssert.assertThat(pretty, Matchers.equalTo(fileContents));
}

/**
* Do a round-trip test on sample file containing a scalar using Spring property reference syntax.
*
* <a href="https://github.com/decorators-squad/eo-yaml/issues/518">#518</a>
* based on
* <a href="https://github.com/decorators-squad/eo-yaml/issues/515">PR</a>
*
* @throws IOException When there's a problem reading the sample files.
*/
@Test
public void supportsSpringPropertyRef() throws IOException {
final String filename = "issue_518_spring_property_ref.yml";
final String fileContents = readTestResource(filename).trim();

final YamlMapping read = new RtYamlInput(
new FileInputStream("src/test/resources/" + filename)
).readYamlMapping();

MatcherAssert.assertThat(read.type(), Matchers.equalTo(Node.MAPPING));
MatcherAssert.assertThat(
read.asMapping().keys().size(),
Matchers.equalTo(1));

final YamlNode topLevelMapping = read.asMapping().value("a_mapping");
MatcherAssert.assertThat(
topLevelMapping.type(),
Matchers.equalTo(Node.MAPPING));
MatcherAssert.assertThat(
topLevelMapping.asMapping().keys().size(),
Matchers.equalTo(1));

final String pretty = read.toString().trim();

MatcherAssert.assertThat(pretty, Matchers.equalTo(fileContents));
}

/**
* Read a test resource file's contents.
* @param fileName File to read.
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/issue_518_spring_property_ref.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a_mapping:
a_scalar: "${ENV_PROP:theDefault}"

0 comments on commit 84fe615

Please sign in to comment.