Search in sources :

Example 31 with Date

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));
}
Also used : JobRunningStatistics(com.dangdang.ddframe.job.statistics.type.job.JobRunningStatistics) Date(java.util.Date) Test(org.junit.Test)

Example 32 with Date

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"));
}
Also used : BigDecimal(java.math.BigDecimal) Date(java.util.Date) Test(org.junit.Test)

Example 33 with Date

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())));
}
Also used : Timestamp(java.sql.Timestamp) Date(java.util.Date) Test(org.junit.Test)

Example 34 with Date

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);
}
Also used : Date(java.util.Date) Test(org.testng.annotations.Test)

Example 35 with Date

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();
}
Also used : Graceful(org.eclipse.jetty.util.component.Graceful) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ErrorHandler(org.eclipse.jetty.server.handler.ErrorHandler) StatisticsHandler(org.eclipse.jetty.server.handler.StatisticsHandler) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Date(java.util.Date) ServletException(javax.servlet.ServletException) MultiException(org.eclipse.jetty.util.MultiException) IOException(java.io.IOException) Future(java.util.concurrent.Future) MultiException(org.eclipse.jetty.util.MultiException)

Aggregations

Date (java.util.Date)33499 Test (org.junit.Test)8112 SimpleDateFormat (java.text.SimpleDateFormat)4502 ArrayList (java.util.ArrayList)3177 Calendar (java.util.Calendar)2351 HashMap (java.util.HashMap)1985 IOException (java.io.IOException)1914 File (java.io.File)1649 ParseException (java.text.ParseException)1578 List (java.util.List)1106 DateFormat (java.text.DateFormat)1022 Map (java.util.Map)983 GregorianCalendar (java.util.GregorianCalendar)884 Test (org.junit.jupiter.api.Test)853 HashSet (java.util.HashSet)576 Test (org.testng.annotations.Test)527 Timestamp (java.sql.Timestamp)458 BigDecimal (java.math.BigDecimal)436 LocalDate (java.time.LocalDate)423 DateTime (org.joda.time.DateTime)391