8169196: [TESTBUG] Three tests from sun/net/www have undeclared dependencies
Reviewed-by: dfuchs
--- a/jdk/test/sun/net/www/http/HttpClient/RetryPost.java Thu Nov 10 08:59:34 2016 +0000
+++ b/jdk/test/sun/net/www/http/HttpClient/RetryPost.java Wed Nov 09 14:24:41 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -21,10 +21,25 @@
* questions.
*/
-import java.net.*;
-import java.util.*;
-import java.io.*;
-import com.sun.net.httpserver.*;
+/*
+ * @test
+ * @bug 6427251 6382788
+ * @modules jdk.httpserver
+ * @run main RetryPost
+ * @run main/othervm -Dsun.net.http.retryPost=false RetryPost noRetry
+ * @summary HttpURLConnection automatically retries non-idempotent method POST
+ */
+
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.SocketException;
+import java.net.URL;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
--- a/jdk/test/sun/net/www/http/HttpClient/RetryPost.sh Thu Nov 10 08:59:34 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#
-# Copyright (c) 2006, 2013, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
- # @test
- # @bug 6427251 6382788
- # @run shell/timeout=140 RetryPost.sh
- # @summary HttpURLConnection automatically retries non-idempotent method POST
-
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | AIX )
- PS=":"
- FS="/"
- ;;
- CYGWIN* )
- PS=";"
- FS="/"
- ;;
- Windows* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-# compile
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}RetryPost.java
-
-# run with no option specified. Should retry POST request.
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} RetryPost
-result=$?
-if [ "$result" -ne "0" ]; then
- exit 1
-fi
-
-# run with option specified. Should not retry POST request.
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dsun.net.http.retryPost=false RetryPost noRetry
-result=$?
-if [ "$result" -ne "0" ]; then
- exit 1
-fi
-
-# no failures, exit.
-exit 0
-
--- a/jdk/test/sun/net/www/http/KeepAliveStream/InfiniteLoop.java Thu Nov 10 08:59:34 2016 +0000
+++ b/jdk/test/sun/net/www/http/KeepAliveStream/InfiniteLoop.java Wed Nov 09 14:24:41 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -24,14 +24,19 @@
/*
* @test
* @bug 8004863
+ * @modules jdk.httpserver
* @summary Checks for proper close code in KeepAliveStream
*/
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
-import java.io.*;
-import java.net.*;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.URL;
import java.util.concurrent.Phaser;
// Racey test, will not always fail, but if it does then we have a problem.
--- a/jdk/test/sun/net/www/protocol/http/NoNTLM.java Thu Nov 10 08:59:34 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/http/NoNTLM.java Wed Nov 09 14:24:41 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,11 +26,19 @@
* @summary Sanity check that NTLM will not be selected by the http protocol
* handler when running on a profile that does not support NTLM
* @modules java.base/sun.net.www
+ * java.base/sun.net.www.protocol.http
* @run main/othervm NoNTLM
*/
-import java.net.*;
-import java.io.*;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.Proxy;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URL;
import sun.net.www.MessageHeader;
public class NoNTLM {
@@ -208,11 +216,14 @@
}
public static void main(String[] args) throws Exception {
- // assume NTLM is not supported when Kerberos is not available
try {
- Class.forName("javax.security.auth.kerberos.KerberosPrincipal");
- System.out.println("Kerberos is present, assuming NTLM is supported too");
- return;
+ Class<?> ntlmProxyClass = Class.forName("sun.net.www.protocol.http.NTLMAuthenticationProxy", true, NoNTLM.class.getClassLoader());
+ Field ntlmSupportedField = ntlmProxyClass.getDeclaredField("supported");
+ ntlmSupportedField.setAccessible(true);
+ if (ntlmSupportedField.getBoolean(null)) {
+ System.out.println("NTLM is supported. Nothing to do. Exiting.");
+ return;
+ }
} catch (ClassNotFoundException okay) { }
// setup Authenticator