You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2023/05/22 14:29:37 UTC
[cxf] branch 3.6.x-fixes updated: Update Undertow to 2.2.24.Final (#1272)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.6.x-fixes by this push:
new bd3e3de2fe Update Undertow to 2.2.24.Final (#1272)
bd3e3de2fe is described below
commit bd3e3de2fe775ab49ac2b381008636ba2f326152
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Mon May 22 10:29:28 2023 -0400
Update Undertow to 2.2.24.Final (#1272)
---
parent/pom.xml | 2 +-
.../http/auth/DigestAuthSupplierSpringTest.java | 1 +
systests/transport-undertow/pom.xml | 29 +---
.../http_undertow/UndertowDigestAuthTest.java | 10 +-
.../AbstractUndertowClientServerHttp2Test.java | 91 +++++-----
.../http_undertow/http2/Http2TestClient.java | 184 ---------------------
6 files changed, 62 insertions(+), 255 deletions(-)
diff --git a/parent/pom.xml b/parent/pom.xml
index 5e5541cd95..9be3c5d24a 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -218,7 +218,7 @@
<cxf.tomitribe.http.signature.version>1.8</cxf.tomitribe.http.signature.version>
<cxf.undertow.osgi.version>[1.4,3.0)</cxf.undertow.osgi.version>
<cxf.undertow.xnio.osgi.version>[3.3,4.0)</cxf.undertow.xnio.osgi.version>
- <cxf.undertow.version>2.2.20.Final</cxf.undertow.version>
+ <cxf.undertow.version>2.2.24.Final</cxf.undertow.version>
<!-- the Export-Package is the same as the Maven artifact
version (with the Final), but we don't want an import package with a version
with a qualifier. We do want a range. -->
diff --git a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthSupplierSpringTest.java b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthSupplierSpringTest.java
index 6a71ddae8e..93c4692401 100644
--- a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthSupplierSpringTest.java
+++ b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/http/auth/DigestAuthSupplierSpringTest.java
@@ -20,6 +20,7 @@ package org.apache.cxf.systest.hc5.http.auth;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.core.MediaType;
+
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transport.http.auth.DigestAuthSupplier;
diff --git a/systests/transport-undertow/pom.xml b/systests/transport-undertow/pom.xml
index 6c9b9e4329..661c203ddd 100644
--- a/systests/transport-undertow/pom.xml
+++ b/systests/transport-undertow/pom.xml
@@ -95,42 +95,34 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-jaxb</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-websocket</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.asynchttpclient</groupId>
@@ -153,22 +145,14 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
- <version>${cxf.atmosphere.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http-hc</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-undertow</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -183,12 +167,10 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-testutils</artifactId>
- <version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -201,26 +183,22 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-features-logging</artifactId>
- <version>${project.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>test</scope>
- <version>${cxf.spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>test</scope>
- <version>${cxf.spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>test</scope>
- <version>${cxf.spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -236,5 +214,10 @@
<artifactId>jaxb-xjc</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-hc5</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
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 15a662edc0..6f3f214a8d 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
@@ -44,13 +44,13 @@ import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transport.http.HTTPConduitConfigurer;
-import org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit;
+import org.apache.cxf.transport.http.asyncclient.hc5.AsyncHTTPConduit;
import org.apache.cxf.transport.http.auth.DigestAuthSupplier;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.SOAPService;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -119,7 +119,7 @@ public class UndertowDigestAuthTest extends AbstractClientServerTestBase {
cond.setClient(client);
if (async) {
if (cond instanceof AsyncHTTPConduit) {
- UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
+ 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);
@@ -166,7 +166,7 @@ public class UndertowDigestAuthTest extends AbstractClientServerTestBase {
try {
BindingProvider bp = (BindingProvider)greeter;
if (async) {
- UsernamePasswordCredentials creds = new UsernamePasswordCredentials("blah", "foo");
+ UsernamePasswordCredentials creds = new UsernamePasswordCredentials("blah", "foo".toCharArray());
bp.getRequestContext().put(Credentials.class.getName(), creds);
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "blah");
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 bf6a21fae1..fe60ca0489 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
@@ -25,72 +25,89 @@ import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transport.http.asyncclient.hc5.AsyncHTTPConduit;
import org.apache.cxf.transport.https.InsecureTrustManager;
-import io.undertow.client.ClientResponse;
-import io.undertow.util.Protocols;
-
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
abstract class AbstractUndertowClientServerHttp2Test extends AbstractBusClientServerTestBase {
@Test
public void testBookNotFoundWithHttp2() throws Exception {
- final Http2TestClient client = new Http2TestClient(isSecure());
-
- final ClientResponse response = client
- .request(getAddress())
+ final WebClient client = createWebClient("/web/bookstore/notFound", true);
+ assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
+
+ final Response response = client
.accept("text/plain")
.path(getContext() + "/web/bookstore/notFound")
- .http2()
.get();
-
- assertThat(response.getResponseCode(), equalTo(404));
- assertThat(response.getProtocol(), equalTo(Protocols.HTTP_2_0));
+
+ assertThat(response.getStatus(), equalTo(404));
+
+ client.close();
}
@Test
public void testBookWithHttp2() throws Exception {
- final Http2TestClient client = new Http2TestClient(isSecure());
-
- final ClientResponse response = client
- .request(getAddress())
+ final WebClient client = createWebClient("/web/bookstore/booknames", true);
+ assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
+
+ final Response response = client
.accept("text/plain")
- .path(getContext() + "/web/bookstore/booknames")
- .http2()
.get();
- assertThat(response.getResponseCode(), equalTo(200));
- assertThat(response.getProtocol(), equalTo(Protocols.HTTP_2_0));
- assertEquals("CXF in Action", client.getBody(response));
+ assertThat(response.getStatus(), equalTo(200));
+ assertEquals("CXF in Action", response.readEntity(String.class));
+
+ client.close();
}
@Test
public void testGetBookStreamHttp2() throws Exception {
- final Http2TestClient client = new Http2TestClient(isSecure());
+ final WebClient client = createWebClient("/web/bookstore/bookstream", true);
+ assertThat(WebClient.getConfig(client).getHttpConduit(), instanceOf(AsyncHTTPConduit.class));
- final ClientResponse response = client
- .request(getAddress())
+ final Response response = client
.accept("application/json")
- .path(getContext() + "/web/bookstore/bookstream")
- .http2()
.get();
- assertThat(response.getResponseCode(), equalTo(200));
- assertThat(response.getProtocol(), equalTo(Protocols.HTTP_2_0));
- assertEquals("{\"Book\":{\"id\":1,\"name\":\"WebSocket1\"}}",
- client.getBody(response));
+ assertThat(response.getStatus(), equalTo(200));
+ assertEquals("{\"Book\":{\"id\":1,\"name\":\"WebSocket1\"}}", response.readEntity(String.class));
+
+ client.close();
}
@Test
public void testBookWithHttp() throws Exception {
+ final WebClient client = createWebClient("/web/bookstore/booknames", false);
+
+ try (Response resp = client.get()) {
+ assertThat(resp.getStatus(), equalTo(200));
+ assertEquals("CXF in Action", resp.readEntity(String.class));
+ }
+
+ client.close();
+ }
+
+ protected abstract String getAddress();
+ protected abstract String getContext();
+
+ protected boolean isSecure() {
+ return getAddress().startsWith("https");
+ }
+
+ private WebClient createWebClient(final String path, final boolean enableHttp2) {
final WebClient wc = WebClient
- .create(getAddress() + getContext() + "/web/bookstore/booknames")
+ .create(getAddress() + getContext() + path)
.accept("text/plain");
-
+
+ WebClient.getConfig(wc).getRequestContext().put(AsyncHTTPConduit.ENABLE_HTTP2, enableHttp2);
+ WebClient.getConfig(wc).getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, "ALWAYS");
+
if (isSecure()) {
final HTTPConduit conduit = WebClient.getConfig(wc).getHttpConduit();
TLSClientParameters params = conduit.getTlsClientParameters();
@@ -105,16 +122,6 @@ abstract class AbstractUndertowClientServerHttp2Test extends AbstractBusClientSe
params.setDisableCNCheck(true);
}
- try (Response resp = wc.get()) {
- assertThat(resp.getStatus(), equalTo(200));
- assertEquals("CXF in Action", resp.readEntity(String.class));
- }
- }
-
- protected abstract String getAddress();
- protected abstract String getContext();
-
- protected boolean isSecure() {
- return getAddress().startsWith("https");
+ return wc;
}
}
diff --git a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/Http2TestClient.java b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/Http2TestClient.java
deleted file mode 100644
index 6d8ed7df0e..0000000000
--- a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/http2/Http2TestClient.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- * 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.http2;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.CompletableFuture;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLContext;
-import javax.ws.rs.core.MediaType;
-
-import org.apache.cxf.transport.https.InsecureTrustManager;
-import org.xnio.IoUtils;
-import org.xnio.OptionMap;
-import org.xnio.Options;
-import org.xnio.Xnio;
-import org.xnio.XnioWorker;
-
-import io.undertow.UndertowOptions;
-import io.undertow.client.ClientCallback;
-import io.undertow.client.ClientConnection;
-import io.undertow.client.ClientExchange;
-import io.undertow.client.ClientRequest;
-import io.undertow.client.ClientResponse;
-import io.undertow.client.UndertowClient;
-import io.undertow.connector.ByteBufferPool;
-import io.undertow.protocols.ssl.UndertowXnioSsl;
-import io.undertow.server.DefaultByteBufferPool;
-import io.undertow.util.AttachmentKey;
-import io.undertow.util.Headers;
-import io.undertow.util.HttpString;
-import io.undertow.util.Methods;
-import io.undertow.util.StringReadChannelListener;
-
-/**
- * TODO: Use CXF client once https://issues.apache.org/jira/browse/CXF-8606 is dones
- */
-public class Http2TestClient {
- private static final int BUFFER_SIZE = Integer.getInteger("test.bufferSize", 1024 * 16 - 20);
- private static final AttachmentKey<String> RESPONSE_BODY = AttachmentKey.create(String.class);
-
- private final UndertowClient client;
- private final UndertowXnioSsl ssl;
- private final XnioWorker worker;
- private final ByteBufferPool pool;
-
- public Http2TestClient(boolean secure) throws Exception {
- client = UndertowClient.getInstance();
-
- final Xnio xnio = Xnio.getInstance();
- worker = xnio.createWorker(null,
- OptionMap.builder()
- .set(Options.WORKER_IO_THREADS, 8)
- .set(Options.TCP_NODELAY, true)
- .set(Options.KEEP_ALIVE, true)
- .set(Options.WORKER_NAME, "TestClient")
- .getMap());
-
- pool = new DefaultByteBufferPool(true, BUFFER_SIZE, 1000, 10, 100);
- if (secure) {
- final SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
- sslContext.init(new KeyManager[] {}, InsecureTrustManager.getNoOpX509TrustManagers(), null);
- ssl = new UndertowXnioSsl(xnio, OptionMap.EMPTY, sslContext);
- } else {
- ssl = null;
- }
- }
-
- public class RequestBuilder {
- private final String address;
- private String path = "";
- private String accept = MediaType.WILDCARD;
- private OptionMap options = OptionMap.EMPTY;
-
- public RequestBuilder(final String address) {
- this.address = address;
- }
-
- public RequestBuilder path(final String p) {
- this.path = p;
- return this;
- }
-
-
- public RequestBuilder accept(final String a) {
- this.accept = a;
- return this;
- }
-
- public RequestBuilder http2() {
- options = OptionMap.create(UndertowOptions.ENABLE_HTTP2, true);
- return this;
- }
-
- public ClientResponse get() throws IOException {
- return request(address, path, options, Methods.GET, accept);
- }
- }
-
- public RequestBuilder request(final String address) throws IOException {
- return new RequestBuilder(address);
- }
-
- public ClientResponse request(final String address, final String path, final OptionMap options,
- final HttpString method, final String accept) throws IOException {
-
- final ClientConnection connection = client
- .connect(URI.create(address), worker, ssl, pool, options)
- .get();
-
- try {
- final ClientRequest request = new ClientRequest()
- .setMethod(method)
- .setPath(path);
-
- request.getRequestHeaders().put(Headers.ACCEPT, accept);
- request.getRequestHeaders().put(Headers.HOST, "localhost");
-
- final CompletableFuture<ClientResponse> future = new CompletableFuture<ClientResponse>();
- connection.sendRequest(request, createClientCallback(future));
- return future.join();
- } finally {
- IoUtils.safeClose(connection);
- }
- }
-
- private ClientCallback<ClientExchange> createClientCallback(final CompletableFuture<ClientResponse> future) {
- return new ClientCallback<ClientExchange>() {
- @Override
- public void completed(ClientExchange result) {
- result.setResponseListener(new ClientCallback<ClientExchange>() {
- @Override
- public void completed(final ClientExchange result) {
- new StringReadChannelListener(result.getConnection().getBufferPool()) {
- @Override
- protected void stringDone(String string) {
- result.getResponse().putAttachment(RESPONSE_BODY, string);
- future.complete(result.getResponse());
- }
-
- @Override
- protected void error(IOException e) {
- future.completeExceptionally(e);
- }
- }.setup(result.getResponseChannel());
- }
-
- @Override
- public void failed(IOException e) {
- future.completeExceptionally(e);
- }
- });
- }
-
- @Override
- public void failed(IOException e) {
- future.completeExceptionally(e);
- }
- };
- }
-
- public String getBody(ClientResponse response) {
- return response.getAttachment(RESPONSE_BODY);
- }
-
-}