Skip to content

Commit b39304b

Browse files
committed
Use @DefaultTimeZone in test instead of setting a global variable
1 parent ddef8cd commit b39304b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
<artifactId>junit-jupiter-params</artifactId>
5353
<scope>test</scope>
5454
</dependency>
55+
<dependency>
56+
<groupId>org.junit-pioneer</groupId>
57+
<artifactId>junit-pioneer</artifactId>
58+
<scope>test</scope>
59+
</dependency>
5560
<dependency>
5661
<groupId>org.easymock</groupId>
5762
<artifactId>easymock</artifactId>

src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
import java.io.IOException;
2828
import java.io.Serializable;
2929
import java.util.Date;
30-
import java.util.TimeZone;
3130

3231
import org.apache.commons.collections4.functors.ConstantFactory;
3332
import org.apache.commons.collections4.functors.ExceptionFactory;
3433
import org.junit.jupiter.api.Test;
34+
import org.junitpioneer.jupiter.DefaultTimeZone;
3535

3636
/**
3737
* Tests the org.apache.commons.collections.FactoryUtils class.
@@ -129,8 +129,8 @@ void testExceptionFactory() {
129129
}
130130

131131
@Test
132+
@DefaultTimeZone("GMT")
132133
void testInstantiateFactoryComplex() {
133-
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
134134
// 2nd Jan 1970
135135
final Factory<Date> factory = FactoryUtils.instantiateFactory(Date.class,
136136
new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE},

0 commit comments

Comments
 (0)