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 dbff2fc5dc Add a test case for SOAP based service to simulate a high
load (#2377)
dbff2fc5dc is described below
commit dbff2fc5dcd9b0ebf20862734dce15a528156158
Author: Andriy Redko <[email protected]>
AuthorDate: Tue Apr 29 16:54:00 2025 -0400
Add a test case for SOAP based service to simulate a high load (#2377)
---
.../cxf/systest/http/jaxws/JAXWSClientTest.java | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git
a/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSClientTest.java
b/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSClientTest.java
index 80e26f8711..4f7ddff486 100644
---
a/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSClientTest.java
+++
b/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSClientTest.java
@@ -21,13 +21,20 @@ package org.apache.cxf.systest.http.jaxws;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Objects;
import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import jakarta.jws.WebService;
import jakarta.xml.ws.soap.SOAPFaultException;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.ext.logging.event.LogEvent;
import org.apache.cxf.ext.logging.event.LogEventSender;
@@ -38,11 +45,13 @@ import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertThrows;
@@ -141,4 +150,53 @@ public class JAXWSClientTest extends
AbstractBusClientServerTestBase {
// HttpClient may keep some small amount worker threads around,
capping it to 5
assertThat(captureHttpClientThreads.get(),
lessThanOrEqualTo(expectedHttpClientThreads + 5L));
}
+
+ @Test
+ public void testNoChunkingHighLoad() throws Exception {
+ // setup the feature by using JAXWS front-end API
+ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+ factory.setAddress("http://localhost:" + PORT +
"/SoapContext/GreeterPort");
+ factory.setServiceClass(Greeter.class);
+
+ final Greeter proxy = factory.create(Greeter.class);
+ Client client = ClientProxy.getClient(proxy);
+ HTTPConduit http = (HTTPConduit) client.getConduit();
+
+ final HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
+ httpClientPolicy.setConnectionTimeout(3000);
+ httpClientPolicy.setAllowChunking(false);
+ httpClientPolicy.setVersion("1.1");
+ http.setClient(httpClientPolicy);
+
+ final AuthorizationPolicy authPolicy = new AuthorizationPolicy();
+ authPolicy.setUserName("test");
+ authPolicy.setPassword("test");
+ authPolicy.setAuthorizationType("Basic");
+ http.setAuthorization(authPolicy);
+
+ final char[] bytes = new char [32 * 1024];
+ final Random random = new Random();
+ for (int i = 0; i < bytes.length; ++i) {
+ bytes[i] = (char)(random.nextInt(26) + 'a');
+ }
+
+ final String greeting = new String(bytes);
+ final Collection<Future<String>> futures = new ArrayList<>();
+ final ExecutorService executor = Executors.newFixedThreadPool(10);
+
+ try {
+ for (int i = 0; i < 2000; ++i) {
+ futures.add(executor.submit(() -> proxy.greetMe(greeting)));
+ }
+
+ for (final Future<String> f: futures) {
+ assertThat(f.get(10, TimeUnit.SECONDS),
equalTo(greeting.toUpperCase()));
+ }
+ } finally {
+ executor.shutdown();
+ if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
+ executor.shutdownNow();
+ }
+ }
+ }
}