activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-225 validate clientID is set for durable sub
Date Fri, 18 Sep 2015 02:13:35 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master bb2c89080 -> 0a3ec0f4d


ARTEMIS-225 validate clientID is set for durable sub


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/1c933cfb
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/1c933cfb
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/1c933cfb

Branch: refs/heads/master
Commit: 1c933cfbaeae6518e2fcf55bcb58f3b714f04370
Parents: bb2c890
Author: jbertram <jbertram@apache.org>
Authored: Thu Sep 17 15:46:18 2015 -0500
Committer: jbertram <jbertram@apache.org>
Committed: Thu Sep 17 15:46:18 2015 -0500

----------------------------------------------------------------------
 .../ra/inflow/ActiveMQActivationSpec.java       |  5 ++
 .../ra/ActiveMQMessageHandlerTest.java          | 59 ++++++++++++++++++++
 2 files changed, 64 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1c933cfb/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
index f80342b..0b46b20 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
@@ -696,6 +696,11 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties
implemen
             propsNotSet.add(new PropertyDescriptor("subscriptionName", ActiveMQActivationSpec.class));
             errorMessages.add("If subscription is durable then subscription name must be
specified.");
          }
+
+         if ((isSubscriptionDurable() && getClientID() == null) || (isSubscriptionDurable()
&& getClientID() != null && getClientID().length() == 0)) {
+            propsNotSet.add(new PropertyDescriptor("clientID", ActiveMQActivationSpec.class));
+            errorMessages.add("If subscription is durable then clientID must be specified.");
+         }
       }
       catch (IntrospectionException e) {
          e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1c933cfb/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
index a5636cf..7f94f81 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java
@@ -715,6 +715,65 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase {
    }
 
    @Test
+   public void testNullClientID() throws Exception {
+      ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
+      MyBootstrapContext ctx = new MyBootstrapContext();
+      qResourceAdapter.start(ctx);
+
+      ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+      spec.setResourceAdapter(qResourceAdapter);
+      spec.setUseJNDI(false);
+      spec.setDestination("mdbTopic");
+      spec.setSubscriptionDurability("Durable");
+      spec.setSubscriptionName("sub");
+      spec.setSetupAttempts(1);
+      spec.setShareSubscriptions(true);
+      spec.setMaxSession(1);
+
+      CountDownLatch latch = new CountDownLatch(5);
+      DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
+      DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint,
false);
+      try {
+         qResourceAdapter.endpointActivation(endpointFactory, spec);
+         fail();
+      }
+      catch (Exception e) {
+         assertTrue(e instanceof InvalidPropertyException);
+         assertEquals("clientID", ((InvalidPropertyException) e).getInvalidPropertyDescriptors()[0].getName());
+      }
+   }
+
+   @Test
+   public void testEmptyClientID() throws Exception {
+      ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
+      MyBootstrapContext ctx = new MyBootstrapContext();
+      qResourceAdapter.start(ctx);
+
+      ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+      spec.setResourceAdapter(qResourceAdapter);
+      spec.setUseJNDI(false);
+      spec.setDestination("mdbTopic");
+      spec.setSubscriptionDurability("Durable");
+      spec.setSubscriptionName("sub");
+      spec.setClientID("");
+      spec.setSetupAttempts(1);
+      spec.setShareSubscriptions(true);
+      spec.setMaxSession(1);
+
+      CountDownLatch latch = new CountDownLatch(5);
+      DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
+      DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint,
false);
+      try {
+         qResourceAdapter.endpointActivation(endpointFactory, spec);
+         fail();
+      }
+      catch (Exception e) {
+         assertTrue(e instanceof InvalidPropertyException);
+         assertEquals("clientID", ((InvalidPropertyException) e).getInvalidPropertyDescriptors()[0].getName());
+      }
+   }
+
+   @Test
    public void testBadDestinationType() throws Exception {
       ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
       MyBootstrapContext ctx = new MyBootstrapContext();


Mime
View raw message