diff options
Diffstat (limited to 'luni/src/test/java/libcore/javax/net/ssl/SSLSessionTest.java')
-rw-r--r-- | luni/src/test/java/libcore/javax/net/ssl/SSLSessionTest.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSessionTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSessionTest.java index 217dfe9..67c83bf 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLSessionTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSessionTest.java @@ -54,11 +54,24 @@ public class SSLSessionTest extends TestCase { } public void test_SSLSession_getCreationTime() { + // We use OpenSSL, which only returns times accurate to the nearest second. + // NativeCrypto just multiplies by 1000, which looks like truncation, which + // would make it appear as if the OpenSSL side of things was created before + // we called it. + long t0 = System.currentTimeMillis() / 1000; TestSSLSessions s = TestSSLSessions.create(); + long t1 = System.currentTimeMillis() / 1000; + assertTrue(s.invalid.getCreationTime() > 0); - assertTrue(s.server.getCreationTime() > 0); - assertTrue(s.client.getCreationTime() > 0); - assertTrue(Math.abs(s.server.getCreationTime() - s.client.getCreationTime()) < 1 * 1000); + + long sTime = s.server.getCreationTime() / 1000; + assertTrue(sTime + " >= " + t0, sTime >= t0); + assertTrue(sTime + " <= " + t1, sTime <= t1); + + long cTime = s.client.getCreationTime() / 1000; + assertTrue(cTime + " >= " + t0, cTime >= t0); + assertTrue(cTime + " <= " + t1, cTime <= t1); + s.close(); } |