diff --git a/test/jdk/java/net/httpclient/ConnectTimeoutNoProxyAsync.java b/test/jdk/java/net/httpclient/ConnectTimeoutNoProxyAsync.java deleted file mode 100644 index ace12cd0295..00000000000 --- a/test/jdk/java/net/httpclient/ConnectTimeoutNoProxyAsync.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 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 - * 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. - */ - -import java.net.http.HttpClient.Version; -import java.time.Duration; -import org.testng.annotations.Test; - -/* - * @test - * @summary Tests for connection related timeouts - * @bug 8208391 - * @run testng/othervm ConnectTimeoutNoProxyAsync - */ - -public class ConnectTimeoutNoProxyAsync extends AbstractConnectTimeout { - - @Test(dataProvider = "variants") - @Override - public void timeoutNoProxyAsync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestduration) - { - super.timeoutNoProxyAsync(requestVersion, scheme, method, connectTimeout, requestduration); - } -} diff --git a/test/jdk/java/net/httpclient/ConnectTimeoutNoProxySync.java b/test/jdk/java/net/httpclient/ConnectTimeoutNoProxySync.java deleted file mode 100644 index f30dea6deea..00000000000 --- a/test/jdk/java/net/httpclient/ConnectTimeoutNoProxySync.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 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 - * 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. - */ - -import java.net.http.HttpClient.Version; -import java.time.Duration; -import org.testng.annotations.Test; - -/* - * @test - * @summary Tests for connection related timeouts - * @bug 8208391 - * @run testng/othervm ConnectTimeoutNoProxySync - */ - -public class ConnectTimeoutNoProxySync extends AbstractConnectTimeout { - - @Test(dataProvider = "variants") - @Override - public void timeoutNoProxySync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) - throws Exception - { - super.timeoutNoProxySync(requestVersion, scheme, method, connectTimeout, requestTimeout); - } -} diff --git a/test/jdk/java/net/httpclient/AbstractConnectTimeout.java b/test/jdk/java/net/httpclient/ConnectTimeoutTest.java similarity index 86% rename from test/jdk/java/net/httpclient/AbstractConnectTimeout.java rename to test/jdk/java/net/httpclient/ConnectTimeoutTest.java index 4702b552d14..e5323b494c6 100644 --- a/test/jdk/java/net/httpclient/AbstractConnectTimeout.java +++ b/test/jdk/java/net/httpclient/ConnectTimeoutTest.java @@ -48,6 +48,8 @@ import java.util.stream.IntStream; import org.testng.annotations.AfterClass; import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_1_1; @@ -56,7 +58,17 @@ import static java.time.Duration.*; import static java.util.concurrent.TimeUnit.NANOSECONDS; import static org.testng.Assert.fail; -public abstract class AbstractConnectTimeout { +/* + * @test + * @bug 8208391 8375352 + * @summary Verifies behavior on `connect()` timeouts + * @run testng/othervm ${test.main.class} + * @run testng/othervm -Dtest.proxy ${test.main.class} + * @run testng/othervm -Dtest.async ${test.main.class} + * @run testng/othervm -Dtest.async -Dtest.proxy ${test.main.class} + */ + +public final class ConnectTimeoutTest { private static final int BACKLOG = 1; @@ -159,26 +171,21 @@ public abstract class AbstractConnectTimeout { return l.stream().toArray(Object[][]::new); } - //@Test(dataProvider = "variants") - protected void timeoutNoProxySync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) - throws Exception - { - timeoutSync(requestVersion, scheme, method, connectTimeout, requestTimeout, NO_PROXY); - } - - //@Test(dataProvider = "variants") - protected void timeoutWithProxySync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) - throws Exception - { - timeoutSync(requestVersion, scheme, method, connectTimeout, requestTimeout, PROXY_SELECTOR); + @Test(dataProvider = "variants") + public void test( + Version requestVersion, + String scheme, + String method, + Duration connectTimeout, + Duration requestTimeout) + throws Exception { + ProxySelector proxySelector = System.getProperty("test.proxy") != null ? PROXY_SELECTOR : NO_PROXY; + boolean async = System.getProperty("test.async") != null; + if (async) { + timeoutAsync(requestVersion, scheme, method, connectTimeout, requestTimeout, proxySelector); + } else { + timeoutSync(requestVersion, scheme, method, connectTimeout, requestTimeout, proxySelector); + } } private void timeoutSync(Version requestVersion, @@ -222,24 +229,6 @@ public abstract class AbstractConnectTimeout { } } - //@Test(dataProvider = "variants") - protected void timeoutNoProxyAsync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) { - timeoutAsync(requestVersion, scheme, method, connectTimeout, requestTimeout, NO_PROXY); - } - - //@Test(dataProvider = "variants") - protected void timeoutWithProxyAsync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) { - timeoutAsync(requestVersion, scheme, method, connectTimeout, requestTimeout, PROXY_SELECTOR); - } - private void timeoutAsync(Version requestVersion, String scheme, String method, diff --git a/test/jdk/java/net/httpclient/ConnectTimeoutWithProxyAsync.java b/test/jdk/java/net/httpclient/ConnectTimeoutWithProxyAsync.java deleted file mode 100644 index a6e0c22c15a..00000000000 --- a/test/jdk/java/net/httpclient/ConnectTimeoutWithProxyAsync.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 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 - * 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. - */ - -import java.net.http.HttpClient.Version; -import java.time.Duration; -import org.testng.annotations.Test; - -/* - * @test - * @summary Tests for connection related timeouts - * @bug 8208391 - * @run testng/othervm ConnectTimeoutWithProxyAsync - */ - -public class ConnectTimeoutWithProxyAsync extends AbstractConnectTimeout { - - @Test(dataProvider = "variants") - @Override - public void timeoutWithProxyAsync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) - { - super.timeoutWithProxyAsync(requestVersion, scheme, method, connectTimeout, requestTimeout); - } -} diff --git a/test/jdk/java/net/httpclient/ConnectTimeoutWithProxySync.java b/test/jdk/java/net/httpclient/ConnectTimeoutWithProxySync.java deleted file mode 100644 index a61fdc48bcf..00000000000 --- a/test/jdk/java/net/httpclient/ConnectTimeoutWithProxySync.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 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 - * 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. - */ - -import java.net.http.HttpClient.Version; -import java.time.Duration; -import org.testng.annotations.Test; - -/* - * @test - * @summary Tests for connection related timeouts - * @bug 8208391 - * @run testng/othervm ConnectTimeoutWithProxySync - */ - -public class ConnectTimeoutWithProxySync extends AbstractConnectTimeout { - - @Test(dataProvider = "variants") - @Override - public void timeoutWithProxySync(Version requestVersion, - String scheme, - String method, - Duration connectTimeout, - Duration requestTimeout) - throws Exception - { - super.timeoutWithProxySync(requestVersion, scheme, method, connectTimeout, requestTimeout); - } -}