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