Skip to content

Commit

Permalink
Fix tests for suppressTestResource + add module-info uses
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Feb 15, 2023
1 parent 7d544ab commit e2875ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
requires transitive io.avaje.applog;
requires static org.yaml.snakeyaml;

uses io.avaje.config.EventLog;
uses io.avaje.config.ConfigurationSource;
}
2 changes: 1 addition & 1 deletion src/test/java/io/avaje/config/CoreConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void forPath_nested() {
@Test
void test_toString() {
assertThat(data.toString()).isNotEmpty();
data.setWatcher(new FileWatch( Mockito.mock(CoreConfiguration.class), Collections.emptyList(), null));
data.setWatcher(new FileWatch( new CoreConfiguration(new DefaultEventLog(), new Properties()) , Collections.emptyList(), null));
data.loadIntoSystemProperties();
}

Expand Down
24 changes: 14 additions & 10 deletions src/test/java/io/avaje/config/InitialLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,19 @@ void loadViaCommandLine_localFile() {
@Test
void load_withSuppressTestResource() {
//application-test.yaml is loaded when suppressTestResource is not set to true
System.setProperty("suppressTestResource", "");
InitialLoader loader = new InitialLoader(new DefaultEventLog());
Properties properties = loader.load();
assertThat(properties.getProperty("myapp.activateFoo")).isEqualTo("true");

//application-test.yaml is not loaded when suppressTestResource is set to true
System.setProperty("suppressTestResource", "true");
InitialLoader loaderWithSuppressTestResource = new InitialLoader(new DefaultEventLog());
Properties propertiesWithoutTestResource = loaderWithSuppressTestResource.load();
assertThat(propertiesWithoutTestResource.getProperty("myapp.activateFoo")).isNull();
try {
System.setProperty("suppressTestResource", "");
InitialLoader loader = new InitialLoader(new DefaultEventLog());
Properties properties = loader.load();
assertThat(properties.getProperty("myapp.activateFoo")).isEqualTo("true");

//application-test.yaml is not loaded when suppressTestResource is set to true
System.setProperty("suppressTestResource", "true");
InitialLoader loaderWithSuppressTestResource = new InitialLoader(new DefaultEventLog());
Properties propertiesWithoutTestResource = loaderWithSuppressTestResource.load();
assertThat(propertiesWithoutTestResource.getProperty("myapp.activateFoo")).isNull();
} finally {
System.clearProperty("suppressTestResource");
}
}
}

0 comments on commit e2875ff

Please sign in to comment.