aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-04-02 15:17:31 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-04-02 16:53:38 +0200
commitd5b84364c57fd4f1f160661e3da105527ead4c28 (patch)
tree446b481d6ff94ddc0949b4997d5b2cceeb561ed8 /sonar-batch
parent9d98b11d4ed298aa9a6c312f9f34b51f32bfd481 (diff)
downloadsonarqube-d5b84364c57fd4f1f160661e3da105527ead4c28.tar.gz
sonarqube-d5b84364c57fd4f1f160661e3da105527ead4c28.zip
Use random timezone when executing tests from maven
This allows to fail-fast if a test is heavily coupled with local timezone.
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/platform/DefaultServerTest.java2
2 files changed, 5 insertions, 2 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
index c13593a9bba..86a866c271e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
@@ -28,6 +28,7 @@ import org.sonar.api.utils.System2;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.text.SimpleDateFormat;
+import java.util.TimeZone;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
@@ -70,7 +71,9 @@ public class ProjectConfiguratorTest extends AbstractDbUnitTestCase {
Project project = new Project("key");
new ProjectConfigurator(getSession(), settings, system2).configure(project);
- assertThat(new SimpleDateFormat("ddMMyyyy-mmss").format(project.getAnalysisDate())).isEqualTo("30012005-4510");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyy-mmss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ assertThat(dateFormat.format(project.getAnalysisDate())).isEqualTo("30012005-4510");
}
@Test(expected = RuntimeException.class)
diff --git a/sonar-batch/src/test/java/org/sonar/batch/platform/DefaultServerTest.java b/sonar-batch/src/test/java/org/sonar/batch/platform/DefaultServerTest.java
index 8c5e2a74752..adb2b134b1f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/platform/DefaultServerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/platform/DefaultServerTest.java
@@ -44,7 +44,7 @@ public class DefaultServerTest {
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");
- assertThat(metadata.getStartedAt().getDate()).isEqualTo(18);
+ assertThat(metadata.getStartedAt()).isNotNull();
assertThat(metadata.getURL()).isEqualTo("http://foo.com");
assertThat(metadata.getPermanentServerId()).isEqualTo("abcde");
}