@Test(expected = InvalException.class) public void testInvalidNseconds() throws Exception { nfstime4 time = new nfstime4(); time.seconds = 1; time.nseconds = 1000000000; time.toMillis(); }
/** * openjdk-1.8 + maven fail to compile. Suppress warning until * a working alternative is found. */ @SuppressWarnings("deprecation") @Test public void testValidTime() throws Exception { nfstime4 time = new nfstime4(); time.seconds = 1; time.nseconds = (int)TimeUnit.MILLISECONDS.toNanos(5); long date = LocalDateTime.of(1970, 1, 1, 0, 0, 1, 0).toInstant(ZoneOffset.UTC).toEpochMilli(); assertEquals("invalid date", date + 5, time.toMillis()); }