This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
The following commit(s) were added to refs/heads/master by this push:
new 4f720f7dea Fix transport-h2 unit tests
4f720f7dea is described below
commit 4f720f7deabe1c66e7008f8f7a94a247aa986181
Author: Robert Lazarski <[email protected]>
AuthorDate: Wed Nov 19 04:20:18 2025 -1000
Fix transport-h2 unit tests
---
.../apache/axis2/kernel/http/HTTPConstants.java | 5 +
.../transport/h2/H2SOAPCompatibilityTest.java | 5 -
.../axis2/transport/h2/ProtocolValidationTest.java | 104 +++++++++++++++++++++
.../axis2/transport/h2/SimpleProtocolTest.java | 75 +++++++++++++++
.../http/AbstractHTTPTransportSender.java | 10 +-
.../apache/axis2/transport/http/HTTPSender.java | 6 +-
src/site/xdoc/docs/http2-transport-additions.xml | 4 +-
7 files changed, 199 insertions(+), 10 deletions(-)
diff --git a/modules/kernel/src/org/apache/axis2/kernel/http/HTTPConstants.java
b/modules/kernel/src/org/apache/axis2/kernel/http/HTTPConstants.java
index 19d9f0792c..d555958edc 100644
--- a/modules/kernel/src/org/apache/axis2/kernel/http/HTTPConstants.java
+++ b/modules/kernel/src/org/apache/axis2/kernel/http/HTTPConstants.java
@@ -227,6 +227,11 @@ public class HTTPConstants {
*/
public static final String HEADER_PROTOCOL_10 = "HTTP/1.0";
+ /**
+ * Field HEADER_PROTOCOL_20
+ */
+ public static final String HEADER_PROTOCOL_20 = "HTTP/2.0";
+
/**
* Field HEADER_PRAGMA
*/
diff --git
a/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/H2SOAPCompatibilityTest.java
b/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/H2SOAPCompatibilityTest.java
index 974cd0aa12..dc78f57552 100644
---
a/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/H2SOAPCompatibilityTest.java
+++
b/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/H2SOAPCompatibilityTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.axis2.transport.h2;
-import static com.google.common.truth.Truth.assertAbout;
-import static org.apache.axiom.truth.xml.XMLTruth.xml;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -39,14 +36,12 @@ import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.NamedValue;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.Handler.InvocationResponse;
import org.apache.axis2.kernel.http.HTTPConstants;
import org.apache.axis2.transport.h2.impl.httpclient5.H2TransportSender;
diff --git
a/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/ProtocolValidationTest.java
b/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/ProtocolValidationTest.java
new file mode 100644
index 0000000000..4ad02e742d
--- /dev/null
+++
b/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/ProtocolValidationTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.axis2.transport.h2;
+
+import junit.framework.TestCase;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.transport.h2.impl.httpclient5.H2TransportSender;
+
+/**
+ * Test to verify that the HTTP/2.0 PROTOCOL parameter validation fix works
correctly.
+ */
+public class ProtocolValidationTest extends TestCase {
+
+ public void testHTTP2ProtocolValidation() throws Exception {
+ // Create minimal configuration context
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ ConfigurationContext configContext = new
ConfigurationContext(axisConfig);
+
+ // Create transport description with HTTP/2.0 protocol
+ TransportOutDescription transportOut = new
TransportOutDescription("h2");
+ transportOut.addParameter(new Parameter("PROTOCOL", "HTTP/2.0"));
+
+ // Create H2TransportSender
+ H2TransportSender transportSender = new H2TransportSender();
+
+ try {
+ // This should NOT throw an exception after the fix
+ transportSender.init(configContext, transportOut);
+
+ // If we get here, the fix worked
+ System.out.println("SUCCESS: H2TransportSender.init() accepted
HTTP/2.0 protocol");
+
+ // Verify the protocol parameter was preserved
+ Parameter protocolParam = transportOut.getParameter("PROTOCOL");
+ assertNotNull("Protocol parameter should not be null",
protocolParam);
+ assertEquals("Protocol parameter should be HTTP/2.0", "HTTP/2.0",
protocolParam.getValue());
+
+ } catch (AxisFault e) {
+ // If we get the old error, the fix didn't work
+ if (e.getMessage().contains("Can have values only HTTP/1.0 or
HTTP/1.1")) {
+ fail("FIX FAILED: Still getting protocol validation error: " +
e.getMessage());
+ } else {
+ // Some other error - re-throw it
+ throw e;
+ }
+ } finally {
+ // Clean up
+ try {
+ transportSender.stop();
+ } catch (Exception e) {
+ // Ignore cleanup errors
+ }
+ }
+ }
+
+ public void testHTTP11StillWorks() throws Exception {
+ // Verify that HTTP/1.1 still works after our changes
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ ConfigurationContext configContext = new
ConfigurationContext(axisConfig);
+
+ TransportOutDescription transportOut = new
TransportOutDescription("h2");
+ transportOut.addParameter(new Parameter("PROTOCOL", "HTTP/1.1"));
+
+ H2TransportSender transportSender = new H2TransportSender();
+
+ try {
+ // This should work fine
+ transportSender.init(configContext, transportOut);
+
+ // Verify the protocol parameter was preserved
+ Parameter protocolParam = transportOut.getParameter("PROTOCOL");
+ assertNotNull("Protocol parameter should not be null",
protocolParam);
+ assertEquals("Protocol parameter should be HTTP/1.1", "HTTP/1.1",
protocolParam.getValue());
+
+ } finally {
+ try {
+ transportSender.stop();
+ } catch (Exception e) {
+ // Ignore cleanup errors
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git
a/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/SimpleProtocolTest.java
b/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/SimpleProtocolTest.java
new file mode 100644
index 0000000000..6b7adeacfb
--- /dev/null
+++
b/modules/transport-h2/src/test/java/org/apache/axis2/transport/h2/SimpleProtocolTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.axis2.transport.h2;
+
+import junit.framework.TestCase;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.kernel.http.HTTPConstants;
+import org.apache.axis2.transport.h2.impl.httpclient5.H2TransportSender;
+
+/**
+ * Simple test to verify HTTP/2.0 protocol support works with the cleaner
approach.
+ */
+public class SimpleProtocolTest extends TestCase {
+
+ public void testHTTP2ProtocolSupport() throws Exception {
+ System.out.println("Testing clean HTTP/2.0 protocol support...");
+
+ // Create minimal test setup
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ ConfigurationContext configContext = new
ConfigurationContext(axisConfig);
+ TransportOutDescription transportOut = new
TransportOutDescription("h2");
+
+ // Set HTTP/2.0 protocol parameter
+ transportOut.addParameter(new Parameter("PROTOCOL",
HTTPConstants.HEADER_PROTOCOL_20));
+
+ H2TransportSender sender = new H2TransportSender();
+
+ try {
+ // This should work with our clean fix
+ sender.init(configContext, transportOut);
+ System.out.println("✅ SUCCESS: HTTP/2.0 protocol accepted!");
+
+ // Verify parameter is still HTTP/2.0
+ Parameter protocol = transportOut.getParameter("PROTOCOL");
+ assertEquals("HTTP/2.0 parameter should be preserved",
+ HTTPConstants.HEADER_PROTOCOL_20,
protocol.getValue());
+
+ } catch (AxisFault e) {
+ System.err.println("❌ FAILED: " + e.getMessage());
+ throw e;
+ } finally {
+ try {
+ sender.stop();
+ } catch (Exception ignored) {}
+ }
+ }
+
+ public void testConstantValue() {
+ // Verify our constant is correct
+ assertEquals("HTTP/2.0 constant should match expected value",
+ "HTTP/2.0", HTTPConstants.HEADER_PROTOCOL_20);
+ System.out.println("✅ HTTP/2.0 constant value is correct: " +
HTTPConstants.HEADER_PROTOCOL_20);
+ }
+}
\ No newline at end of file
diff --git
a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java
b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java
index ea1e750d5f..06c9bcc094 100644
---
a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java
+++
b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java
@@ -87,7 +87,8 @@ public abstract class AbstractHTTPTransportSender extends
AbstractHandler implem
setHTTPClientVersion(confContext);
// <parameter name="PROTOCOL">HTTP/1.0</parameter> or
- // <parameter name="PROTOCOL">HTTP/1.1</parameter> is
+ // <parameter name="PROTOCOL">HTTP/1.1</parameter> or
+ // <parameter name="PROTOCOL">HTTP/2.0</parameter> is
// checked
Parameter version = transportOut
.getParameter(HTTPConstants.PROTOCOL_VERSION);
@@ -106,10 +107,15 @@ public abstract class AbstractHTTPTransportSender extends
AbstractHandler implem
} else if (HTTPConstants.HEADER_PROTOCOL_10.equals(version
.getValue())) {
defaultHttpVersion = HTTPConstants.HEADER_PROTOCOL_10;
+ } else if (HTTPConstants.HEADER_PROTOCOL_20.equals(version
+ .getValue())) {
+ defaultHttpVersion = HTTPConstants.HEADER_PROTOCOL_20;
+ // HTTP/2.0 supports multiplexing, so enable chunked by default
+ defaultChunked = true;
} else {
throw new AxisFault("Parameter "
+ HTTPConstants.PROTOCOL_VERSION
- + " Can have values only HTTP/1.0 or HTTP/1.1");
+ + " Can have values only HTTP/1.0, HTTP/1.1, or
HTTP/2.0");
}
}
diff --git
a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java
b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java
index 5fffb378ab..e983dd4267 100644
---
a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java
+++
b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java
@@ -96,10 +96,14 @@ public abstract class HTTPSender {
this.httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
// chunked is not possible with HTTP/1.0
this.chunked = false;
+ } else if (HTTPConstants.HEADER_PROTOCOL_20.equals(version)) {
+ this.httpVersion = HTTPConstants.HEADER_PROTOCOL_20;
+ // HTTP/2.0 supports multiplexing, enable chunked
+ this.chunked = true;
} else {
throw new AxisFault(
"Parameter " + HTTPConstants.PROTOCOL_VERSION
- + " Can have values only HTTP/1.0 or
HTTP/1.1");
+ + " Can have values only HTTP/1.0, HTTP/1.1,
or HTTP/2.0");
}
}
}
diff --git a/src/site/xdoc/docs/http2-transport-additions.xml
b/src/site/xdoc/docs/http2-transport-additions.xml
index 86c3accd8f..71f83263d6 100644
--- a/src/site/xdoc/docs/http2-transport-additions.xml
+++ b/src/site/xdoc/docs/http2-transport-additions.xml
@@ -191,7 +191,7 @@ options.setProperty("MAX_CONCURRENT_STREAMS", 20);
<p>The H2TransportSender provides three processing modes optimized for
different payload sizes:</p>
<ul>
- <li><strong>Standard Processing</strong> (&lt;10MB): Regular HTTP/2
features</li>
+ <li><strong>Standard Processing</strong> (0MB-10MB): Regular HTTP/2
features</li>
<li><strong>Multiplexing Mode</strong> (10-50MB): Enhanced concurrent
processing</li>
<li><strong>Streaming Mode</strong> (50MB+): Memory-efficient streaming with
chunked processing</li>
</ul>
@@ -621,7 +621,7 @@ httpAsyncClient.start();
<p>For SOAP services using HTTP/2 transport:</p>
<ul>
- <li><strong>Small SOAP Messages (&lt;1MB):</strong> 5-15% latency
improvement due to connection multiplexing</li>
+ <li><strong>Small SOAP Messages (0MB-1MB):</strong> 5-15% latency
improvement due to connection multiplexing</li>
<li><strong>Medium SOAP Messages (1-10MB):</strong> 10-20% improvement from
header compression</li>
<li><strong>Large SOAP Messages (10MB+):</strong> 15-25% improvement from
streaming, but still much slower than equivalent JSON</li>
<li><strong>Concurrent SOAP Calls:</strong> 20-40% improvement from stream
multiplexing</li>