public void cleanup() throws IOException { DateTimeUtils.setCurrentMillisSystem(); if (this.fs.exists(testTempDirPath)) { if (!this.fs.delete(testTempDirPath, true)) { throw new IOException("Failed to clean up path " + this.testTempDirPath); } } }
private void resetTime() { DateTimeUtils.setCurrentMillisSystem(); } }
@AfterMethod public void tearDown() throws Exception { DateTimeUtils.setCurrentMillisSystem(); }
@After public void tearDown() throws Exception { if (this.defaultTz != null) { TimeZone.setDefault(this.defaultTz); } DateTimeUtils.setCurrentMillisSystem(); }
@After public void tearDown() { DateTimeUtils.setCurrentMillisSystem(); }
@AfterGroups("SystemTimeTests") public void resetSystemCurrentTime() { DateTimeUtils.setCurrentMillisSystem(); } }
@After public void unfreezeTime() { DateTimeUtils.setCurrentMillisSystem(); }
@After public void teardown() { DateTimeUtils.setCurrentMillisSystem(); }
@After public void teardown() { DateTimeUtils.setCurrentMillisSystem(); }
@After public void tearDown() throws Exception { // Restore to normal "now" time DateTimeUtils.setCurrentMillisSystem(); DateTimeZone.setDefault(mOldDefaultJodaTz); TimeZone.setDefault(mOldDefaultSystemTz); ContentResolver cr = InstrumentationRegistry.getContext().getContentResolver(); Settings.System.putString(cr, Settings.System.TIME_12_24, mOldTime1224Setting); }
Assert.assertTrue(deletedPaths.get(0).equals(snapshot2)); } finally { DateTimeUtils.setCurrentMillisSystem();
Assert.assertTrue(movedPaths.get(0).second().getParent().equals(createdDir)); } finally { DateTimeUtils.setCurrentMillisSystem();
@Test public void testISORetentionDuration() throws Exception { DateTimeUtils.setCurrentMillisFixed(new DateTime(2016, 2, 11, 10, 0, 0, 0).getMillis()); try { // 20 Days verify("P20D", ImmutableList.of(WithDate(new DateTime(2016, 1, 5, 10, 0, 0, 0)), WithDate(new DateTime(2016, 1, 6, 10, 0, 0, 0))), ImmutableList.of(WithDate(new DateTime(2016, 2, 10, 10, 0, 0, 0)), WithDate(new DateTime(2016, 2, 11, 10, 0, 0, 0)))); // 2 Months verify("P2M", ImmutableList.of(WithDate(new DateTime(2015, 12, 5, 10, 0, 0, 0)), WithDate(new DateTime(2015, 11, 5, 10, 0, 0, 0))), ImmutableList.of(WithDate(new DateTime(2016, 2, 10, 10, 0, 0, 0)), WithDate(new DateTime(2016, 1, 10, 10, 0, 0, 0)))); // 2 Years verify("P2Y", ImmutableList.of(WithDate(new DateTime(2014, 1, 5, 10, 0, 0, 0)), WithDate(new DateTime(2013, 1, 5, 10, 0, 0, 0))), ImmutableList.of(WithDate(new DateTime(2016, 2, 10, 10, 0, 0, 0)), WithDate(new DateTime(2015, 2, 10, 10, 0, 0, 0)))); // 20 Hours verify("PT20H", ImmutableList.of(WithDate(new DateTime(2016, 2, 10, 11, 0, 0, 0)), WithDate(new DateTime(2016, 2, 9, 11, 0, 0, 0))), ImmutableList.of(WithDate(new DateTime(2016, 2, 11, 8, 0, 0, 0)), WithDate(new DateTime(2016, 2, 11, 9, 0, 0, 0)))); } finally { // Restore time DateTimeUtils.setCurrentMillisSystem(); } }
DateTimeUtils.setCurrentMillisSystem();
public static Date resetClock() { DateTimeUtils.setCurrentMillisSystem(); return new Date(DateTimeUtils.currentTimeMillis()); }
public static Date resetClock() { DateTimeUtils.setCurrentMillisSystem(); return new Date(DateTimeUtils.currentTimeMillis()); }
@AfterMethod(alwaysRun = true) public void tearDown() throws Exception { DateTimeUtils.setCurrentMillisSystem(); } }
@AfterMethod(alwaysRun = true) public void tearDown() throws Exception { DateTimeUtils.setCurrentMillisSystem(); } }
@AfterMethod(alwaysRun = true) public void tearDown() throws Exception { DateTimeUtils.setCurrentMillisSystem(); } }
/** * This test manipulates global states (time) in org.joda.time.DateTimeUtils . Thus this test can * run in parallel with tests that do the same. */ @Test public void periodTimerTest() { // get a new timechecker, start from now, repeat every minute. should // evaluate to false now, and true a minute later. final long baseTimeInMilliSeconds = 1000; final ReadablePeriod period = Utils.parsePeriodString("10s"); DateTimeUtils.setCurrentMillisFixed(baseTimeInMilliSeconds); final BasicTimeChecker timeChecker = new BasicTimeChecker("BasicTimeChecket_1", baseTimeInMilliSeconds, DateTimeZone.UTC, true, true, period, null); final Condition cond = getCondition(timeChecker); assertFalse(cond.isMet()); DateTimeUtils.setCurrentMillisFixed(baseTimeInMilliSeconds + 11 * 1000); assertTrue(cond.isMet()); cond.resetCheckers(); assertFalse(cond.isMet()); DateTimeUtils.setCurrentMillisFixed(baseTimeInMilliSeconds + 22 * 1000); assertTrue(cond.isMet()); DateTimeUtils.setCurrentMillisSystem(); }