List of usage examples for java.util.concurrent TimeUnit SECONDS
TimeUnit SECONDS
To view the source code for java.util.concurrent TimeUnit SECONDS.
Click Source Link
From source file:ca.aedwards.ldap.component.LdapClComponentTest.java
@Test public void testTimerInvokesBeanMethod() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(5); System.out.println("starting is satisfied"); assertMockEndpointsSatisfied(60, TimeUnit.SECONDS); //mock.assertIsSatisfied(450000); System.out.println("Finished is satisfied"); //assertMockEndpointsSatisfied(); }
From source file:com.dickthedeployer.dick.web.service.util.OptymisticLockService.java
@Transactional public void shouldThrowOptymisticLockException(Long id) throws InterruptedException, ExecutionException, TimeoutException { Worker finalWorker = workerDao.findOne(id); Executors.newSingleThreadExecutor().submit(() -> { Worker theSameWorker = workerDao.findOne(finalWorker.getId()); theSameWorker.setStatus(Worker.Status.BUSY); workerDao.save(theSameWorker);/*from ww w .j a va 2 s .co m*/ }).get(1, TimeUnit.SECONDS); finalWorker.setStatus(Worker.Status.DEAD); workerDao.save(finalWorker); }
From source file:crawler.IdleConnectionMonitorThread.java
@Override public void run() { try {/* w w w.j a va2 s.co m*/ while (!shutdown) { synchronized (this) { wait(5000); // Close expired connections connMgr.closeExpiredConnections(); // Optionally, close connections that have been idle longer than 30 sec connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (InterruptedException ignored) { // terminate } }
From source file:com.worldline.easycukes.selenium.utils.SeleniumHelper.java
/** * @param driver//from ww w. j a v a 2s . com * @param by * @return */ public static WebElement waitForElementToBePresent(@NonNull final WebDriver driver, @NonNull final By by) { final FluentWait<WebDriver> wait = new FluentWait<>(driver) .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS) .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS) .ignoring(NoSuchElementException.class); return wait.until(new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver webDriver) { try { if (webDriver.findElement(by).isDisplayed()) return webDriver.findElement(by); return null; } catch (final ElementNotVisibleException e) { return null; } } }); }
From source file:camelinaction.SpringBigFileCachedThreadPoolTest.java
@Test public void testBigFile() throws Exception { // when the first exchange is done NotifyBuilder notify = new NotifyBuilder(context).whenDoneByIndex(0).create(); long start = System.currentTimeMillis(); System.out.println("Waiting to be done with 2 min timeout (use ctrl + c to stop)"); notify.matches(2 * 60, TimeUnit.SECONDS); long delta = System.currentTimeMillis() - start; System.out.println("Took " + delta / 1000 + " seconds"); }
From source file:com.magnet.plugin.common.helpers.URLHelper.java
public static InputStream loadUrl(final String url) throws Exception { final InputStream[] inputStreams = new InputStream[] { null }; final Exception[] exception = new Exception[] { null }; Future<?> downloadThreadFuture = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { try { HttpURLConnection connection; if (ApplicationManager.getApplication() != null) { connection = HttpConfigurable.getInstance().openHttpConnection(url); } else { connection = (HttpURLConnection) new URL(url).openConnection(); connection.setReadTimeout(CONNECTION_TIMEOUT); connection.setConnectTimeout(CONNECTION_TIMEOUT); }/*from w w w .java 2 s.co m*/ connection.connect(); inputStreams[0] = connection.getInputStream(); } catch (IOException e) { exception[0] = e; } } }); try { downloadThreadFuture.get(5, TimeUnit.SECONDS); } catch (TimeoutException ignored) { } if (!downloadThreadFuture.isDone()) { downloadThreadFuture.cancel(true); throw new Exception(IdeBundle.message("updates.timeout.error")); } if (exception[0] != null) throw exception[0]; return inputStreams[0]; }
From source file:com.crawler.app.fetcher.IdleConnectionMonitorThread.java
@Override public void run() { try {//from w w w.j a v a 2s . c o m while (!shutdown) { synchronized (this) { wait(5000); // Close expired connections connMgr.closeExpiredConnections(); // Optionally, close connections that have been idle longer than 30 sec connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (InterruptedException ex) { // terminate } }
From source file:com.unknown.pkg.ProxiesCustomProfileApplicationIT.java
@Test public void startsUp() throws InterruptedException { TimeUnit.SECONDS.sleep(5); LOG.info("RUNNING ON PORT : {}", port); }
From source file:com.springer.omelet.driver.DriverUtility.java
/*** * Generic waitFor Function which waits for condition to be successful else * return null//www . j a va2s .c o m * * @param expectedCondition * :ExpectedCondition<T> * @param driver * :WebDriver * @param timeout * in seconds * @return <T> or null */ public static <T> T waitFor(ExpectedCondition<T> expectedCondition, WebDriver driver, int timeOutInSeconds) { Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); try { T returnValue = new WebDriverWait(driver, timeOutInSeconds).pollingEvery(500, TimeUnit.MILLISECONDS) .until(expectedCondition); return returnValue; } catch (TimeoutException e) { LOGGER.error(e); return null; } finally { driver.manage().timeouts().implicitlyWait(Driver.getBrowserConf().getDriverTimeOut(), TimeUnit.SECONDS); stopwatch.stop(); LOGGER.debug("Time Taken for waitFor method for Expected Condition is:" + stopwatch.elapsedTime(TimeUnit.SECONDS)); } }
From source file:com.ctrip.infosec.rule.resource.ListRepoTest.java
/** * Test of put method, of class ListRepo. *///from ww w .j a va 2 s. com @Test public void testPut() { System.out.println("put"); ListRepoResponse response = ListRepo.put("L0001001", "hello world!", 3, "my test value"); System.out.println("response: " + JSON.toJSONString(response)); assertEquals(response.getErrorCode(), "0"); ListRepoBooleanResponse booleanResponse = ListRepo.isIn("L0001001", "hello world!"); System.out.println("booleanResponse: " + JSON.toJSONString(booleanResponse)); assertEquals(booleanResponse.getErrorCode(), "0"); assertTrue(booleanResponse.getResult()); Threads.sleep(4, TimeUnit.SECONDS); booleanResponse = ListRepo.isIn("L0001001", "hello world!"); assertEquals(booleanResponse.getErrorCode(), "0"); assertTrue(booleanResponse.getResult() == false); }