Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
vtintillier committed Jan 11, 2024
1 parent 1cb1edd commit 5c049a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ void settingAfterPreDeleteAlsoWorks() throws Exception {
properties.set("bar", "h");
assertThat(System.getProperty("bar")).isEqualTo("h");

SystemProperties nested = new SystemProperties();
nested.remove("bar");
SystemProperties nested = new SystemProperties().remove("bar");
nested.execute(() -> {
nested.set("bar", "bong");
assertThat(System.getProperty("bar")).isEqualTo("bong");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ void method3_hasCleanPropertiesAndEnvironment() {
}
}

@ExtendWith(SystemStubsExtension.class)
@Nested
class SystemPropertiesAsParentClass {

@SystemStub
private SystemProperties systemProperties = new WithDefaultsSystemProperties()
.set("key1", "value3");

@Test
void defaultValuesAreSet() {
assertThat(System.getProperty("key1")).isEqualTo("value3");
assertThat(System.getProperty("key2")).isEqualTo("value2");
}
}

private static class WithDefaultsSystemProperties extends SystemProperties {

WithDefaultsSystemProperties() {
super("key1", "value1");
this.set("key2", "value2");
}
}

@ExtendWith(SystemStubsExtension.class)
@Nested
class FieldWithoutAnnotation {
Expand Down

0 comments on commit 5c049a9

Please sign in to comment.