use of java.util.Timer in project platform_frameworks_base by android.
the class LocationBasedCountryDetectorTest method waitForTimerReset.
private void waitForTimerReset(TestCountryDetector detector) {
int count = 5;
long interval = 1000;
try {
while (count-- > 0 && detector.getTimer() != null) {
Thread.sleep(interval);
}
} catch (InterruptedException e) {
}
Timer timer = detector.getTimer();
assertTrue(timer == null);
}
use of java.util.Timer in project antlr4 by antlr.
the class SharedWebDriver method close.
public static void close() {
if (driver != null) {
if (timer != null) {
timer.cancel();
timer = null;
}
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
driver.quit();
driver = null;
}
}, // close with delay to allow next Test to start
2000);
}
}
use of java.util.Timer in project camel by apache.
the class QuickfixjProducerTest method processInOutExchangeSendUnsuccessful.
@Test
public void processInOutExchangeSendUnsuccessful() throws Exception {
Mockito.when(mockExchange.getPattern()).thenReturn(ExchangePattern.InOut);
Mockito.when(mockExchange.getProperty(QuickfixjProducer.CORRELATION_CRITERIA_KEY)).thenReturn(new MessagePredicate(sessionID, MsgType.EMAIL));
Mockito.when(mockExchange.getProperty(QuickfixjProducer.CORRELATION_TIMEOUT_KEY, 1000L, Long.class)).thenReturn(5000L);
org.apache.camel.Message mockOutboundCamelMessage = Mockito.mock(org.apache.camel.Message.class);
Mockito.when(mockExchange.getOut()).thenReturn(mockOutboundCamelMessage);
final Message outboundFixMessage = new Email();
outboundFixMessage.getHeader().setString(SenderCompID.FIELD, "TARGET");
outboundFixMessage.getHeader().setString(TargetCompID.FIELD, "SENDER");
Session mockSession = Mockito.spy(TestSupport.createSession(sessionID));
Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
Mockito.doAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
try {
quickfixjEngine.getMessageCorrelator().onEvent(QuickfixjEventCategory.AppMessageReceived, sessionID, outboundFixMessage);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}, 10);
return false;
}
}).when(mockSession).send(Matchers.isA(Message.class));
producer.process(mockExchange);
Mockito.verify(mockOutboundCamelMessage, Mockito.never()).setBody(Matchers.isA(Message.class));
Mockito.verify(mockSession).send(inboundFixMessage);
Mockito.verify(mockExchange).setException(Matchers.isA(CannotSendException.class));
}
use of java.util.Timer in project cube-sdk by liaohuqiu.
the class SystemWatcher method run.
public void run() {
mTimerTask = new TimerTask() {
@Override
public void run() {
MemoryInfo mi = new MemoryInfo();
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Activity.ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
Runtime runtime = Runtime.getRuntime();
String s = String.format("free:%s%% %sKB total:%sKB max:%sKB ", runtime.freeMemory() * 100f / runtime.totalMemory(), runtime.freeMemory(), runtime.totalMemory() / 1024, runtime.maxMemory() / 1024);
// s += String.format("native: free:%sKB total:%sKB max:%sKB", android.os.Debug.getNativeHeapFreeSize() / 1024, android.os.Debug.getNativeHeapAllocatedSize() / 1024,
// android.os.Debug.getNativeHeapSize() / 1024);
// s += String.format("| availMem:%sKB", mi.availMem / 1024);
Log.d("memory", s);
}
};
mTimer = new Timer();
mTimer.schedule(mTimerTask, 1000, 1000);
}
use of java.util.Timer in project JieCaoVideoPlayer by lipangit.
the class JCVideoPlayer method startProgressTimer.
public void startProgressTimer() {
cancelProgressTimer();
UPDATE_PROGRESS_TIMER = new Timer();
mProgressTimerTask = new ProgressTimerTask();
UPDATE_PROGRESS_TIMER.schedule(mProgressTimerTask, 0, 300);
}
Aggregations