|
|
|
@ -51,14 +51,22 @@ import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
|
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.junit.MockSystemReader; |
|
|
|
|
import org.eclipse.jgit.util.RelativeDateFormatter; |
|
|
|
|
import org.junit.Before; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
public class RelativeDateFormatterTest { |
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
public void setUp() { |
|
|
|
|
SystemReader.setInstance(new MockSystemReader()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void assertFormat(long ageFromNow, long timeUnit, |
|
|
|
|
String expectedFormat) { |
|
|
|
|
Date d = new Date(System.currentTimeMillis() - ageFromNow * timeUnit); |
|
|
|
|
Date d = new Date(SystemReader.getInstance().getCurrentTime() |
|
|
|
|
- ageFromNow * timeUnit); |
|
|
|
|
String s = RelativeDateFormatter.format(d); |
|
|
|
|
assertEquals(expectedFormat, s); |
|
|
|
|
} |
|
|
|
|