Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
2.18.1
-
None
-
None
Description
I have a couple of test which need to be run under specific locale.
It is achieved by this surefire plugin configuration:
Under Java 7 this plugin configuration works:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <systemPropertyVariables> <user.timezone>America/Chicago</user.timezone> </systemPropertyVariables> </configuration> </plugin>
but under Java 8 the test sensitive test still uses default system locale and they fail.
Surefire plugin sets system properties too late, because in Java 8, several locale-dependent variables are set much earlier than in Java 7, e.g. TimeZone.getDefault() and
properties specified in systemPropertyVariables section don't have influence on tests.
Workaround for it is setting system properties in argLine section, e.g. <argLine>-Duser.timezone=America/Chicago</argLine>.
Workaround:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <argLine>-Duser.timezone=America/Chicago</argLine> </configuration> </plugin>