diff --git a/systests/transport-hc5/pom.xml b/systests/transport-hc5/pom.xml
index 19440a2f334..e9d12f475eb 100644
--- a/systests/transport-hc5/pom.xml
+++ b/systests/transport-hc5/pom.xml
@@ -70,6 +70,31 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ forceURLConnection-test
+
+ test
+
+
+
+ true
+
+
+
+
+ default-test
+
+
+ false
+
+
+
+
+
diff --git a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/IsAsyncHttpConduit.java b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/IsAsyncHttpConduit.java
new file mode 100644
index 00000000000..2bf01803a64
--- /dev/null
+++ b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/IsAsyncHttpConduit.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.hc5;
+
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+import org.apache.cxf.transport.http.asyncclient.hc5.AsyncHTTPConduit;
+import org.apache.cxf.transport.http.asyncclient.hc5.URLConnectionAsyncHTTPConduit;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+public class IsAsyncHttpConduit extends TypeSafeMatcher {
+ public void describeTo(Description description) {
+ if (HTTPTransportFactory.isForceURLConnectionConduit()) {
+ description.appendText("instance of URLConnectionAsyncHTTPConduit async conduit ");
+ } else {
+ description.appendText("instance of AsyncHTTPConduit async conduit ");
+ }
+ }
+
+ @Override
+ protected boolean matchesSafely(Object item) {
+ return isAsyncConduit(item);
+ }
+
+ public static IsAsyncHttpConduit isInstanceOfAsyncHttpConduit() {
+ return new IsAsyncHttpConduit();
+ }
+
+ private static boolean isAsyncConduit(Object instance) {
+ if (HTTPTransportFactory.isForceURLConnectionConduit()) {
+ return instance instanceof URLConnectionAsyncHTTPConduit;
+ } else {
+ return instance instanceof AsyncHTTPConduit;
+ }
+ }
+}
diff --git a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthTest.java b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthTest.java
index 4d2565cc395..b412dc1dda2 100644
--- a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthTest.java
+++ b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthTest.java
@@ -49,6 +49,8 @@
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.apache.cxf.systest.hc5.IsAsyncHttpConduit.isInstanceOfAsyncHttpConduit;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -127,14 +129,11 @@ private Greeter setupClient(boolean async) throws Exception {
client.setReceiveTimeout(600000);
cond.setClient(client);
if (async) {
- if (cond instanceof AsyncHTTPConduit) {
- UsernamePasswordCredentials creds = new UsernamePasswordCredentials("foo", "bar".toCharArray());
- bp.getRequestContext().put(Credentials.class.getName(), creds);
- bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
- client.setAutoRedirect(true);
- } else {
- fail("Not an async conduit");
- }
+ assertThat("Not an async conduit", cond, isInstanceOfAsyncHttpConduit());
+ UsernamePasswordCredentials creds = new UsernamePasswordCredentials("foo", "bar".toCharArray());
+ bp.getRequestContext().put(Credentials.class.getName(), creds);
+ bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
+ client.setAutoRedirect(true);
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "foo");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "bar");
diff --git a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http2/AbstractApacheClientServerHttp2Test.java b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http2/AbstractApacheClientServerHttp2Test.java
index da4628ad68b..b93efc56b0b 100644
--- a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http2/AbstractApacheClientServerHttp2Test.java
+++ b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http2/AbstractApacheClientServerHttp2Test.java
@@ -29,8 +29,8 @@
import org.junit.Test;
+import static org.apache.cxf.systest.hc5.IsAsyncHttpConduit.isInstanceOfAsyncHttpConduit;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
@@ -38,8 +38,8 @@ abstract class AbstractApacheClientServerHttp2Test extends AbstractBusClientServ
@Test
public void testBookNotFoundWithHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/notFound", true);
- assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
-
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
+
final Response response = client
.accept("text/plain")
.path(getContext() + "/web/bookstore/notFound")
@@ -51,7 +51,7 @@ public void testBookNotFoundWithHttp2() throws Exception {
@Test
public void testBookTraceWithHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/trace", true);
- assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
final Response response = client
.accept("text/plain")
@@ -66,7 +66,7 @@ public void testBookTraceWithHttp2() throws Exception {
@Test
public void testBookWithHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/booknames", true);
- assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
final Response response = client
.accept("text/plain")
@@ -81,7 +81,7 @@ public void testBookWithHttp2() throws Exception {
@Test
public void testBookEncodedWithHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/book%20names", true);
- assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
final Response response = client
.accept("text/plain")
@@ -96,7 +96,7 @@ public void testBookEncodedWithHttp2() throws Exception {
@Test
public void testGetBookStreamHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/bookstream", true);
- assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
final Response response = client
.accept("application/xml")
diff --git a/systests/transport-undertow/pom.xml b/systests/transport-undertow/pom.xml
index e300a0cce7a..a6c6c088be8 100644
--- a/systests/transport-undertow/pom.xml
+++ b/systests/transport-undertow/pom.xml
@@ -89,6 +89,31 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ forceURLConnection-test
+
+ test
+
+
+
+ true
+
+
+
+
+ default-test
+
+
+ false
+
+
+
+
+
diff --git a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/IsAsyncHttpConduit.java b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/IsAsyncHttpConduit.java
new file mode 100644
index 00000000000..aebdeb35bf8
--- /dev/null
+++ b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/IsAsyncHttpConduit.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.http_undertow;
+
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+import org.apache.cxf.transport.http.asyncclient.hc5.AsyncHTTPConduit;
+import org.apache.cxf.transport.http.asyncclient.hc5.URLConnectionAsyncHTTPConduit;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+public class IsAsyncHttpConduit extends TypeSafeMatcher {
+ public void describeTo(Description description) {
+ if (HTTPTransportFactory.isForceURLConnectionConduit()) {
+ description.appendText("instance of URLConnectionAsyncHTTPConduit async conduit ");
+ } else {
+ description.appendText("instance of AsyncHTTPConduit async conduit ");
+ }
+ }
+
+ @Override
+ protected boolean matchesSafely(Object item) {
+ return isAsyncConduit(item);
+ }
+
+ public static IsAsyncHttpConduit isInstanceOfAsyncHttpConduit() {
+ return new IsAsyncHttpConduit();
+ }
+
+ private static boolean isAsyncConduit(Object instance) {
+ if (HTTPTransportFactory.isForceURLConnectionConduit()) {
+ return instance instanceof URLConnectionAsyncHTTPConduit;
+ } else {
+ return instance instanceof AsyncHTTPConduit;
+ }
+ }
+}
diff --git a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/UndertowDigestAuthTest.java b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/UndertowDigestAuthTest.java
index ab48a964722..448bf49bace 100644
--- a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/UndertowDigestAuthTest.java
+++ b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/UndertowDigestAuthTest.java
@@ -55,6 +55,8 @@
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.apache.cxf.systest.http_undertow.IsAsyncHttpConduit.isInstanceOfAsyncHttpConduit;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -118,14 +120,11 @@ private HTTPConduit setupClient(boolean async) throws Exception {
client.setReceiveTimeout(600000);
cond.setClient(client);
if (async) {
- if (cond.getClass().getName().endsWith("AsyncHTTPConduit")) {
- UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd".toCharArray());
- bp.getRequestContext().put(Credentials.class.getName(), creds);
- bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
- client.setAutoRedirect(true);
- } else {
- fail("Not an async conduit");
- }
+ assertThat("Not an async conduit", cond, isInstanceOfAsyncHttpConduit());
+ UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd".toCharArray());
+ bp.getRequestContext().put(Credentials.class.getName(), creds);
+ bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
+ client.setAutoRedirect(true);
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
diff --git a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/AbstractUndertowClientServerHttp2Test.java b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/AbstractUndertowClientServerHttp2Test.java
index d1179bb23f8..faac3e1d231 100644
--- a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/AbstractUndertowClientServerHttp2Test.java
+++ b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/AbstractUndertowClientServerHttp2Test.java
@@ -29,16 +29,16 @@
import org.junit.Test;
+import static org.apache.cxf.systest.http_undertow.IsAsyncHttpConduit.isInstanceOfAsyncHttpConduit;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
abstract class AbstractUndertowClientServerHttp2Test extends AbstractBusClientServerTestBase {
@Test
public void testBookNotFoundWithHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/notFound", true);
- assertTrue(WebClient.getConfig(client).getHttpConduit().getClass().getName().endsWith("AsyncHTTPConduit"));
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
final Response response = client
.accept("text/plain")
@@ -53,7 +53,7 @@ public void testBookNotFoundWithHttp2() throws Exception {
@Test
public void testBookWithHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/booknames", true);
- assertTrue(WebClient.getConfig(client).getHttpConduit().getClass().getName().endsWith("AsyncHTTPConduit"));
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
final Response response = client
.accept("text/plain")
@@ -68,8 +68,8 @@ public void testBookWithHttp2() throws Exception {
@Test
public void testGetBookStreamHttp2() throws Exception {
final WebClient client = createWebClient("/web/bookstore/bookstream", true);
- assertTrue(WebClient.getConfig(client).getHttpConduit().getClass().getName().endsWith("AsyncHTTPConduit"));
-
+ assertThat(WebClient.getConfig(client).getHttpConduit(), isInstanceOfAsyncHttpConduit());
+
final Response response = client
.accept("application/json")
.get();
diff --git a/systests/transports/pom.xml b/systests/transports/pom.xml
index 30444864db7..7a911f3d17f 100644
--- a/systests/transports/pom.xml
+++ b/systests/transports/pom.xml
@@ -88,6 +88,31 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ forceURLConnection-test
+
+ test
+
+
+
+ true
+
+
+
+
+ default-test
+
+
+ false
+
+
+
+
+
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/IsAsyncHttpConduit.java b/systests/transports/src/test/java/org/apache/cxf/systest/IsAsyncHttpConduit.java
new file mode 100644
index 00000000000..e2b773704ed
--- /dev/null
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/IsAsyncHttpConduit.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest;
+
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+import org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit;
+import org.apache.cxf.transport.http.asyncclient.URLConnectionAsyncHTTPConduit;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+public class IsAsyncHttpConduit extends TypeSafeMatcher {
+ public void describeTo(Description description) {
+ if (HTTPTransportFactory.isForceURLConnectionConduit()) {
+ description.appendText("instance of URLConnectionAsyncHTTPConduit async conduit ");
+ } else {
+ description.appendText("instance of AsyncHTTPConduit async conduit ");
+ }
+ }
+
+ @Override
+ protected boolean matchesSafely(Object item) {
+ return isAsyncConduit(item);
+ }
+
+ public static IsAsyncHttpConduit isInstanceOfAsyncHttpConduit() {
+ return new IsAsyncHttpConduit();
+ }
+
+ private static boolean isAsyncConduit(Object instance) {
+ if (HTTPTransportFactory.isForceURLConnectionConduit()) {
+ return instance instanceof URLConnectionAsyncHTTPConduit;
+ } else {
+ return instance instanceof AsyncHTTPConduit;
+ }
+ }
+}
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
index fa10c667315..c19dbe7663f 100644
--- a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
@@ -55,6 +55,8 @@
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.apache.cxf.systest.IsAsyncHttpConduit.isInstanceOfAsyncHttpConduit;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -116,14 +118,11 @@ private HTTPConduit setupClient(boolean async) throws Exception {
HTTPClientPolicy client = new HTTPClientPolicy();
cond.setClient(client);
if (async) {
- if (cond.getClass().getName().endsWith("AsyncHTTPConduit")) {
- UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
- bp.getRequestContext().put(Credentials.class.getName(), creds);
- bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
- client.setAutoRedirect(true);
- } else {
- fail("Not an async conduit");
- }
+ assertThat("Not an async conduit", cond, isInstanceOfAsyncHttpConduit());
+ UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
+ bp.getRequestContext().put(Credentials.class.getName(), creds);
+ bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
+ client.setAutoRedirect(true);
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");