Skip to content

Commit

Permalink
Revert system property and environment variable changes in tests (#578)
Browse files Browse the repository at this point in the history
PR: #578
  • Loading branch information
Marcono1234 committed Mar 10, 2022
1 parent ad7736a commit 09f08be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -39,6 +40,12 @@ void setUp() {
System.setProperty(SET_SYSPROP_KEY, SET_SYSPROP_ORIGINAL_VALUE);
}

@AfterEach
void tearDown() {
EnvironmentVariableUtils.clear(SET_ENVVAR_KEY);
System.clearProperty(SET_SYSPROP_KEY);
}

@Test
@Issue("432")
@DisplayName("should not mix backups of different extensions on clear environment variable and clear system property")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ static void globalSetUp() {
@AfterAll
static void globalTearDown() {
assertThat(systemEnvironmentVariable("set envvar A")).isEqualTo("old A");
EnvironmentVariableUtils.clear("set envvar A");
assertThat(systemEnvironmentVariable("set envvar B")).isEqualTo("old B");
EnvironmentVariableUtils.clear("set envvar B");
assertThat(systemEnvironmentVariable("set envvar C")).isEqualTo("old C");
EnvironmentVariableUtils.clear("set envvar C");

assertThat(systemEnvironmentVariable("clear envvar D")).isNull();
assertThat(systemEnvironmentVariable("clear envvar E")).isNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ static void globalSetUp() {
@AfterAll
static void globalTearDown() {
assertThat(System.getProperty("set prop A")).isEqualTo("old A");
System.clearProperty("set prop A");
assertThat(System.getProperty("set prop B")).isEqualTo("old B");
System.clearProperty("set prop B");
assertThat(System.getProperty("set prop C")).isEqualTo("old C");
System.clearProperty("set prop C");

assertThat(System.getProperty("clear prop D")).isNull();
assertThat(System.getProperty("clear prop E")).isNull();
Expand Down

0 comments on commit 09f08be

Please sign in to comment.