Java Code Examples for java.time.Duration#minusSeconds()

The following examples show how to use java.time.Duration#minusSeconds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKDuration.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="MinusSeconds")
public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.minusSeconds(amount);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 2
Source File: TCKDuration.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="MinusSeconds")
public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.minusSeconds(amount);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 3
Source File: TCKDuration.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="MinusSeconds")
public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.minusSeconds(amount);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 4
Source File: TCKDuration.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="MinusSeconds")
public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.minusSeconds(amount);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 5
Source File: TCKDuration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="MinusSeconds")
public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.minusSeconds(amount);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 6
Source File: TCKDuration.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(1, 0);
    t.minusSeconds(Long.MIN_VALUE + 1);
}
 
Example 7
Source File: TCKDuration.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test(expected = ArithmeticException.class)
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 8
Source File: TCKDuration.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(1, 0);
    t.minusSeconds(Long.MIN_VALUE + 1);
}
 
Example 9
Source File: TCKDuration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 10
Source File: TCKDuration.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 11
Source File: AbstractStreamControllerTest.java    From kafka-webview with MIT License 4 votes vote down vote up
/**
 * Attempts to make a websocket connection as an authenticated user, and stream values from a view.
 */
@Test
public void test_authenticated_webSocketConnection() throws InterruptedException {
    // Create a count down latch to know when we have consumed all of our records.
    final CountDownLatch countDownLatch = new CountDownLatch(kafkaRecords.size());

    // Create a list we can add our consumed records to
    final List<Map> consumedRecords = new ArrayList<>();

    // Login to instance.
    final UserLoginDetails userLoginDetails = login();

    final WebSocketHttpHeaders socketHttpHeaders = new WebSocketHttpHeaders(userLoginDetails.getHttpHeaders());
    final long userId = userLoginDetails.getUserId();

    // Create websocket client
    final SockJsClient sockJsClient = new SockJsClient(createTransportClient());
    final WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);
    stompClient.setMessageConverter(new MappingJackson2MessageConverter());

    // Connect to websocket
    stompClient.connect(WEBSOCKET_URL, socketHttpHeaders, new StompSessionHandlerAdapter() {
        /**
         * After we connect, subscribe to our view.
         */
        @Override
        public void afterConnected(final StompSession session, final StompHeaders connectedHeaders) {
            session.setAutoReceipt(false);
            subscribeToResults(session, view.getId(), userId, countDownLatch, consumedRecords);
            try {
                requestNewStream(session, view.getId());
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }, port);

    // Start the client.
    stompClient.start();

    // Define a max time of 15 seconds
    Duration testTimeout = Duration.ofSeconds(15);

    while (countDownLatch.getCount() > 0) {
        // Sleep for a period and recheck.
        Thread.sleep(1000L);
        testTimeout = testTimeout.minusSeconds(1);

        if (testTimeout.isNegative()) {
            fail("Test timed out!");
        }
    }

    // Success!
    assertEquals("Found all messages!", consumedRecords.size(), kafkaRecords.size());
}
 
Example 12
Source File: TCKDuration.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(1, 0);
    t.minusSeconds(Long.MIN_VALUE + 1);
}
 
Example 13
Source File: TCKDuration.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(1, 0);
    t.minusSeconds(Long.MIN_VALUE + 1);
}
 
Example 14
Source File: TCKDuration.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 15
Source File: TCKDuration.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 16
Source File: TCKDuration.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(1, 0);
    t.minusSeconds(Long.MIN_VALUE + 1);
}
 
Example 17
Source File: TCKDuration.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 18
Source File: TCKDuration.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}
 
Example 19
Source File: TCKDuration.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Duration t = Duration.ofSeconds(1, 0);
    t.minusSeconds(Long.MIN_VALUE + 1);
}
 
Example 20
Source File: TCKDuration.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-2, 0);
    t.minusSeconds(Long.MAX_VALUE);
}