BATCH-2668: Fixed failing test on CET timezone

In order to convert a String value to a Date, The `DefaultConversionService`
uses the constructor `java.util.Date(java.lang.String)` behind the scene
(from `org.springframework.core.convert.support.ObjectToObjectConverter.convert`).

This constructor throws a `java.lang.IllegalArgumentException` for values in
CET timezone, for example: "Thu Jan 04 09:05:50 CET 2018".

This commit updates the failing test to use a fixed timezone (UTC).

Resolves BATCH-2668
This commit is contained in:
Mahmoud Ben Hassine
2018-01-04 18:34:41 +01:00
committed by Michael Minella
parent c61809e158
commit a0773cac9b

View File

@@ -27,7 +27,10 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.TimeZone;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
@@ -54,6 +57,20 @@ import static org.junit.Assert.fail;
public class BeanWrapperFieldSetMapperTests {
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC");
private TimeZone defaultTimeZone = TimeZone.getDefault();
@Before
public void setUp() {
TimeZone.setDefault(UTC_TIME_ZONE);
}
@After
public void tearDown() {
TimeZone.setDefault(defaultTimeZone);
}
@Test
public void testNameAndTypeSpecified() throws Exception {
boolean errorCaught = false;