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

amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git

commit 333f9e9052721d46dc189331b0be028ebe8a3347
Author: Amichai Rothman <[email protected]>
AuthorDate: Mon Jun 30 15:02:38 2025 +0300

    Improve TCP provider tests
---
 .../aries/rsa/provider/tcp/TcpProviderTest.java    | 33 +++++++++++++++-------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git 
a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
 
b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
index 02aa4cfd..6c39613b 100644
--- 
a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
+++ 
b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
@@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.core.StringStartsWith.startsWith;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
@@ -63,6 +64,7 @@ public class TcpProviderTest {
 
     private static final int TIMEOUT = 200;
     private static final int NUM_CALLS = 100;
+    private static final int NUM_THREADS = 10;
 
     private MyService myServiceProxy;
     private MyService myServiceProxy2;
@@ -86,7 +88,7 @@ public class TcpProviderTest {
         int port = getFreePort();
         props.put("aries.rsa.hostname", "localhost");
         props.put("aries.rsa.port", port);
-        props.put("aries.rsa.numThreads", "10");
+        props.put("aries.rsa.numThreads", NUM_THREADS);
         props.put("osgi.basic.timeout", TIMEOUT);
         BundleContext bc = EasyMock.mock(BundleContext.class);
         props.put("aries.rsa.id", "service1");
@@ -114,7 +116,7 @@ public class TcpProviderTest {
     }
 
     @Test
-    public void testCallTimeout() {
+    public void testClientTimeout() {
         try {
             myServiceProxy.callSlow(TIMEOUT + 100);
             Assert.fail("Expecting timeout");
@@ -122,14 +124,15 @@ public class TcpProviderTest {
             assertThat(e.getCause().getClass().getName(), 
equalTo(SocketTimeoutException.class.getName()));
             assertThat(e.getType(), equalTo(ServiceException.REMOTE));
         }
+        // and we recover to normal handling on the following call
+        assertEquals("next",myServiceProxy.echo("next"));
     }
 
     @Test
-    public void testPerf() throws InterruptedException {
-        runPerfTest(myServiceProxy);
-        String msg = "test";
-        String result = myServiceProxy.echo(msg);
-        Assert.assertEquals(msg, result);
+    public void testPerformance() throws InterruptedException {
+        runPerformanceTest(myServiceProxy);
+        // and continue normally afterward
+        assertEquals("test", myServiceProxy.echo("test"));
     }
 
     @Test(expected=ExpectedTestException.class)
@@ -142,6 +145,16 @@ public class TcpProviderTest {
         myServiceProxy.echo("test");
     }
 
+    @Test
+    public void testMultipleCalls() {
+        String s;
+        for (int i = 0; i < 5; i++) {
+            s = "test" + i;
+            assertEquals(s, s, myServiceProxy.echo(s));
+            assertThrows(ExpectedTestException.class, () -> 
myServiceProxy.callException());
+        }
+    }
+
     @Test
     public void testCallSharedPort() {
         Object port1 = ep.description().getProperties().get("aries.rsa.port");
@@ -155,7 +168,7 @@ public class TcpProviderTest {
      * Test for ARIES-1515
      */
     @Test
-    public void testCallWithInterfaceBasedParam() throws IOException, 
InterruptedException {
+    public void testCallWithInterfaceBasedParam() {
         List<String> msgList = new ArrayList<>();
         myServiceProxy.callWithList(msgList);
     }
@@ -227,13 +240,13 @@ public class TcpProviderTest {
         }
     }
 
-    private void runPerfTest(final MyService myServiceProxy2) throws 
InterruptedException {
+    private void runPerformanceTest(final MyService myServiceProxy2) throws 
InterruptedException {
         StringBuilder msg = new StringBuilder();
         for (int c = 0; c < 1000; c++) {
             msg.append("testing123");
         }
         final String msg2 = msg.toString();
-        ExecutorService executor = Executors.newFixedThreadPool(10);
+        ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
         Runnable task = new Runnable() {
 
             @Override

Reply via email to