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

ffang pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 817b10b9089f29785e5f74f33e53a49f16dde320
Author: Tim Ward <[email protected]>
AuthorDate: Wed Jul 21 13:52:22 2021 +0100

    [CXF-8565] A failing test demonstrating the Netty Transport NPE
    A simple GET request with no body triggers an NPE because there is no 
content type for the request, and CXF tries to set a null Content-Type in the 
Netty Request
    Also add a test with a body, to ensure that Netty works reliably there as 
well
    
    Signed-off-by: Tim Ward <[email protected]>
    (cherry picked from commit e5f1c65f3bb2f0f043fb5572402a3932390b82c6)
---
 systests/jaxrs/pom.xml                             |  6 +++
 .../cxf/systest/jaxrs/JAXRSAsyncClientTest.java    | 47 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 6208ffb..e686094 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -259,6 +259,12 @@
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-netty-client</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-features-logging</artifactId>
             <version>${project.version}</version>
             <scope>test</scope>
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
index 3cbf337..15e4c04 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
@@ -57,9 +57,11 @@ import javax.xml.ws.Holder;
 
 import org.apache.cxf.jaxrs.client.ClientConfiguration;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.netty.client.NettyHttpTransportFactory;
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 
 import org.junit.Before;
@@ -478,6 +480,51 @@ public class JAXRSAsyncClientTest extends 
AbstractBusClientServerTestBase {
             assertThat(response.getStatus(), equalTo(404));
         }
     }
+
+    @Test
+    public void testNettyClientGet() throws Exception {
+        final String address = "http://localhost:"; + PORT + 
"/bookstore/books/wildcard";
+        
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        
bean.setTransportId(NettyHttpTransportFactory.DEFAULT_NAMESPACES.get(0));
+        bean.setAddress(address);
+        
+        WebClient webClient = bean.createWebClient();
+        
+        try (Response response = webClient
+                .to(address, false)
+                .accept("text/plain")
+                .async()
+                .get()
+                .get(10, TimeUnit.SECONDS)) {
+            assertThat(response.getStatus(), equalTo(200));
+        } finally {
+            webClient.close();
+        }
+    }
+    
+    @Test
+    public void testNettyClientDeleteWithBody() throws Exception {
+        final String address = "http://localhost:"; + PORT + 
"/bookstore/deletebody";
+        
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        
bean.setTransportId(NettyHttpTransportFactory.DEFAULT_NAMESPACES.get(0));
+        bean.setAddress(address);
+        
+        WebClient webClient = bean.createWebClient();
+        
+        try {
+            Book book = webClient
+                .to(address, false)
+                .accept("application/xml")
+                .async()
+                .method("DELETE", Entity.entity(new Book("Delete", 123L), 
"application/xml"), Book.class)
+                .get(20, TimeUnit.SECONDS);
+            assertEquals("Delete", book.getName());
+        } finally {
+            webClient.close();
+        }
+    }
     
     private WebClient createWebClient(String address) {
         return WebClient.create(address);

Reply via email to