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

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git


The following commit(s) were added to refs/heads/main by this push:
     new aa2a538  PROTON-2452 Pass along node properties and receiver options 
to create
aa2a538 is described below

commit aa2a538085e974240d1ffe0420e5a4ca67bf207a
Author: Timothy Bish <[email protected]>
AuthorDate: Mon Nov 1 15:17:26 2021 -0400

    PROTON-2452 Pass along node properties and receiver options to create
    
    When creating a dynamic receiver with dynamic node properties or with
    receiver options only, ensure the values are passed along to the full
    fledged API that is being called to do the work.
---
 .../protonj2/client/impl/ClientConnection.java     |  4 +-
 .../qpid/protonj2/client/impl/ConnectionTest.java  | 80 ++++++++++++++++++++++
 2 files changed, 82 insertions(+), 2 deletions(-)

diff --git 
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientConnection.java
 
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientConnection.java
index 4eacbb2..184f7bf 100644
--- 
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientConnection.java
+++ 
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientConnection.java
@@ -326,12 +326,12 @@ public class ClientConnection implements Connection {
 
     @Override
     public Receiver openDynamicReceiver(Map<String, Object> 
dynamicNodeProperties) throws ClientException {
-        return openDynamicReceiver(null, null);
+        return openDynamicReceiver(dynamicNodeProperties, null);
     }
 
     @Override
     public Receiver openDynamicReceiver(ReceiverOptions receiverOptions) 
throws ClientException {
-        return openDynamicReceiver(null, null);
+        return openDynamicReceiver(null, receiverOptions);
     }
 
     @Override
diff --git 
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
 
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
index 3c57622..e13863d 100644
--- 
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
+++ 
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
@@ -38,6 +38,7 @@ import org.apache.qpid.protonj2.client.ConnectionOptions;
 import org.apache.qpid.protonj2.client.ErrorCondition;
 import org.apache.qpid.protonj2.client.Message;
 import org.apache.qpid.protonj2.client.Receiver;
+import org.apache.qpid.protonj2.client.ReceiverOptions;
 import org.apache.qpid.protonj2.client.Sender;
 import org.apache.qpid.protonj2.client.Session;
 import org.apache.qpid.protonj2.client.Tracker;
@@ -1034,6 +1035,85 @@ public class ConnectionTest extends 
ImperativeClientTestCase {
     }
 
     @Test
+    public void testCreateDynamicReceiverWithNodeProperties() throws Exception 
{
+        Map<String, Object> dynamicNodeProperties = new HashMap<>();
+        dynamicNodeProperties.put("test", "vale");
+
+        try (ProtonTestServer peer = new 
ProtonTestServer(testServerOptions())) {
+            peer.expectSASLAnonymousConnect();
+            peer.expectOpen().respond();
+            peer.expectBegin().respond();
+            peer.expectAttach().withRole(Role.RECEIVER.getValue())
+                               .withSource()
+                               .withDynamic(true)
+                               .withAddress(nullValue())
+                               
.withDynamicNodeProperties(dynamicNodeProperties)
+                               .also()
+                               .respond();
+            peer.expectFlow();
+            peer.expectDetach().respond();
+            peer.expectClose().respond();
+            peer.start();
+
+            URI remoteURI = peer.getServerURI();
+
+            LOG.info("Connect test started, peer listening on: {}", remoteURI);
+
+            Client container = Client.create();
+            Connection connection = container.connect(remoteURI.getHost(), 
remoteURI.getPort(), connectionOptions());
+            connection.openFuture().get(10, TimeUnit.SECONDS);
+
+            Receiver receiver = 
connection.openDynamicReceiver(dynamicNodeProperties);
+            receiver.openFuture().get(10, TimeUnit.SECONDS);
+
+            assertNotNull(receiver.address(), "Remote should have assigned the 
address for the dynamic receiver");
+
+            receiver.closeAsync().get(10, TimeUnit.SECONDS);
+
+            connection.closeAsync().get(10, TimeUnit.SECONDS);
+
+            peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
+        }
+    }
+
+    @Test
+    public void testCreateDynamicReceiverWithReceiverOptions() throws 
Exception {
+        try (ProtonTestServer peer = new 
ProtonTestServer(testServerOptions())) {
+            peer.expectSASLAnonymousConnect();
+            peer.expectOpen().respond();
+            peer.expectBegin().respond();
+            peer.expectAttach().withRole(Role.RECEIVER.getValue())
+                               .withDesiredCapabilities("queue")
+                               .respond();
+            peer.expectFlow();
+            peer.expectDetach().respond();
+            peer.expectClose().respond();
+            peer.start();
+
+            URI remoteURI = peer.getServerURI();
+
+            LOG.info("Connect test started, peer listening on: {}", remoteURI);
+
+            Client container = Client.create();
+            Connection connection = container.connect(remoteURI.getHost(), 
remoteURI.getPort(), connectionOptions());
+            connection.openFuture().get(10, TimeUnit.SECONDS);
+
+            ReceiverOptions options = new ReceiverOptions();
+            options.desiredCapabilities("queue");
+            Receiver receiver = connection.openDynamicReceiver(options);
+            receiver.openFuture().get(10, TimeUnit.SECONDS);
+
+            assertNotNull(receiver.address(), "Remote should have assigned the 
address for the dynamic receiver");
+
+            receiver.closeAsync().get(10, TimeUnit.SECONDS);
+
+            connection.closeAsync().get(10, TimeUnit.SECONDS);
+
+            peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
+        }
+    }
+
+    @Test
     public void 
testConnectionSenderOpenHeldUntilConnectionOpenedAndRelaySupportConfirmed() 
throws Exception {
         try (ProtonTestServer peer = new 
ProtonTestServer(testServerOptions())) {
             peer.expectSASLAnonymousConnect();

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to