This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new f4c01962b6 CXF-9062: Be able to create AsyncHTTPConduit based on 
URLConnectionHTTPConduit (add test suites to test forceURLConnection property 
activation)
f4c01962b6 is described below

commit f4c01962b630583127feed0731c8018ebb6d464a
Author: Andriy Redko <[email protected]>
AuthorDate: Tue Oct 8 12:47:51 2024 -0400

    CXF-9062: Be able to create AsyncHTTPConduit based on 
URLConnectionHTTPConduit (add test suites to test forceURLConnection property 
activation)
---
 systests/transport-hc5/pom.xml                     | 25 +++++++++++
 .../apache/cxf/systest/hc5/IsAsyncHttpConduit.java | 52 ++++++++++++++++++++++
 .../cxf/systest/hc5/http/auth/DigestAuthTest.java  | 15 +++----
 .../http2/AbstractApacheClientServerHttp2Test.java | 14 +++---
 systests/transport-undertow/pom.xml                | 25 +++++++++++
 .../systest/http_undertow/IsAsyncHttpConduit.java  | 52 ++++++++++++++++++++++
 .../http_undertow/UndertowDigestAuthTest.java      | 15 +++----
 .../AbstractUndertowClientServerHttp2Test.java     | 10 ++---
 systests/transports/pom.xml                        | 25 +++++++++++
 .../org/apache/cxf/systest/IsAsyncHttpConduit.java | 52 ++++++++++++++++++++++
 .../systest/http_jetty/JettyDigestAuthTest.java    | 15 +++----
 11 files changed, 264 insertions(+), 36 deletions(-)

diff --git a/systests/transport-hc5/pom.xml b/systests/transport-hc5/pom.xml
index 19440a2f33..e9d12f475e 100644
--- a/systests/transport-hc5/pom.xml
+++ b/systests/transport-hc5/pom.xml
@@ -70,6 +70,31 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>forceURLConnection-test</id>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <systemPropertyVariables>
+                                
<org.apache.cxf.transport.http.forceURLConnection>true</org.apache.cxf.transport.http.forceURLConnection>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>default-test</id>
+                        <configuration>
+                            <systemPropertyVariables>
+                                
<org.apache.cxf.transport.http.forceURLConnection>false</org.apache.cxf.transport.http.forceURLConnection>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
     <dependencies>
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 0000000000..2bf01803a6
--- /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<Object> {
+    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 4d2565cc39..b412dc1dda 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.apache.hello_world.services.SOAPService;
 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 @@ public class DigestAuthTest extends 
AbstractBusClientServerTestBase {
         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 da4628ad68..b93efc56b0 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.apache.cxf.transport.https.InsecureTrustManager;
 
 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 @@ abstract class AbstractApacheClientServerHttp2Test extends 
AbstractBusClientServ
     @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 @@ abstract class AbstractApacheClientServerHttp2Test extends 
AbstractBusClientServ
     @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 @@ abstract class AbstractApacheClientServerHttp2Test extends 
AbstractBusClientServ
     @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 @@ abstract class AbstractApacheClientServerHttp2Test extends 
AbstractBusClientServ
     @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 e300a0cce7..a6c6c088be 100644
--- a/systests/transport-undertow/pom.xml
+++ b/systests/transport-undertow/pom.xml
@@ -89,6 +89,31 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>forceURLConnection-test</id>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <systemPropertyVariables>
+                                
<org.apache.cxf.transport.http.forceURLConnection>true</org.apache.cxf.transport.http.forceURLConnection>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>default-test</id>
+                        <configuration>
+                            <systemPropertyVariables>
+                                
<org.apache.cxf.transport.http.forceURLConnection>false</org.apache.cxf.transport.http.forceURLConnection>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
     <dependencies>
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 0000000000..aebdeb35bf
--- /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<Object> {
+    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 ab48a96472..448bf49bac 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.apache.hello_world_soap_http.SOAPService;
 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 @@ public class UndertowDigestAuthTest extends 
AbstractClientServerTestBase {
         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 d1179bb23f..faac3e1d23 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.apache.cxf.transport.https.InsecureTrustManager;
 
 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 @@ abstract class AbstractUndertowClientServerHttp2Test extends 
AbstractBusClientSe
     @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 @@ abstract class AbstractUndertowClientServerHttp2Test extends 
AbstractBusClientSe
     @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 30444864db..7a911f3d17 100644
--- a/systests/transports/pom.xml
+++ b/systests/transports/pom.xml
@@ -88,6 +88,31 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>forceURLConnection-test</id>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <systemPropertyVariables>
+                                
<org.apache.cxf.transport.http.forceURLConnection>true</org.apache.cxf.transport.http.forceURLConnection>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>default-test</id>
+                        <configuration>
+                            <systemPropertyVariables>
+                                
<org.apache.cxf.transport.http.forceURLConnection>false</org.apache.cxf.transport.http.forceURLConnection>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
     <dependencies>
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 0000000000..e2b773704e
--- /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<Object> {
+    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 fa10c66731..c19dbe7663 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.apache.http.auth.UsernamePasswordCredentials;
 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 @@ public class JettyDigestAuthTest extends 
AbstractClientServerTestBase {
         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");

Reply via email to