Search in sources :

Example 66 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method multipliedBy_tooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void multipliedBy_tooBig() {
    Duration test = Duration.ofSeconds(1, 1);
    test.multipliedBy(Long.MAX_VALUE);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 67 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method plus_longTemporalUnit_micros.

@Test
public void plus_longTemporalUnit_micros() {
    Duration t = Duration.ofSeconds(1);
    t = t.plus(1, MICROS);
    assertEquals(1, t.getSeconds());
    assertEquals(1000, t.getNano());
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 68 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method minusSeconds_long_overflowTooSmall.

@Test(expectedExceptions = { ArithmeticException.class })
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 69 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method factory_of_longTemporalUnit.

@Test(dataProvider = "OfTemporalUnit")
public void factory_of_longTemporalUnit(long amount, TemporalUnit unit, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.of(amount, unit);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 70 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method test_toMillis_max.

@Test
public void test_toMillis_max() {
    Duration test = Duration.ofSeconds(Long.MAX_VALUE / 1000, (Long.MAX_VALUE % 1000) * 1000000);
    assertEquals(test.toMillis(), Long.MAX_VALUE);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (java.time.Duration)262 Test (org.testng.annotations.Test)135 Test (org.junit.Test)32 Instant (java.time.Instant)27 ArrayList (java.util.ArrayList)15 CompletableFuture (java.util.concurrent.CompletableFuture)15 Preconditions (com.google.common.base.Preconditions)14 Exceptions (io.pravega.common.Exceptions)13 List (java.util.List)13 CompletionException (java.util.concurrent.CompletionException)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 TimeoutTimer (io.pravega.common.TimeoutTimer)12 Futures (io.pravega.common.concurrent.Futures)12 SegmentProperties (io.pravega.segmentstore.contracts.SegmentProperties)11 StreamSegmentNotExistsException (io.pravega.segmentstore.contracts.StreamSegmentNotExistsException)11 Storage (io.pravega.segmentstore.storage.Storage)11 LoggerHelpers (io.pravega.common.LoggerHelpers)10 ZonedDateTime (java.time.ZonedDateTime)10 Executor (java.util.concurrent.Executor)10 Slf4j (lombok.extern.slf4j.Slf4j)10