use of java.util.Date in project elastic-job by dangdangdotcom.
the class StatisticRdbRepositoryTest method assertFindLatestJobRunningStatistics.
@Test
public void assertFindLatestJobRunningStatistics() {
repository.add(new JobRunningStatistics(100, new Date()));
repository.add(new JobRunningStatistics(200, new Date()));
Optional<JobRunningStatistics> po = repository.findLatestJobRunningStatistics();
assertThat(po.get().getRunningCount(), is(200));
}
use of java.util.Date in project sharding-jdbc by dangdangdotcom.
the class ResultSetUtilTest method assertConvertNumberValueSuccess.
@Test
public void assertConvertNumberValueSuccess() {
assertThat((String) ResultSetUtil.convertValue("1", String.class), is("1"));
assertThat((byte) ResultSetUtil.convertValue((byte) 1, byte.class), is((byte) 1));
assertThat((short) ResultSetUtil.convertValue((short) 1, short.class), is((short) 1));
assertThat((int) ResultSetUtil.convertValue(new BigDecimal("1"), int.class), is(1));
assertThat((long) ResultSetUtil.convertValue(new BigDecimal("1"), long.class), is(1L));
assertThat((double) ResultSetUtil.convertValue(new BigDecimal("1"), double.class), is(1d));
assertThat((float) ResultSetUtil.convertValue(new BigDecimal("1"), float.class), is(1f));
assertThat((BigDecimal) ResultSetUtil.convertValue(new BigDecimal("1"), BigDecimal.class), is(new BigDecimal("1")));
assertThat((BigDecimal) ResultSetUtil.convertValue((short) 1, BigDecimal.class), is(new BigDecimal("1")));
assertThat((Date) ResultSetUtil.convertValue(new Date(0L), Date.class), is(new Date(0L)));
assertThat(ResultSetUtil.convertValue((short) 1, Object.class), is((Object) Short.valueOf("1")));
assertThat(ResultSetUtil.convertValue((short) 1, String.class), is((Object) "1"));
}
use of java.util.Date in project sharding-jdbc by dangdangdotcom.
the class ResultSetUtilTest method assertConvertDateValueSuccess.
@Test
public void assertConvertDateValueSuccess() {
Date now = new Date();
assertThat((Date) ResultSetUtil.convertValue(now, Date.class), is(now));
assertThat((java.sql.Date) ResultSetUtil.convertValue(now, java.sql.Date.class), is(now));
assertThat((Time) ResultSetUtil.convertValue(now, Time.class), is(now));
assertThat((Timestamp) ResultSetUtil.convertValue(now, Timestamp.class), is(new Timestamp(now.getTime())));
}
use of java.util.Date in project che by eclipse.
the class FactoryBaseValidatorTest method shouldNotValidateIfUntilSinceAfterCurrentTime.
@Test(expectedExceptions = ApiException.class, expectedExceptionsMessageRegExp = FactoryConstants.ILLEGAL_FACTORY_BY_SINCE_MESSAGE)
public void shouldNotValidateIfUntilSinceAfterCurrentTime() throws ApiException {
Long currentTime = new Date().getTime();
factory.withPolicies(newDto(PoliciesDto.class).withSince(currentTime + 10000L));
validator.validateCurrentTimeBetweenSinceUntil(factory);
}
use of java.util.Date in project jetty.project by eclipse.
the class Server method doStop.
/* ------------------------------------------------------------ */
@Override
protected void doStop() throws Exception {
if (isDumpBeforeStop())
dumpStdErr();
if (LOG.isDebugEnabled())
LOG.debug("doStop {}", this);
MultiException mex = new MultiException();
// list if graceful futures
List<Future<Void>> futures = new ArrayList<>();
// First close the network connectors to stop accepting new connections
for (Connector connector : _connectors) futures.add(connector.shutdown());
// Then tell the contexts that we are shutting down
Handler[] gracefuls = getChildHandlersByClass(Graceful.class);
for (Handler graceful : gracefuls) futures.add(((Graceful) graceful).shutdown());
// Shall we gracefully wait for zero connections?
long stopTimeout = getStopTimeout();
if (stopTimeout > 0) {
long stop_by = System.currentTimeMillis() + stopTimeout;
if (LOG.isDebugEnabled())
LOG.debug("Graceful shutdown {} by ", this, new Date(stop_by));
// Wait for shutdowns
for (Future<Void> future : futures) {
try {
if (!future.isDone())
future.get(Math.max(1L, stop_by - System.currentTimeMillis()), TimeUnit.MILLISECONDS);
} catch (Exception e) {
mex.add(e);
}
}
}
// Cancel any shutdowns not done
for (Future<Void> future : futures) if (!future.isDone())
future.cancel(true);
// Now stop the connectors (this will close existing connections)
for (Connector connector : _connectors) {
try {
connector.stop();
} catch (Throwable e) {
mex.add(e);
}
}
// And finally stop everything else
try {
super.doStop();
} catch (Throwable e) {
mex.add(e);
}
if (getStopAtShutdown())
ShutdownThread.deregister(this);
//Unregister the Server with the handler thread for receiving
//remote stop commands as we are stopped already
ShutdownMonitor.deregister(this);
mex.ifExceptionThrow();
}
Aggregations