Skip to content

Commit

Permalink
patch config-parser (#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC authored Jan 31, 2024
1 parent adb71e5 commit abe3368
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public InspectitConfig parseConfig(String configYaml) throws IOException {
factory.setResources(new FileUrlResource(tempFile.getAbsolutePath()));
Properties properties = factory.getObject();

// if the inspectit object does not contain further properties, like this "inspectit.config.http.url"
if(properties != null && properties.containsKey("inspectit"))
return new InspectitConfig();

// Create ConfigurationPropertySource from Properties
ConfigurationPropertySource propertySource = new MapConfigurationPropertySource(properties);
// Add to list because Binder expects Iterable<ConfigurationPropertySource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class ParseConfigTests {

@Test
void withPlaceholder() throws IOException {

String configYaml = getYaml("configWithPlaceholder.yml");

InspectitConfig result = configParser.parseConfig(configYaml);
Expand Down Expand Up @@ -113,7 +112,6 @@ void withUnknownProperty() throws IOException {

@Test
void withDuration() throws IOException {

String configYaml = getYaml("configWithDuration.yml");

InspectitConfig result = configParser.parseConfig(configYaml);
Expand All @@ -126,7 +124,6 @@ void withDuration() throws IOException {

@Test
void withDocumentation() throws IOException {

String configYaml = getYaml("configWithDocumentation.yml");

InspectitConfig result = configParser.parseConfig(configYaml);
Expand All @@ -153,6 +150,15 @@ void withDocumentation() throws IOException {
.isEqualTo(actionSettingsMock);
}

@Test
void withoutFurtherProperties() throws IOException {
String configYaml = getYaml("configWithoutFurtherProperties.yml");

InspectitConfig result = configParser.parseConfig(configYaml);

assertThat(result).isEqualTo(new InspectitConfig());
}

@Test
void invalidYaml() {
String configYaml = "invalid-yaml";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inspectit:

0 comments on commit abe3368

Please sign in to comment.