Skip to content

Commit fda87c3

Browse files
committed
#376: JsonProviderTest fails if run after other Junits in a test suite
Signed-off-by: Lukas Jungmann <[email protected]>
1 parent 7f7ba7e commit fda87c3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tck/tck-tests/src/main/java/ee/jakarta/tck/jsonp/api/provider/JsonProviderTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import jakarta.json.stream.JsonGeneratorFactory;
3535
import jakarta.json.stream.JsonParser;
3636
import jakarta.json.stream.JsonParserFactory;
37+
import org.junit.jupiter.api.AfterEach;
38+
import org.junit.jupiter.api.BeforeEach;
3739
import org.junit.jupiter.api.Test;
3840

3941
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -46,7 +48,23 @@ public class JsonProviderTest {
4648

4749
private static final String JSONP_PROVIDER_FACTORY = "jakarta.json.provider";
4850

49-
51+
private String factoryValue;
52+
53+
@BeforeEach
54+
public void setUp() {
55+
factoryValue = System.getProperty(JSONP_PROVIDER_FACTORY);
56+
System.clearProperty(JSONP_PROVIDER_FACTORY);
57+
}
58+
59+
@AfterEach
60+
public void reset() {
61+
if (factoryValue != null) {
62+
System.setProperty(JSONP_PROVIDER_FACTORY, factoryValue);
63+
} else {
64+
System.clearProperty(JSONP_PROVIDER_FACTORY);
65+
}
66+
}
67+
5068
/**
5169
* Verifies it is possible to obtain the JsonProvider implementation from a System property.
5270
*/

0 commit comments

Comments
 (0)