aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-08-16 23:11:08 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-08-16 23:11:08 +0200
commitc48a643629430e988f8d91740d9f84da8f731935 (patch)
treee8e225c3f5a560ac027c24a2b3b90e9c99e13f82 /sonar-batch
parent13ae5af72fca947c15e0d9f16c9c44396cc28aaa (diff)
downloadsonarqube-c48a643629430e988f8d91740d9f84da8f731935.tar.gz
sonarqube-c48a643629430e988f8d91740d9f84da8f731935.zip
Fix tests when timezone is not GMT+2
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/JsonReportTest.java10
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/JsonReportTest/report.json4
2 files changed, 12 insertions, 2 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/JsonReportTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/JsonReportTest.java
index 51ad93918b4..71cf7d91048 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/JsonReportTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/JsonReportTest.java
@@ -21,6 +21,7 @@ package org.sonar.batch.scan;
import com.google.common.collect.Lists;
import org.json.JSONException;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -45,6 +46,7 @@ import java.io.IOException;
import java.io.StringWriter;
import java.util.Collections;
import java.util.Locale;
+import java.util.TimeZone;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -62,9 +64,12 @@ public class JsonReportTest {
RuleI18nManager ruleI18nManager = mock(RuleI18nManager.class);
Settings settings;
IssueCache issueCache = mock(IssueCache.class);
+ TimeZone initialTimeZone;
@Before
public void setUp() {
+ initialTimeZone = TimeZone.getDefault();
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
when(resource.getEffectiveKey()).thenReturn("Action.java");
when(server.getVersion()).thenReturn("3.6");
@@ -73,6 +78,11 @@ public class JsonReportTest {
jsonReport = new JsonReport(settings, fileSystem, server, ruleI18nManager, issueCache, mock(EventBus.class));
}
+ @After
+ public void tearDown() throws Exception {
+ TimeZone.setDefault(initialTimeZone);
+ }
+
@Test
public void should_write_json() throws JSONException {
DefaultIssue issue = new DefaultIssue()
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/JsonReportTest/report.json b/sonar-batch/src/test/resources/org/sonar/batch/scan/JsonReportTest/report.json
index 6b6ead4619e..a6a5165f1b1 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/JsonReportTest/report.json
+++ b/sonar-batch/src/test/resources/org/sonar/batch/scan/JsonReportTest/report.json
@@ -11,8 +11,8 @@
"reporter": "julien",
"assignee": "simon",
"effortToFix": 3.14,
- "creationDate": "2013-04-24T00:00:00+0200",
- "updateDate": "2013-04-25T00:00:00+0200"
+ "creationDate": "2013-04-24T00:00:00+0000",
+ "updateDate": "2013-04-25T00:00:00+0000"
}
], "components": [
{