1818 */
1919package org .codehaus .groovy .control ;
2020
21+ import groovy .junit6 .plugin .ForkedJvm ;
2122import org .codehaus .groovy .control .customizers .ImportCustomizer ;
2223import org .codehaus .groovy .control .messages .WarningMessage ;
23- import org .junit .jupiter .api .AfterEach ;
24- import org .junit .jupiter .api .BeforeEach ;
2524import org .junit .jupiter .api .Test ;
2625
2726import java .io .File ;
2827import java .util .Arrays ;
2928import java .util .Collections ;
30- import java .util .Properties ;
3129
3230import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
3331import static org .junit .jupiter .api .Assertions .assertEquals ;
4240 */
4341public final class CompilerConfigurationTest {
4442
45- private Properties savedProperties ;
46-
47- @ BeforeEach
48- public void setUp () {
49- savedProperties = System .getProperties ();
50- System .setProperties (new Properties (savedProperties ));
51- }
52-
53- @ AfterEach
54- public void tearDown () {
55- System .setProperties (savedProperties );
56- }
57-
5843 @ Test
5944 public void testDefaultConstructor () {
6045 CompilerConfiguration config = CompilerConfiguration .DEFAULT ;
@@ -76,13 +61,17 @@ public void testDefaultConstructor() {
7661 }
7762
7863 @ Test
64+ @ ForkedJvm (systemProperties = {
65+ "groovy.warnings=PaRaNoiA" ,
66+ "groovy.output.verbose=trUE" ,
67+ "groovy.mem.stub=true" ,
68+ "groovy.generate.stub.in.memory=true" ,
69+ "groovy.recompile.minimumInterval=867892345" })
7970 public void testSetViaSystemProperties () {
80- System .setProperty ("groovy.warnings" , "PaRaNoiA" );
81- System .setProperty ("groovy.output.verbose" , "trUE" );
82- System .setProperty ("groovy.mem.stub" , "true" );
83- System .setProperty ("groovy.generate.stub.in.memory" , "true" );
84- System .setProperty ("groovy.recompile.minimumInterval" , "867892345" );
85-
71+ // Properties are set on the JVM command line via @ForkedJvm; the
72+ // forked child reads them through the normal System.getProperties()
73+ // path the production code uses, and parent-JVM state stays clean
74+ // for all the other (read-only) tests in this class.
8675 assertEquals ("PaRaNoiA" , System .getProperty ("groovy.warnings" ));
8776
8877 CompilerConfiguration config = new CompilerConfiguration (System .getProperties ());
0 commit comments