From d5b84364c57fd4f1f160661e3da105527ead4c28 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 2 Apr 2015 15:17:31 +0200 Subject: Use random timezone when executing tests from maven This allows to fail-fast if a test is heavily coupled with local timezone. --- .../src/test/java/org/sonar/batch/ProjectConfiguratorTest.java | 5 ++++- .../src/test/java/org/sonar/batch/platform/DefaultServerTest.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'sonar-batch') 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"); } -- cgit v1.2.3