Fix MailMetadataIT.metadataOnNewChange when running against NoteDb

MailMetadataIT.metadataOnNewChange failed when it was executed against
NoteDb, because of a timestamp mismatch. The NoteDb timestamps provide
precision only on second level, while the timestamp in the mail header
includes milli seconds. Fix comparing those timestamps by setting a 1s
clock step for the test.

Change-Id: If50f6d8b8a1897a9a197fb7a386650d8e298b3a3
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-11-17 14:40:31 -08:00
parent d3d8ba94a2
commit 6e01539e4b

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.server.mail;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
@@ -24,7 +25,10 @@ import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.server.mail.MailUtil;
import com.google.gerrit.server.mail.send.EmailHeader;
import com.google.gerrit.testutil.FakeEmailSender;
import com.google.gerrit.testutil.TestTimeUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.Timestamp;
@@ -38,6 +42,20 @@ import java.util.Map;
/** Tests the presence of required metadata in email headers, text and html. */
public class MailMetadataIT extends AbstractDaemonTest {
private String systemTimeZone;
@Before
public void setTimeForTesting() {
systemTimeZone = System.setProperty("user.timezone", "US/Eastern");
TestTimeUtil.resetWithClockStep(1, SECONDS);
}
@After
public void resetTime() {
TestTimeUtil.useSystemTime();
System.setProperty("user.timezone", systemTimeZone);
}
@Test
public void metadataOnNewChange() throws Exception {
PushOneCommit.Result newChange = createChange();