diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-12-04 09:11:15 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-12-04 09:11:49 +0100 |
commit | 6d839eabd042fdfa70d0d18931b8495cbe5b0c81 (patch) | |
tree | e5e1b3078ecb763530d87962b79d7ebc2cfb8016 /sonar-batch | |
parent | 808dd97c835e726a825adf512cf2d8ad6d7a9405 (diff) | |
download | sonarqube-6d839eabd042fdfa70d0d18931b8495cbe5b0c81.tar.gz sonarqube-6d839eabd042fdfa70d0d18931b8495cbe5b0c81.zip |
Try to make JsonReportTest timezone independent
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java index c2aa4b686af..94cabfd72eb 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java @@ -49,6 +49,7 @@ import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Collections; import java.util.Locale; +import java.util.TimeZone; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Matchers.eq; @@ -57,6 +58,8 @@ import static org.mockito.Mockito.when; public class JsonReportTest { + private SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + @org.junit.Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -72,6 +75,7 @@ public class JsonReportTest { @Before public void setUp() { + SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+02:00")); when(resource.getEffectiveKey()).thenReturn("Action.java"); when(server.getVersion()).thenReturn("3.6"); @@ -96,8 +100,8 @@ public class JsonReportTest { .setEffortToFix(3.14) .setReporter("julien") .setAssignee("simon") - .setCreationDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-04-24")) - .setUpdateDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-04-25")) + .setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24")) + .setUpdateDate(SIMPLE_DATE_FORMAT.parse("2013-04-25")) .setNew(false); when(ruleI18nManager.getName("squid", "AvoidCycles", Locale.getDefault())).thenReturn("Avoid Cycles"); when(jsonReport.getIssues()).thenReturn(Lists.<DefaultIssue>newArrayList(issue)); @@ -120,9 +124,9 @@ public class JsonReportTest { .setRuleKey(RuleKey.of("squid", "AvoidCycles")) .setStatus(Issue.STATUS_CLOSED) .setResolution(Issue.RESOLUTION_FIXED) - .setCreationDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-04-24")) - .setUpdateDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-04-25")) - .setCloseDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-04-26")) + .setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24")) + .setUpdateDate(SIMPLE_DATE_FORMAT.parse("2013-04-25")) + .setCloseDate(SIMPLE_DATE_FORMAT.parse("2013-04-26")) .setNew(false); when(ruleI18nManager.getName("squid", "AvoidCycles", Locale.getDefault())).thenReturn("Avoid Cycles"); when(jsonReport.getIssues()).thenReturn(Lists.<DefaultIssue>newArrayList(issue)); |