test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java
changeset 50303 7164c3bb55df
parent 48397 ead47ddf5844
--- a/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java	Wed May 30 08:52:59 2018 +0200
+++ b/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java	Wed May 30 16:36:35 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,25 @@
  * @bug 4640544 8044773
  * @summary Unit test for ServerSocketChannel setOption/getOption/options
  *          methods.
+ * @modules jdk.net
  * @requires !vm.graal.enabled
  * @run main SocketOptionTests
  * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
 
-import java.nio.*;
 import java.nio.channels.*;
 import java.net.*;
 import java.io.IOException;
 import java.util.*;
 import static java.net.StandardSocketOptions.*;
+import static jdk.net.ExtendedSocketOptions.*;
 
 public class SocketOptionTests {
 
+    private static final int DEFAULT_KEEP_ALIVE_PROBES = 7;
+    private static final int DEFAULT_KEEP_ALIVE_TIME = 1973;
+    private static final int DEFAULT_KEEP_ALIVE_INTVL = 53;
+
     static void checkOption(ServerSocketChannel ssc, SocketOption name, Object expectedValue)
         throws IOException
     {
@@ -76,6 +81,16 @@
             ssc.setOption(SO_REUSEPORT, false);
             checkOption(ssc, SO_REUSEPORT, false);
         }
+        if (ssc.supportedOptions().containsAll(List.of(TCP_KEEPCOUNT,
+                TCP_KEEPIDLE, TCP_KEEPINTERVAL))) {
+            ssc.setOption(TCP_KEEPCOUNT, DEFAULT_KEEP_ALIVE_PROBES);
+            checkOption(ssc, TCP_KEEPCOUNT, DEFAULT_KEEP_ALIVE_PROBES);
+            ssc.setOption(TCP_KEEPIDLE, DEFAULT_KEEP_ALIVE_TIME);
+            checkOption(ssc, TCP_KEEPIDLE, DEFAULT_KEEP_ALIVE_TIME);
+            ssc.setOption(TCP_KEEPINTERVAL, DEFAULT_KEEP_ALIVE_INTVL);
+            checkOption(ssc, TCP_KEEPINTERVAL, DEFAULT_KEEP_ALIVE_INTVL);
+
+        }
 
         // NullPointerException
         try {